As a small project I want to get an LED to adjust brightness based on a waveform. I am assuming I would need to analyze the waveform, and convert the amplitude to a 0-1023 value, but I have no idea where to begin. I was hoping to find a library or API online that could work with this idea, but all of them rely on sound sensors or microphones. If there is any way to have the audio on the arduino and use the board's system memory to store and process the files, that would help a lot in keeping the size of the build down.
You can easily program a waveform into the arduino - but any sort of sound with much information content would soon fill up the memory space.
Of course you can connect an audio player to an arduino input and use that to control an LED.
Well not quite it will make the build a lot bigger because it has to store all the bytes in the audio sample. There is enough memory to store about three seconds of audio in an Arduino Uno.
It would be better if your Audio were in a file in an 8 bit format on an SD card. The computer app Audacity will do that for you and you can transfer it to the SD card on your PC.
Then just read the bytes one by one, apply a map function to them and then feed that into the number 0 to 255 of an analogue write function. Note the only pins this works with are the PWM ones normally identified with a ~ next to the PIN number.
You can get various Audio Shields. The audio shield uses an SD card to hold the audio files and it does all of the "real work" with the Arduino just telling it what file to play and when to start, etc.
With this set-up, the Arduino can't directly read the audio data from the SD card so the Arduino would have to be separately programmed to activate the LED based on what file is the playing, or it could read the analog output from the audio shield.
The advantage of separate programming is you can program the LED(s) to do exactly what you want. The disadvantage is it's a lot of time-consuming careful programming for each song. That kind of thing is done for stage lighting where everything is determined in advance. DJs use sound activated lighting.
You can use a direct line-level or headphone-level audio signal which is better if you don't want to pick-up normal room sounds.
I made The World's Simplest Lighting Effect as an example which reacts to the audio. There is a schematic if you want to use a direct signal (or It will work with a microphone board.)
Which is in effect what I did for this project to get the mouth in some sort of sync with the words.
I had pre loaded some answers to common questions I get about my exhibits, so when I was asked them at the show I could put in the answer number and the circuit would speak the answer. To do this I fed the audio back into an analogue input and use the reading to pick a graphic with an increasingly large mouth.