Hi, I'm totally new to fastled and I wonder if anybody know a good

Hi, I’m totally new to fastled and I wonder if anybody know a good library for fft audio analysing via microphone that work on the ESP8266 12-E chip. Thanks!

Depending on your platform, FastLED is likely to be consuming pretty much all the ‘real time’ your processor has. FastLED uses timer interrupts like they are going out of fashion!

Performing FFTs on audio is also very cpu intensive and interrupt heavy and therefore it is very unlikely that the two will coexist at all.

If you really want to do this, this will need 2 systems. First one controlling your LEDs, the second performing FFTs. Then interlink these via some method that allows you to send the simplest of information through.

A serial data stream from the FFT to LED would use only 1 pin at each end (plus a shared ground reference) as you don’t need the LED to send anything back I would have thought. At the other extreme you may need something like dual port RAM so the two systems can function totally asynchronously. The serial stream is probably the simplest, but remember that serial also uses interrupts and this can ‘miss’ data. So you also need to consider how to keep the two synchronised and trap missing bytes. There are lots of inter-system communication options that could be implemented, depending on your skills and the system needs.

Not all massively difficult and it also keeps the software very separate and therefore much easier to debug. You can then also choose boards that are suitable for the tasks in hand. And if you want to upgrade something, the other stays as-is.

Modular systems are always easier to build and fault find.

I’ve been able to use the OpenMusicLabs FHT library, however I use APA102’s instead of WS2812’s because of the above Interrupt issues. See demo:

@Adam_Sharp Thanks for the elaborate answer! I had no idea that those two where that cpu intesive. Although now when you mention it, it does make sense. How about using the fastLED library together with the MSGEQ7? Would that be a better way of doing this? https://www.sparkfun.com/products/10468

Maybe this example can help? Using the Teensy Audio Library, it computes 1024 point FFT and renders the result as 60 bands on a 60x32 LED grid, updating at a rate of 86 Hz. https://github.com/PaulStoffregen/OctoWS2811/blob/master/examples/SpectrumAnalyzer/SpectrumAnalyzer.ino

@Andrew_Tuline Thank you for you answer! I did actually download your fastled-demo, and I gotta say, great work! Right now I’m waiting for my MEMS mic because yes, I did order one of those cheap sensor at first. And as you stated in your repo… It didn’t work…
Anyway, do you think it would be possible, performance wise, to run your sound reactive programs along with a webserver on a single esp8266? I mean, the esp does feature a 32-bit processor? https://www.espressif.com/sites/default/files/documentation/0a-esp8266ex_datasheet_en.pdf

If you use a Teensy, and the correct LEDs, you have much more CPU time available. And there are even more powerful boards out there.

Sorry can’t recommend any ‘Arduino’ style FFT software, I use hardware dedicated DSPs to perform my FFTs, when I need them. Gives me huge numbers of bins, thousands of times a second with dozens of input channels. But I have heard good reports for MSGEQ7.

Modular man you see. I have hardware modules that I put together as needed with minor software tweaks. Tend to use lots of SBCs to overcome runtime failures and provide realtime redundancy replacement and fall over - self healing to a degree. So I tend to use cheap stuff that I don’t care if it goes bang, or really how many I put into a system. As they say “failure is not an option” with some systems. Makes the customer very happy to get high MTBFs in hot and vibration prone environments.

How does a DSP chip give you a huge number of FFT bins thousands of times per second? For audio, that is.

I mean, no matter how much CPU power you have, there’s the fundamental math of Fourier transform. A 4096 point FFT necessarily means 4096 samples. If your sample rate is 44.1 kHz, then those FFT bins represent the spectral content during those 93 ms. Or at least during the center portion of that 93 ms, assuming you’re using a Hanning or similar window. So even if you do 50% overlapped FFTs, that’s a new set of bins every ~46 ms. And if you grow to larger and larger FFT size, the time window grows (slower refresh rate), longer results containing the spectra of multiple musical events.

Sure you can crank up the sample rate, to do many more per second. But if you do a 16384 length FFT on 192 kHz data, giving you 8193 frequency bins, only the first 1706 of those 8193 bins correspond to the 20 kHz range even the best humans can hear. FFT fundamentally has a time vs resolution trade-off. No amount of CPU power can change the fundamental nature of math.

Not just audio and not just from a single audio channel.

I have been experimenting with audio from the where the light display is located. So with 40 light effect units, there are 40 audio inputs. Over the frequency range that the speakers can put out.

But also with limited sampling of UV, IR and visible light cameras on the dancing crowd. Along with the dance surfaces (ULF) and stuff from the buildings steel structure (ULF to HF). All produce some very interesting FFTs to work with.

Why assume I’m dealing with audio? The world is full of interesting vibrations that we are unaware of, but are often in sync with us. If I could sense them, I would also work with the FFTs of the heart beats, breathing and brain waves of the dancers, probably tomorrow…

Assuming audio because Albin’s question specifically asked “anybody know a good library for fft audio analysing”.

@Albin_Winkelmann If you decide to try the MSGEQ7 route search the group here for posts by Stefan Patrick and you’ll see you can get some good results even though the MSGEQ7 is limited to 7 bands which have fixed ranges.

Wow, people are very helpful in this forum! Thank you all for the input! :smiley:
Quite right, my plan is to make a warable ledstrip that reacts to music or display different animations, it’ll also host a webpage where you can change the animations, brightness etc. Depeding on the performance, I might have the webserver shut down when the ledstrip is in “sound reactive” mode.
The ledstrip I have right now is the WS2812B with 30 leds. I’ll be using the ADMP401 MEMS microphone and run it all from an esp8266 as I mentioned in the post. Since I have a ledstrip I only want to have it react differently to bass, mid and high frequency (like vocals). I’m not really interesting in displaying the whole aduio spectrum. Just merely having it react differently on different tones. Having a ledstrip that only react to loudness is not so impressive.

@Adam_Sharp mentioned that fastLED uses interrupts like crazy, so what about the NeoPixel library? https://github.com/adafruit/Adafruit_NeoPixel
@marmil Thank’s for that input! I’ll check that out

You could try an ESP-32 – it has two cores, so you can dedicate one to computation/analysis and the other to FastLED.