examples/audioinfiniteloop: Use const to represent bytePerSample (#1867)

Co-authored-by: wasedaigo <daigo@odencat.com>
This commit is contained in:
wasedaigo 2021-11-08 15:52:53 +09:00 committed by GitHub
parent 2815829200
commit 851733397e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,6 +34,7 @@ const (
screenWidth = 640
screenHeight = 480
sampleRate = 22050
bytesPerSample = 4 // 2 channels * 2 bytes (16 bit)
introLengthInSecond = 5
loopLengthInSecond = 4
@ -62,7 +63,7 @@ func (g *Game) Update() error {
// Create an infinite loop stream from the decoded bytes.
// 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)
if err != nil {