I'm trying to work on a reactive lighting project and I'm confused about a couple topics when it comes to sampling audio.
I want to be able to have RGB reactive lighting controlled by a microcontroller sampling audio from a standard audio jack (such as from a phone). I'm planning to just use a mono sound audio jack to simplify everything.
My main concern is how to actually sample the audio. My understanding is that from a phone audio jack the signal is already in analog form, and needs to be sampled again at the microcontroller, and I figure I would need a sampling rate of around 20kHz to capture most of the frequencies in the audio.
In the past I've used Arduinos for projects that sample at ~8kHz with the standard audioread() function. I was able to use a library I previously had and interrupts in C to achieve a sampling rate of around ~10kHz which isn't much better. Would I just need to purchase faster hardware or is there a way to increase the sampling rate on cheaper microcontrollers?
I'm also worried that even if I can sample the signal fast enough, that the processing for my reactive lighting may take too long and slow the sampling down. I plan on using FFT and calculate a dominant frequency from the last X samples (to be determined based on sampling rate) and quantize it into different colors. What sort of timing limitations are there here? If I know the sampling rate I can calculate the time between samples, but is there a way to calculate the time it takes to execute a loop of the reactive lighting algorithm? If I could do that I would be able to see if my algorithim is fast enough to keep up.
I'm trying to sort all this out before I go and purchase any parts for this project, so any help is appreciated.