Findy Phonie: An Android Phone Finder

We’ve been on an investigative spree lately, and one of the products of our research is a little experiment in signal processing on Android. This Android mobile app runs in the background and responds to the sound of a whistle, so that, should you lose your phone, you can simply whistle, and have the phone make a noise, to help you find it. Detecting a whistle is a fairly involved task, and developing an app to do so yielded some of the following insights.

We’ve been on an investigative spree lately, and one of the products of our research is a little experiment in signal processing on Android. This Android mobile app runs in the background and responds to the sound of a whistle, so that, should you lose your phone, you can simply whistle, and have the phone make a noise, to help you find it. Detecting a whistle is a fairly involved task, and developing an app to do so yielded some of the following insights.

Sampling

To start working with sounds, we used a discrete Fourier transform to convert the signal into the frequency domain. We used jTransforms for this.

Graphing

We needed to look into the data produced by this sampling mechanism, so we could create an algorithm to detect the whistles. For this, we used GraphView.

This was the output from ambient room noise. It fit with what we expected from ambient noise: a large DC component and gradually smaller high frequency component. The low part was useless, so we cut out everything below 500 Hz. To find the bucket index from a frequency:

frequency / ((float) mSampleRate / mFFTSize));

This was the output from a whistle: an obvious narrow spike, many times louder than the other frequencies. Below was the output from general noise:

Analysis

To detect a whistle programmatically, the plan was to find a spike confined to a certain frequency -- 500Hz -- a number of times louder than the amplitude at any other frequency. This approach mostly worked, but could be triggered by other sounds in the 500 Hz range. To make the test more specific, we needed to check if the tip of the spike was very narrow. This was done by fitting a triangle of two lines around the spike. If any buckets crossed this line, there was a good chance that the spike was just noise, rather than a whistle. Below is a test fitting the parameters. The main frequency test is the blue box, and the triangle test is in yellow:

To make the test even more specific, and preclude more false positives, the number of zero crossings had to be counted. Very noisy sounds can produce narrow spikes, but also produce many more zero crossings than a tone. We looked for 500 to 2800 crossings per second to confirm the whistle:

Conclusion

Thanks to the techniques above, detecting whistles whilst the phone is on the desk can be done with almost perfect accuracy. However, if the phone is hidden away, the microphone is covered up, or the phone is enclosed in a case, the detection rate drops sharply. This is to be expected: after all, trying to listen to a conversation whilst stuffed in a bag with your fingers in your ears is equally difficult. Likewise, the false positive trigger rate increases substantially if music is playing, or a microwave is microwaving. Our next attempt at noise detection might rely on neural networks, or some other technique to make the process ‘smarter’.