This post continues the discussion of how to perform audio analysis on an iPhone in order to recognise bat calls. For the previous post, which covers some of the mathematical techniques please see Fourier Transforms on an iPhone.
The last blog posting ended with a very simplistic way to detect a bat call within an audio sample, and a promise to explain some more sophisticated methods. Whilst researching signal detection algorithms, we were made aware of an existing open source program that does a very similar thing to what we are attempting – Bat BioAcoustics, written by Chris Scott from Leeds University.
BioAcoustics is written in C++, and although it’s a desktop application, a lot of the algorithms in it are portable to any system which has a C++ compiler. Fortunately, an iPhone is one such system.
In order to analyse and classify bat calls in bat species, BioAcoustics performs the following steps:
- Load audio from a WAV file into memory.
- Detect each individual bat call within the file.
- Extract certain audio features for each call, e.g. maximum frequency, bandwidth and other features
- Use a Support Vector Machine model to classify each call
It has a dependency on the following open source libraries:
- QT – to provide a desktop GUI toolkit
- libsndfile – to read audio from a WAV file into memory
- FFTW – for Fourier analysis
- libsvm – to run the SVM models
As mentioned in previous blog posts, Apple provide APIs that can perform audio and signal analysis, and they also provide a GUI toolkit for iPhones. So if we can replace the first three of these libraries – QT, libsndfile and FFTW – with Apples native equivalents, we should be able to port the signal analysis and call matching sections of Bat BioAcoustics to an iPhone.
Finally, BioAcoustics is released under the GPL open source license – which is the same license we will be releasing code from BatMobile under – so there are no legal obstacles to doing this.