examples/audio: Use the same audio file for Ogg and MP3

This also changes the sample rate to 32000 for some special
environments.
This commit is contained in:
Hajime Hoshi 2021-02-21 17:57:02 +09:00
parent e873b386a0
commit 6f462e824f
10 changed files with 18 additions and 26 deletions

View File

@ -42,7 +42,7 @@ const (
screenWidth = 640 screenWidth = 640
screenHeight = 480 screenHeight = 480
sampleRate = 22050 sampleRate = 32000
) )
var ( var (
@ -106,7 +106,7 @@ func NewPlayer(audioContext *audio.Context, musicType musicType) (*Player, error
} }
case typeMP3: case typeMP3:
var err error var err error
s, err = mp3.Decode(audioContext, bytes.NewReader(raudio.Classic_mp3)) s, err = mp3.Decode(audioContext, bytes.NewReader(raudio.Ragtime_mp3))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -255,10 +255,11 @@ Press S to toggle Play/Pause
Press P to play SE Press P to play SE
Press Z or X to change volume of the music Press Z or X to change volume of the music
Press U to switch the runnable-on-unfocused state Press U to switch the runnable-on-unfocused state
Press A to switch Ogg and MP3 Press A to switch Ogg and MP3 (Current: %s)
Current Time: %s Current Time: %s
Current Volume: %d/128 Current Volume: %d/128
Type: %s`, ebiten.CurrentTPS(), currentTimeStr, int(p.audioPlayer.Volume()*128), p.musicType) Type: %s`, ebiten.CurrentTPS(), p.musicType,
currentTimeStr, int(p.audioPlayer.Volume()*128), p.musicType)
ebitenutil.DebugPrint(screen, msg) ebitenutil.DebugPrint(screen, msg)
} }

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -1,14 +1,5 @@
# License # License
## classic.mp3
```
https://musopen.org/music/466/johann-sebastian-bach/air-on-the-g-string-from-orchestral-suite-no-3-bwv-1068/
Air on the G String (from Orchestral Suite no. 3, BWV 1068)
Public Domain
```
## jab.wav ## jab.wav
``` ```
@ -27,7 +18,7 @@ CC0
``` ```
## ragtime.ogg ## ragtime.ogg / ragtime.mp3
``` ```
https://soundcloud.com/jacaranda-trilhas-sonoras/james-scott-01-frog-legs-rag https://soundcloud.com/jacaranda-trilhas-sonoras/james-scott-01-frog-legs-rag

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//go:generate file2byteslice -package=audio -input=./audio/classic.mp3 -output=./audio/classic.go -var=Classic_mp3
//go:generate file2byteslice -package=audio -input=./audio/jab.wav -output=./audio/jab.go -var=Jab_wav //go:generate file2byteslice -package=audio -input=./audio/jab.wav -output=./audio/jab.go -var=Jab_wav
//go:generate file2byteslice -package=audio -input=./audio/jump.ogg -output=./audio/jump.go -var=Jump_ogg //go:generate file2byteslice -package=audio -input=./audio/jump.ogg -output=./audio/jump.go -var=Jump_ogg
//go:generate file2byteslice -package=audio -input=./audio/ragtime.ogg -output=./audio/ragtime.go -var=Ragtime_ogg //go:generate file2byteslice -package=audio -input=./audio/ragtime.mp3 -output=./audio/ragtime.mp3.go -var=Ragtime_mp3
//go:generate file2byteslice -package=audio -input=./audio/ragtime.ogg -output=./audio/ragtime.ogg.go -var=Ragtime_ogg
//go:generate file2byteslice -package=fonts -input=./fonts/mplus-1p-regular.ttf -output=./fonts/mplus1pregular.go -var=MPlus1pRegular_ttf //go:generate file2byteslice -package=fonts -input=./fonts/mplus-1p-regular.ttf -output=./fonts/mplus1pregular.go -var=MPlus1pRegular_ttf
//go:generate file2byteslice -package=fonts -input=./fonts/pressstart2p.ttf -output=./fonts/pressstart2p.go -var=PressStart2P_ttf //go:generate file2byteslice -package=fonts -input=./fonts/pressstart2p.ttf -output=./fonts/pressstart2p.go -var=PressStart2P_ttf
//go:generate file2byteslice -package=images -input=./images/ebiten.png -output=./images/ebiten.go -var=Ebiten_png //go:generate file2byteslice -package=images -input=./images/ebiten.png -output=./images/ebiten.go -var=Ebiten_png