wav icon indicating copy to clipboard operation
wav copied to clipboard

Signed 16bit stream incorrectly converted

Open xeoncross opened this issue 9 years ago • 4 comments

Reading a 2-channel, signed 16bit PCM stream doesn't work (common) because the bytes are converted to int32 instead of int16

n = int32(s[0]) + int32(s[1])<<8

n = int16(buf[0]) + int16(buf[1])<<8

You can see a copy of the byte stream graphed here: http://imgur.com/a/TVuH6

xeoncross avatar Jan 09 '17 17:01 xeoncross

We might want to change the logic for 1 or 2 byte sequences to calculate as a signed 16bit number and then type cast to 32 bit.

xeoncross avatar Jan 09 '17 18:01 xeoncross

Consider this conversion to float32 using int64 for the full range of values from more than WAV audio sources.

xeoncross avatar Apr 20 '17 21:04 xeoncross

Looks like @nathan-cormier also ran into this? (re cryptix/wav#14)

cryptix avatar May 03 '17 18:05 cryptix

@Xeoncross the link you posted was based on a branch and now points to some unrelated code.. :'( can you update it?

cryptix avatar May 03 '17 18:05 cryptix