audioxnabuffermicrophonepitch-tracking

XNA Microphone audio buffer format?


I'm working on an XNA script in which I want to read data from the microphone every couple of frames and estimate its pitch. I took input based almost exactly on this page (http://msdn.microsoft.com/en-us/library/ff827802.aspx).

Now I've got a buffer full bytes. What does it represent? I reset everything and look at my buffer every 10th frame, so it appears to be a giant array that has 9 instances of 1764 bytes at different points in time (The whole thing is 15876 bytes large). I'm assuming it's the time domain of sound pressure, because I can't find any information on the format of microphone input. Anybody know how this works? I have a friend who has an FFT up and running, but we're trying to learn as much as we can about that data I'm collecting before we attempt to plug it in.


Solution

  • The samples are in Little-Endian 16 bit Linear PCM. Convert each pair of bytes into a signed short as

    short sample = (short)(buffer[i] | buffer[i+1] << 8);