I have an array of bytes from an audio file and I want to convert it into data that I can process to filter the audio signal. I have an array like this: [239,246,96,247.....]; Each element is a uint8 byte
Each 2 bytes(16 bits) represent a sample,so I converted this array into a int16 element array.
How can I then convert this array into a signal with values in the range[-1,1]?
You already have your signed int16's so you just have to divide by the min and max int16 value respective to the sign.
x is an element of my array. x should be
uint16
and notint16
.Next foreach x, you have to do
(x - maxUInt16/2) / maxUInt16/2
So =>
y = (x - (2^15 - 1)) / (2^15 - 1)
maxUint16 is impair so you have to handle possible overflow
Code :