I was wondering how I can measure the frequency of the audio output of my raspberry pi. Currently I am trying to create a script to control an RGB led to the music that is being played through the arduino

2 Answers 2


In order to measure the frequency you will need to take an fft of the data . http://en.m.wikipedia.org/wiki/Fast_Fourier_transform

First you need to sample the data coming out of the pi. (Or maybe you are playing an MP3 which is already sampled). Take about 1024 samples of data at time and run an fft. This will give you 1024 different "frequency bins". The bin that has the largest number is the loudest frequency.

Please post more information about what is generating sounds so i can help you further


This audio-freq-rpi git helped me out for my project of determining the freq of an audio file.

You can use the speaker_freq_db.py file to measure the frequency of the audio. You might have to increase the record time accordingly. They have used PyAudio to record the audio and FFT method for the frequency.

Although the recorded file is in .wav format. If your sole purpose it just to see the freq of it then that won't be a problem.

Your Answer

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

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