I've got a pcm-stream of raw music data from a wave-file and would like to convert it to a double-array (to apply a fft afterwards).
The result I got now contains very high or low double-numbers (1.0E-200 and 1.0E+300) and I'm not sure whether these can be correct.
This is the code I'm using right now:
WaveStream pcm = WaveFormatConversionStream.CreatePcmStream(mp3);
double real = new double[pcm.Length];
byte buffer = new byte;
int count = 0;
while ((read = pcm.Read(buffer, 0, buffer.Length)) > 0)
real[count] = BitConverter.ToDouble(buffer, 0);
Your PCM stream is almost certainly 16 bit. So instead of
ToInt16 instead. Then divide by 32768.0 to get into the the range +/- 1.0