From f381caa74b69e75f0d5b4d78f1756f9d3a5b91da Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Mon, 27 Dec 2021 12:37:43 -0600 Subject: [PATCH] Detect NumChannels during ogg/vorbis decode --- vorbis/decode.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/vorbis/decode.go b/vorbis/decode.go index 3419211..0486243 100644 --- a/vorbis/decode.go +++ b/vorbis/decode.go @@ -9,10 +9,7 @@ import ( "github.com/pkg/errors" ) -const ( - govorbisNumChannels = 2 - govorbisPrecision = 2 -) +const govorbisPrecision = 2 // Decode takes a ReadCloser containing audio data in ogg/vorbis format and returns a StreamSeekCloser, // which streams that audio. The Seek method will panic if rc is not io.Seeker. @@ -31,7 +28,7 @@ func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err } format = beep.Format{ SampleRate: beep.SampleRate(d.SampleRate()), - NumChannels: govorbisNumChannels, + NumChannels: d.Channels(), Precision: govorbisPrecision, } return &decoder{rc, d, format, nil}, format, nil