Posts: 14
Joined: Sat Aug 11, 2012 8:52 pm

Beat detection for 3.5mm jack

Sat Dec 14, 2013 10:33 pm

Hi all,

I've currently got a Pi setup with Shairport and hooked up to my speakers. I would like to be able to hook some LEDs up to the GPIO pins so that they flash with the beat of the music that's being played through the 3.5mm jack.

I've been looking for some beat detection software that can do this, but I haven't been able to find anything as of yet. I realise that I will probably have to make a basic script to control the actual LEDs. Do you guys have any pointers?

Thanks :D

User avatar
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Beat detection for 3.5mm jack

Sun Dec 15, 2013 12:00 am

Turning a bunch of LEDs is dead simple, however getting your Pi to detect the audio signal levels in real-time is difficult.
You're going to need some way of capturing audio data I believe PulseAudio may have some way of simultaneous capture and playback but don't ask me how it's done.
Personally I would settle for a hardware implementation like the KA2284 or LM3914 LED bar display driver IC although that would take the fun out of programming the Pi.

Richard S.

User avatar
Posts: 326
Joined: Tue Jan 01, 2013 10:27 pm
Contact: Website

Re: Beat detection for 3.5mm jack

Thu Dec 19, 2013 8:03 pm

You might want to check out aubio: http://aubio.org/
RPi and real-time, low-latency audio: http://wiki.linuxaudio.org/wiki/raspberrypi
RPi audio repository: http://rpi.autostatic.com/
RPi and audio blog: https://autostatic.com/tag/raspberrypi/

Posts: 5
Joined: Sat Oct 17, 2015 10:29 pm

Re: Beat detection for 3.5mm jack

Sun Dec 06, 2015 1:20 am

Hey, I know this is like 2 years old, but I'm doing the same thing you're doing, essentially. I managed to route the shairport-sync to Python using

Code: Select all

shairport-sync -v -o stdout | ./python_script.py
but I'm lacking reliable beat detection too. There are a few on the internet, and I tried them all, but none really worked well. I'm trying to write one my own, would update if I'm able to.

User avatar
Posts: 877
Joined: Sat Aug 27, 2011 1:16 pm

Re: Beat detection for 3.5mm jack

Sun Dec 06, 2015 2:06 pm

I've had good results using MSGEQ7's with Arduinos. I don't see why they wouldn't be equally simple to use on Pi's.

Posts: 5
Joined: Sat Oct 17, 2015 10:29 pm

Re: Beat detection for 3.5mm jack

Mon Dec 07, 2015 5:05 am

I just finished this a while ago - works just okay on my RPi2 after removing a bunch of concurrency, so it may be too much for earlier models. Eventually I may improve my lighting algorithm, but I need to gain some more experience in analog data processing first :D

It's on my GitHub: https://github.com/ngoctnq/underlight - it's bundled with a bunch of unnecessary stuff that I use, so remember to remove the redundancy for better performance.

User avatar
Posts: 1046
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: Beat detection for 3.5mm jack

Mon Dec 07, 2015 5:18 am

Taking the sync out of the audio and controlling the LED's is what QLC+ is all about. It already has built-in fft so you can even control spectrum bars. Have a look at http://www.qlcplus.org or http://discohat.com


Posts: 1
Joined: Fri Jul 07, 2017 7:07 pm

Re: Beat detection for 3.5mm jack

Fri Jul 07, 2017 7:49 pm

Hello everyone,

I'm using qlcplus together with "aubio" (audio labelling library) running in real-time on Jack server.
The sound of the OS is fed to Jack audio server using the pulseaudio Jack bridge. From there it is routed/splitted to the aubio real-time instance and out to the speakers.
aubiotrack (one of the examples of aubio) performs the beat detection and feeds the output midi "tick" to qlcplus.
(I had problems with the output midi tick which was not implemented in an older version of aubiotrack, but after fixing this it works like a charm. aubio is open source)
My setup does not run on a raspberry pi but it should be possible there too.
I am using Ubuntu.

Posts: 10
Joined: Sat Aug 18, 2018 2:38 pm

Re: Beat detection for 3.5mm jack

Sat Aug 18, 2018 3:15 pm


GBD is a framework for generic and realtime music beat detection. It is
designed for IoT setups based on the RPi.

The GBD framework includes support plugins for audio signal routing
between hosts, e.g. a smart phone streaming audio via Bluetooth to a
RPi hosting GBD. As the audio stream is routed through the framework,
the GBD DSP analysis library delivers beat counts to Linux POSIX shared
memory. The IoT maker can then use this information to synchronize
light events to the beats in the music stream.


Demo video (OpenGL emulation of LED control): https://youtu.be/1wmrO51TZqA
Project: https://github.com/generic-beat-detector/GBD

Return to “Graphics, sound and multimedia”