[alsa-devel] Mic threshold trigger

OrazioPirataDelloSpazio (Lorenzo) ziducaixao at autistici.org
Wed Nov 5 01:09:47 CET 2008


Hello,
I would like to create a simple trigger from a microphone input, using alsa.
For example I would like that every time I short-circuit a jack inserted 
in the "mic hole", my program say "Hello World".
I would like that this application will be lightweight (I don't need 
audio quality, just a trigger!) and that cohexists with other apps that 
should keep using the output of the same sound card.

My idea was to simply code a raw "snd_pcm_readi" call and after compare 
each sample of the captured block with a threshold. For instance, if the 
90% of sample are above the given threshold, the trigger must act.

Of course it doesn't work :-)

I plug a simple jack in the mic, and open or short-circuit the poles. In 
the captured block, I can find only samples between 0xFFE0 and 0xFFFF 
(and some sporadic 0x0000).

Any hits? Thanks

Lorenzo



More information about the Alsa-devel mailing list