Android Question Detect blowing in the microphone

Ohanian

Active Member
Licensed User
Longtime User
Hi,

Is there any way to detect blowing in the device’s mic?

I want to do a procedure as long as the user blows in the mic, and stop the procedure when then user stops.
 

Ohanian

Active Member
Licensed User
Longtime User
Hi,

is there any sample or code snippet?
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
I think you'll find that this is a phun physics problem. Once you get the raw PCM data, you'll want to run it through a Fourier Transform. I think AGraham has a Fourier library. I suspect that you'll find that blowing on the microphone will generate a very broad, nearly flat energy spectrum. You can characterize the flatness of the spectrum by calculating the standard deviation. I'm not sure if there are statistical libraries available but that's a very easy calculation to do on your own. Then, you can set a range of acceptable standard deviation values that your app will consider indicative of blowing on the mic.

The advantage of this method is that it is volume-independent. You could blow softly or loudly and this method should be able to detect it.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…