Audio Visualizer — Code (Fourier Transform)

Having previously used Fourier Series and Transforms in our signals and systems, and differential equations courses, we knew that we could find frequency data from a time domain signal. The challenge really came in trying to determine the best way to implement our understanding. On paper and by hand, Fourier Series and Transforms can be pretty time and calculation intensive. Also, because we’d be performing our calculations on a microcontroller, we had to shift our focus to Discrete Fourier Transforms, and then because of our near real time goal and limited processing power, we had to consider the algorithmic Fast Fourier Transform (FFT). With all this in mind, we knew that someone else had probably already solved this problem. After some research about implementation of FFT on Arduino (https://www.norwegiancreations.com/2017/08/what-is-fft-and-how-can-you-implement-it-on-an-arduino/) and some quick Google searches for AVR FFT, we stumbled upon an efficient, flexible, and open-source FFT written in Assembly (http://elm-chan.org/works/akilcd/report_e.html). Fortunately, the open-source code by ©ChaN was easily integrated into our project with Atmel Studio. Furthermore, the source files were well commented and were added to our project with great ease. Using the guidance of the comments in the Assembly FFT and the basic outline of the Arduino implementation, we were able to successfully sample and transform a signal into the frequency domain in near realtime.

Audio Visualizer — Schematic

The squirrel fans used to levitate the ping pong balls inside each tube were rated at 12V; therefore, the 3.3V output of the A3BU was not enough to drive the fans. Examination of Figure 4 (see Schematics section) reveals that we used a transistor and a 12V DC power supply to amplify the driving voltage of the fans. Each fan motor was connected in parallel with a capacitor and a protective diode. The 12V DC power was connected in series with each motor, capacitor, diode set, making the motor fans in parallel with each other so that each draws an equal 12V as needed. The input to each transistor was preceded by a 220Ω resistor in series with the transistor. The signal of the transistor was connected to ground of the motor, capacitor, diode set to control how often the 12V DC was to be pulsed across the motor. Consequently, the use of an npn transistor allowed us to scale our pulse width modulation signal from the A3BU (0-3.3V) to a 0-12V signal that drives the fans.

Audio Visualizer — Big Picture

The goal of our project was to create a visual representation of the input frequencies collected by a microphone. To do this we had to receive an analog signal from a microphone, and use this signal to drive the speeds of three different fans. After receiving the signal from the microphone, we ran the raw electrical signal through a fourier transform in order to distinguish the various frequencies within the signal. Once we had the multiple frequencies that made up our signal we divided these frequencies into 3 separate bins: low, medium, and high. We used the average of these bins in order to determine the speed at which the fan should run. If the average of the frequencies contained in the low bin increases, then the speed at which fan 1 is rotating will also increase. Fan 2 which corresponds to the medium range frequencies, and fan 3 which corresponds to the high range of frequencies, both operate in a similar manner. Our goal was achieved as we were able to get the fans to fluctuate in speed based on the various frequencies collected.