This project has moved. For the latest updates, please go here.

Convert WaveIn buffer to PCM integers

Mar 13, 2013 at 5:11 PM
Hello,
Writing NAudio.Wave.WaveInEventArgs buffer to new byte array, then (attempting to)convert those elements to PCM values via BitConverter.ToInt16. However, the signal is littered with peaks and noise. When I dumped into excel to view output from converted array(just recorded single tone) it had the semblence of correct sine wave/frequency buried amidst all sorts of errant samples. (I also tried reversing to account for endianess). When I choose WaveFileWriter and render as .wav, it sounds perfect. So something is getting lost in translation.

What object would convert the buffer to Linear PCM samples?

Thank You
Mar 14, 2013 at 2:00 AM
I think I may stumbled upon the answer by iterating by 2 through the byte array. That way the BitConverter.ToInt16 method combines two byte elements into a 16 bit integer.
Coordinator
Mar 14, 2013 at 2:24 PM
yes, each pair of bytes is a sample if you are recording 16 bit audio