Anyone successfully fading Neopixels while audio plays?

Status
Not open for further replies.

AKA

Member
Hello! I'm really enjoying the Audio shield and the awesome gui. Thanks!

I'm having some trouble trying to do the following: I'd like to play a bell sound and, as the bell sound decays, I'd like to fade some neopixels (I'm not using DotStar because I need the nice warm white of the neopixel RGBW strips).

As I have it now, the bell sound plays (there's an odd "click" in the middle of playback, but I suspect that's a WAV header issue and not related to the main issue), but immediately slows and distorts when I begin fading the Neopixels.

My understanding is that the Neopixels' use of interrupts to time the pixel-driving waveform is what's causing the audio playback issues. I've looked around the forums (my apologies if I've missed anything!) but cannot find a solution. The solution I'm looking for would be, for example, "use this range of pins for the neopixels to ensure their interrupts aren't the same as the audio library's interrupts" or other advice...

Here is my full sketch: https://gist.github.com/AKAMEDIASYSTEM/ebd470c2e6054bd51f467e72606a702a

Any help/insight you might be able to offer would be much appreciated!

Thanks,

AKA
 
I have used the neopixels a lot in combination with audio. Have used pin 3 and 8 as output for the LEDs. And it works.
But you should really watch out for noise on the power lines! The best is to have a separate power regulator for the LEDs. The neopixels are nasty and you will get a lot of unwanted noise.
But after your description it seems like it is something else.
You can take a look at my code that implements a "vu-meter" with 7 neopixels to see if you find something:
https://github.com/OnkartGromt/OpenEffectsProject/blob/master/TurboTore

btw, have you tried to increase the AudioMemory(8);?
 
im not a fan of fading pixels in those for loops, millis() is your friend and let each led update go thru a cycle one at a time
 
60 LEDs takes 1.8 ms to update. Adafruit_NeoPixel blocks all interrupts during that time. That's quite a lot of the 2.9 ms update time for the audio library. If your audio processing is using more than 1.1 ms of the 2.9 ms update time, odds are strong the 1.8 ms interrupt blocking will glitch your sound.

You have basically 2 options.

1: Connecting the LEDs in shorter strips to multiple pins and update each section separately.

2: Use OctoWS2811, which is massively overkill for only 60 LEDs, but it doesn't block interrupts. The SpectrumAnalyzer example rapidly refreshes nearly 2000 LEDs 88 times per second while the audio lib does 1024 point FFTs on the incoming audio.... for just a taste of the incredible capability Teensy 3.2 can have when interrupts aren't blocked!
 
I wonder if using FastLed to write the neopixels would work. I've never used FastLed, so I don't know if it blocks interrupts (like Adafruit's code does) or uses the DMA techniques that Paul's Octows2811 does.

Another option is to separate the LEDs and sound to two different processors, and have some way of signaling between the two:

In terms of the stand alone players, a lot of the cheaper ones require a TF/micro-SD card that is no more than 1GB (i.e. not a micro SD-HC or SD-XC card). If you can't find one, you would need to step up to the next generation that supports up to 32GB (SD-HC) cards. Dfplayer is one such:

Or there is the Adafruit Audio FX Mini that can be used:
 
Last edited:
Thank you to everyone who responded! I am very grateful for your time and thoughtful answers.

Apologies, also, for not updating right away: late last night, as the snow began to fall, I went with the absolute most expedient time-vs-money solution and just popped another Teensy (LC) in there to run the pixels.

I really appreciate everyone's quick help on this!

AKA
 
Status
Not open for further replies.
Back
Top