c# - Create Clapper software with Naudio -


i'd create software listens after claps thru microphone..

my first implementation try software warn when hears high volume sound.

but wondering if me in right direction?

public partial class clapperform : form {     wavein waveinstream;      public clapperform()     {         initializecomponent();     }      private void btnstart_click(object sender, eventargs e)     {         //start streaming         waveinstream = new wavein();         waveinstream.dataavailable += new eventhandler<waveineventargs>(waveinstream_dataavailable);         waveinstream.startrecording();     }      void waveinstream_dataavailable(object sender, waveineventargs e)     {         //check out volume     }     private void btnstop_click(object sender, eventargs e)     {         if (waveinstream != null)         {             //stop streaming             waveinstream.stoprecording();             waveinstream.dispose();              waveinstream = null;         }     } } 

assuming recording 16 bit audio (which default), contents of e.buffer can interpreted this:

for (int n = 0; n < e.bytesrecorded; n += 2) {     short samplevalue = bitconverter.toint16(e.buffer, n);         } 

then can high values of math.abs(samplevalue).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -