mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
examples/audioinfiniteloop: Use const to represent bytePerSample (#1867)
Co-authored-by: wasedaigo <daigo@odencat.com>
This commit is contained in:
parent
2815829200
commit
851733397e
@ -31,9 +31,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
screenWidth = 640
|
screenWidth = 640
|
||||||
screenHeight = 480
|
screenHeight = 480
|
||||||
sampleRate = 22050
|
sampleRate = 22050
|
||||||
|
bytesPerSample = 4 // 2 channels * 2 bytes (16 bit)
|
||||||
|
|
||||||
introLengthInSecond = 5
|
introLengthInSecond = 5
|
||||||
loopLengthInSecond = 4
|
loopLengthInSecond = 4
|
||||||
@ -62,7 +63,7 @@ func (g *Game) Update() error {
|
|||||||
|
|
||||||
// Create an infinite loop stream from the decoded bytes.
|
// Create an infinite loop stream from the decoded bytes.
|
||||||
// s is still an io.ReadCloser and io.Seeker.
|
// s is still an io.ReadCloser and io.Seeker.
|
||||||
s := audio.NewInfiniteLoopWithIntro(oggS, introLengthInSecond*4*sampleRate, loopLengthInSecond*4*sampleRate)
|
s := audio.NewInfiniteLoopWithIntro(oggS, introLengthInSecond*bytesPerSample*sampleRate, loopLengthInSecond*bytesPerSample*sampleRate)
|
||||||
|
|
||||||
g.player, err = g.audioContext.NewPlayer(s)
|
g.player, err = g.audioContext.NewPlayer(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user