I wish to start my first pi project with the Raspberry pi zero. I wish to create a device that performs an action / run a line of code when a specific tone is played.

For example, when the pi detects the tone C3 it lights a bulb.

I have found a library called SoundAnalyse on Google code, but I'm not sure if that is recommended?

I don't know where to start and what to read to get started on this project. I'm aware of the basic of raspberry pi and python.

1 Answer 1


The first issue you will need to overcome is that of getting the audio signal into any RPi - the audio hardware on all of them is output only! The cheapest solution would be a USB audio dongle which can be around the size of a thumb drive and typically will have a pair of 3.5mm sockets - one for stereo audio output (to, say a a low-cost pair of headphones or amplified speakers) and one that is a mono microphone input (the connector may seem to be a 3-pole {stereo} one - tip-ring-sleeve but the either the left[tip] & right[sleeve] are connected together internally or the sleeve is open-circuit).

Once you have got a sound signal into your RPi then you will need software that can continuously monitor the audio and then can perform a Fast Fourier Transform to convert a series of samples (instantaneous sound wave amplitude or voltage representing it vs. time) of the waveform (at at least twice the frequency of that which you are trying to detect and with very strong filtering to prevent frequencies above that limit {the Nyquist frequency} from passing to the sampling system) to frequency bands present in the samples for the time over which the series were taken. You can, by controlling the number of samples, and the rate at which they are taken, control how finely you can determine the bands of frequencies you want to detect and how quickly - and there are engineering trade-offs to make.

I am not aware of any packages to do this right now - but I have not looked hard - there may be something out there to do this; it is just that my University Degree a large number of years ago had an uncompleted project that strong links to this area (but then I was using a system with a Digital Signal Processing IC that was built for this sort of thing)...

Incidentally if you are only looking to use specific frequencies in order to activate some sort of control you may want to investigate using a Dual Tone Multi Frequency system which uses pairs of carefully calculated frequencies (so they can be distinguished from one another) to signal one of, typically sixteen combinations as most telephone systems do nowadays to transmit the numbers dialled down a telephone line. The advantage of using such a limited number of frequencies is that there are integrated circuits out that can generate and decode such signals with a degree of reliability and simplicity that hand-crafted code may take some effort to match.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.