From 851733397e553e68f7eefebda738470ea70bdc6b Mon Sep 17 00:00:00 2001 From: wasedaigo Date: Mon, 8 Nov 2021 15:52:53 +0900 Subject: [PATCH] examples/audioinfiniteloop: Use const to represent bytePerSample (#1867) Co-authored-by: wasedaigo --- examples/audioinfiniteloop/main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/audioinfiniteloop/main.go b/examples/audioinfiniteloop/main.go index 2a22fef41..6850375a5 100644 --- a/examples/audioinfiniteloop/main.go +++ b/examples/audioinfiniteloop/main.go @@ -31,9 +31,10 @@ import ( ) const ( - screenWidth = 640 - screenHeight = 480 - sampleRate = 22050 + 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 {