I have created a VB application (powerpoint Addin) in Visual Studio 2013 which controls lights etc in my house via interfacing to NCD relay controller. I had the idea to try and have a sort of disco option, where the program listens to the input coming in from the PC microphone and (based on user set parameters) uses volume based triggers to initiate changes in the relays, thus creating the switching of lights on or off to create the disco effect.
I managed to get the microphone data coming into the application (and I know it is correct since I can play it direct out to the default speaker and I get the microphone sounds coming out on the speaker - ok with a vary slight delay). Now what I want to do is convert the raw data into a snap-shot amplitude for a specific range of frequencies (show it on a sort of progress bar to start with and make it more fancy later on), but I am stuck trying to understand and convert the raw data - despite reading many articles on the www....
This part of the app is written in c#. The relevant code extracts are:
WaveLib.WaveFormat fmt = new WaveLib.WaveFormat(44100, 16, 2);
- so I am requesting sample rate of 44100 hz, 16 bit and stereo from the microphone.... (Maybe a bit optimistic?)
I receive the data in a buffer which is defined on global level within the class
private byte RecBuffer;
So I have an 8bit buffer, receiving 16bit stereo, so I have understood (maybe incorrectly)
- RecBuffer*256 + recBuffer gives me the left channel and
- RecBuffer*256 + recBuffer gives me the right channel
and this is repeated the length of the buffer, but my question is how do I make sense of this data and how can I understand the amplitude and frequency ? Can anyone point me in the right direction .... help would be much appreciated..... thanks....