mirror of
https://github.com/faiface/beep.git
synced 2025-12-23 23:38:45 -05:00
Merge pull request #79 from tslocum/wavfixes
wav: Resolve conversion issues
This commit is contained in:
@@ -230,25 +230,25 @@ func (d *decoder) Stream(samples [][2]float64) (n int, ok bool) {
|
||||
}
|
||||
case d.h.BitsPerSample == 16 && d.h.NumChans == 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)
|
||||
val := float64(int16(p[i+0])+int16(p[i+1])*(1<<8)) / (1<<16 - 1)
|
||||
samples[j][0] = val
|
||||
samples[j][1] = val
|
||||
}
|
||||
case d.h.BitsPerSample == 16 && d.h.NumChans >= 2:
|
||||
for i, j := 0, 0; i <= n-bytesPerFrame; i, j = i+bytesPerFrame, j+1 {
|
||||
samples[j][0] = float64(int16(p[i+0])+int16(p[i+1])*(1<<8)) / (1<<15 - 1)
|
||||
samples[j][1] = float64(int16(p[i+2])+int16(p[i+3])*(1<<8)) / (1<<15 - 1)
|
||||
samples[j][0] = float64(int16(p[i+0])+int16(p[i+1])*(1<<8)) / (1<<16 - 1)
|
||||
samples[j][1] = float64(int16(p[i+2])+int16(p[i+3])*(1<<8)) / (1<<16 - 1)
|
||||
}
|
||||
case d.h.BitsPerSample == 24 && d.h.NumChans >= 1:
|
||||
case d.h.BitsPerSample == 24 && d.h.NumChans == 1:
|
||||
for i, j := 0, 0; i <= n-bytesPerFrame; i, j = i+bytesPerFrame, j+1 {
|
||||
val := float64((int32(p[i+0])<<8)+(int32(p[i+1])<<16)+(int32(p[i+2])<<24)) / (1 << 8) / (1<<23 - 1)
|
||||
val := float64((int32(p[i+0])<<8)+(int32(p[i+1])<<16)+(int32(p[i+2])<<24)) / (1 << 8) / (1<<24 - 1)
|
||||
samples[j][0] = val
|
||||
samples[j][1] = val
|
||||
}
|
||||
case d.h.BitsPerSample == 24 && d.h.NumChans >= 2:
|
||||
for i, j := 0, 0; i <= n-bytesPerFrame; i, j = i+bytesPerFrame, j+1 {
|
||||
samples[j][0] = float64((int32(p[i+0])<<8)+(int32(p[i+1])<<16)+(int32(p[i+2])<<24)) / (1 << 8) / (1<<23 - 1)
|
||||
samples[j][1] = float64((int32(p[i+3])<<8)+(int32(p[i+4])<<16)+(int32(p[i+5])<<24)) / (1 << 8) / (1<<23 - 1)
|
||||
samples[j][0] = float64((int32(p[i+0])<<8)+(int32(p[i+1])<<16)+(int32(p[i+2])<<24)) / (1 << 8) / (1<<24 - 1)
|
||||
samples[j][1] = float64((int32(p[i+3])<<8)+(int32(p[i+4])<<16)+(int32(p[i+5])<<24)) / (1 << 8) / (1<<24 - 1)
|
||||
}
|
||||
}
|
||||
d.pos += int32(n)
|
||||
|
||||
Reference in New Issue
Block a user