audio: wav: fix Stream for non 2 chans 2 bytes configurations
@@ -123,18 +123,18 @@ func (s *decoder) Stream(samples [][2]float64) (n int, ok bool) {
}
switch {
case s.h.BitsPerSample == 8 && s.h.NumChans == 1:
- for i, j := 0, 0; i < n-bytesPerFrame; i, j = i+bytesPerFrame, j+1 {
+ for i, j := 0, 0; i <= n-bytesPerFrame; i, j = i+bytesPerFrame, j+1 {
val := float64(p[i])/(1<<8-1)*2 - 1
samples[j][0] = val
samples[j][1] = val
}
case s.h.BitsPerSample == 8 && s.h.NumChans >= 2:
- for i, j := 0, 0; i < n-bytesPerFrame; i, j = i+bytesPerFrame, j+1 {
+ for i, j := 0, 0; i <= n-bytesPerFrame; i, j = i+bytesPerFrame, j+1 {
samples[j][0] = float64(p[i+0])/(1<<8-1)*2 - 1
samples[j][1] = float64(p[i+1])/(1<<8-1)*2 - 1
}
case s.h.BitsPerSample == 16 && s.h.NumChans == 1:
- for i, j := 0, 0; i < n-bytesPerFrame; i, j = i+bytesPerFrame, j+1 {
+ for i, j := 0, 0; i <= n-bytesPerFrame; i, j = i+bytesPerFrame, j+1 {
val := float64(int16(p[i+0])+int16(p[i+1])*(1<<8)) / (1<<15 - 1)
samples[j][0] = val
samples[j][1] = val
