Link to home
Start Free TrialLog in
Avatar of KeithD2
KeithD2

asked on

How to make sense of the raw audio data coming in from Wavelib.fifostream

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[0]*256 + recBuffer[1]   gives me the left channel and
- RecBuffer[2]*256 + recBuffer[3]   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....
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KeithD2
KeithD2

ASKER

Thanks. The first one helped great......