Audio Library
This project leverages the excellent Audio library for Arduino which has been forked for the NeoTrellis M4 Express from the original Teensy Audio Library by Paul Stroffregen at pjrc. The Audio library is described this way: "A toolkit for building streaming audio projects, featuring Polyphonic Playback, Recording, Synthesis, Analysis, Effects, Filtering, Mixing, Multiple Simultaneous Inputs & Outputs, and Flexible Internal Signal Routing. "
The two key things we're doing with code from the Audio library are filtering audio and analyzing it for visualization.
FIR Filter
The Finite Impulse Response (FIR) Filter code filters the audio based on frequency bands we specify. Wikipedia describes electronic filters this way:
...circuits which perform signal processing functions, specifically to remove unwanted frequency components from the signal, to enhance wanted ones, or both.
The frequency range of a song can span from 20 Hz to 20,000 Hz (the audio spectrum of human hearing) but we can use an FIR filter to selectively pass through only certain bands (ranges) of those frequencies. You can drop out all of the mid and upper bands, only allowing the low end to remain by using a low pass filter. This gives us a type of calm, muffled sound that's great for queuing a build-up in dance music, for example. Our example allows frequencies below 1000 Hz to pass through.
We also have a band pass filter that allows only mid-range to pass through (a band pass can be any band of frequencies you like, we just happen to have chosen a mid-range here). Our example allows frequencies from 1200 Hz to 1700 Hz to pass.
FFT Spectrum Visualization
To turn the Trellis M4's button LEDs into a spectrum analyzer, we need to measure the incoming audio's signal strength in the full frequency range.
The Fast Fourier Transform code computes a 1024 point audio frequency analysis that we can use for visualization of the magnitude of the sound in various frequency range "bins". These values are then used to determine in real time which NeoPixel's to light up in the Trellis M4 buttons.
Page last edited March 08, 2024
Text editor powered by tinymce.