I’m working on a game which uses blow functionality to move an object in the game screen. This screen also has background music in it.

The problem is that the microphone is detecting the BGM as blow input and the object is being moved without any actual user input.

How can I avoid this kind of false positive?


1 Answer 1


Consider a volume threshold.

The nature of "blow" input usually, on the small microphones used by devices with games that employ this mechanic (like phones or the Nintendo DS), seems to saturate the input range of the microphone. This results in a noisy, static-like sound with very consistently high amplitudes.

Knowing that, you may be able to get away with having the game sample a few points of the microphone input and compute an average amplitude for the sound. Then, check if that value is higher than some threshold value you set in your game code (possibly chosen by preprocessing your background music and choosing something well above its maximum volume).

Similar to how joysticks have "dead zones," this will help you avoid false positives in your audio input.

You could also try other, more complex techniques (such as subtracting out the BGM sound wave from the input a kind of noise-cancelling approach), but they may be too extensive for realtime operation on a mobile device. A volume threshold approach, as described above, is relatively cheap to perform.

You may find this link on microphone input in Unity relevant.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .