PDA

View Full Version : Audio Reactive Teensy - any open source code or guidance?



Tomek
11-09-2015, 04:27 PM
Hi,

Obviously there is some amazing software out there for the common individually addressable RGB leds, and also for FFT analysis of music input.


I've found a lot of projects that incorporate these two things to make teensy audio-reactive lights. Which, previously, everyone had to use a laptop or at least RaspPi, so not very portable.

But what I don't know alot about is how to make use of the audio data from a reactive input, to make some reactive lights.

I plan to integrate this into a halloween costume that I made this year with slow-fade non-controllable RGB lights (which unfortunately a friend broke the costume very severely...so I'd like to upgrade it while I'm at it.)

So not being super great with the software side of things I was hoping there's an audio reactive open source program I haven't found yet, that someone could guide me towards and I could probably manage tweaking to my liking. It seems this has been done many times before (see: youtube videos) but none are available for sharing.

baring the availability of piggy-back code, I might get one of those seven channel filtering chips and I could manage the software to make decisions based on the 7 channel spread, but this would be much inferior to an onboard solution. Simply that, an onboard solution without piggy-back code is beyond my skills at the moment

Tomek
11-09-2015, 04:30 PM
This seems like the most likely project I could learn something from:
https://learn.adafruit.com/fft-fun-with-fourier-transforms/spectrum-analyzer

I am just starting to understand it, but if anyone can tell me if this is the wrong track or the right track, that would save me some confusion. There may also be something better out there (I dont know.)

I'm a few hours into trying to understand what is necessary for this project. It seems very likely that the page I just linked to is the one with a relevant program that covers exactly what I wanted. I was and am slightly unsure if it's exactly what I needed (still learning about the whole system) and I hope it's OK that I posted this thread when it might be right there.

It seems I don't know enough yet to know what i'll need, but I found these things some time shortly after I was giving up and making a thread. I had checked quite a bit before I made the thread, though.

Frank B
11-09-2015, 04:55 PM
You might want to look at Examples->Audio->Analysis, too.

swarfrat
11-09-2015, 06:09 PM
You're just wanting a noise activated trigger? You can just sample, rectify, filter and level trigger off that. Doesn't require anything as complex as FFT unless you want to trigger off specific frequencies.

Frank B
11-09-2015, 06:40 PM
You're just wanting a noise activated trigger? You can just sample, rectify, filter and level trigger off that. Doesn't require anything as complex as FFT unless you want to trigger off specific frequencies.

@swarfat: with this argumentation you only need some transistors and no cpu at all ( for a "noise activated trigger" ) ;-)

swarfrat
11-15-2015, 06:45 PM
You could, but that's actually more complex if the circuit already has a teensy involved.

Tomek
12-15-2015, 04:38 PM
You could, but that's actually more complex if the circuit already has a teensy involved.

So I will update mid january, since I will be doing most of my work on this over december, but I just wanted to clarify the audio-reactive bit.

I think you interpreted audio-reactive to literally be "reacting to audio" or something like that, a noise-activated trigger as you say. But I meant it as just the term I've heard used before for audio-syncing complicated reactions. For example, like the classic winamp visualizer from the 90s (well not a perfect example, since the winamp visualizer could look at the audio before it ran, and my project needs to listen with a microphone and react quickly.)

Thanks everyone! My question seems to have been answered (at least so far as I've been able to investigate to date) by "the examples in the libraries are really powerful, even if there isn't a ton of project documentation using them on the web."


A much bigger version of what I'm interested in was asked a couple years ago:
https://forum.pjrc.com/threads/24251-Looking-to-build-a-LED-DJ-Booth

And paul noted that it didn't seem likely possible. But I think a lot has changed with the audio project and my scale is much smaller.

Tomek
12-23-2015, 06:56 AM
Update 1(my project):

So I finally wired up everything, so I have my teensy3.1+audio board connected to an autogain adjusting microphone from adafruit (to line-in, since its an auto-adjusting mic and I think that's the appropriate input). I have 4 strips of 13-15/ea WS2812B lights. I can individually get I think real data from the microphone (haven't done extensive testing), and flash all the leds.

But I don't really have an idea how to use the FFT analysis of the sound to react the lights. I'm thinking I might end up needing to decide how to utilize the leds, and writing code for that. It doesn't seem like there's any prebuilt audio-reactive routines, that I could piggyback off of. I could be wrong about this fact! Any leads in that direction would be appreciated. But I'll still do my research into good techniques and ideas around an audio-based led response.

PaulStoffregen
12-24-2015, 11:53 AM
Yeah, currently the library only gives you the FFT output. Then it's up to you to figure out what to actually do with the numbers.

OctoWS2811 has an example which turns the data into a huge spectrum analyzer display.

https://github.com/PaulStoffregen/OctoWS2811/blob/master/examples/SpectrumAnalyzer/SpectrumAnalyzer.ino

At the recently Hackaday conferences, Nathaniel made a great spectrum analyzer badge using the 2.8 inch TFT display.

https://hackaday.io/project/8575-audio-spectrum-analyzer-a-supercon-badge

So far, I'm not aware of many projects doing more analysis of the FFT data to actually detect musically interesting patterns.

Tomek
12-25-2015, 03:46 PM
Yeah, currently the library only gives you the FFT output. Then it's up to you to figure out what to actually do with the numbers.

OctoWS2811 has an example which turns the data into a huge spectrum analyzer display.

https://github.com/PaulStoffregen/OctoWS2811/blob/master/examples/SpectrumAnalyzer/SpectrumAnalyzer.ino

At the recently Hackaday conferences, Nathaniel made a great spectrum analyzer badge using the 2.8 inch TFT display.

https://hackaday.io/project/8575-audio-spectrum-analyzer-a-supercon-badge

So far, I'm not aware of many projects doing more analysis of the FFT data to actually detect musically interesting patterns.

Thanks Paul :)! Good to hear from you, since you've probably seen most of what has been done and shared as such.

I'm going to give it a shot, though it might take a few months, it seems, to figure out how to get from my proto-code ideas to actual code (as a hobby project.) For now I'm trying to get a full background on the fastLED library, and useful principles of the FFT stuff, so we'll see how that goes.

Mozz164
07-03-2016, 11:22 PM
Just wondering if you managed to get any further with this project since your last post in December. I have been experimenting with different methods of filtering and I have not yet come up with a solution I am happy to settle on.

As its my first post on this forum id like to say thanks to Paul for making audio tinkering so much more approachable with all the hard work you have put into these audio tools. My hat is off to you sir.!!

I know this is a huge task at hand but couldn't we simpify it a little and calculate the tempo by correlating FFT data with a LP-filtered peak detector with the results providing energy peaks in certain frequency bands? (I.e spectral density.?)... If the algorithm detects a 'beat' in the low range of frequencies then shoot some lines of LEDs down the chain at this estimated tempo. The program would have a pre-compiled library of colour palettes (using FastLED)..that change in intensity and noise when subject to higher pitches and voice. G that makes it sound so easy...

Teensy3.2 | Audio Shield | Design Tool |
FastLED | octoWS2812 | APA102 / ws2812