The driving force for switching gears and pursuing a computer science degree was to gain the skills to develop my own tools for recording. I had improvements in mind for the technology I was using day in and day out, and wanted to know how to build it. Some years later, I learned I should have studied electrical engineering to reach this goal, but I stuck with my current path as I found a love for all the new things that I was learning about at the time. For the sake of satisfying my curiosity, however, I spent a few months reading a textbook on signal processing to attempt to create something related to all this things that had inspired me years earlier.
This project is the results of those efforts. At first, I thought I wanted to build a multiband paragraphic audio equalizer implementing some variety of filter equations. I realized the number of foundational steps and components required to make this happen is large, and so I settled for a sort of 'checkpoint'. As it stands now, this program performs real-time spectrum analysis and also contains a single band peak EQ implemented by manipulating the coefficients of the signal transform in frequency domain with respect to a Gaussian curve. The program has all the functionality to serve as a design and test environment for filter implementations, and so when I find time, my next step will be to implement a more practical EQ such as a biquad filter or something similar.
Source Code: https://github.com/CurtisBuckoll/AudioEQ
Using This Program
This program accepts 16 bit 44.1 kHz mono audio files only, and the audio file of choice can be configured in main.cpp. When executed, it will read in the audio file and display it's frequency response over time in a window. The single band of the EQ can be moved around with the W, A, S, D, keys, and the mouse scroll wheel can be moved to tighten or expand the Q (bandwidth).
There are three transforms implemented that we can cycle through to view how they present the signal spectrum. Since the current EQ mode modifies these spectrum coefficients, the selected mode will also affect the behavior of the EQ. By default, FFT is initially enabled. Pressing the spacebar will toggle through the available transforms, from FFT to DFT to DCT and back to FFT. Closing the window will exit the program.
Project Overview
This program runs with two separate threads, one to manage the input and display, and the other to feed process and feed audio data to SDL2 for playback.
For both the Discrete Cosine and Discrete Fourier Transforms, the forward and inverse operations are carried out by N by N matrix multiplications with signal vector N = 256. In the case of the DFT, the rows of the transformation matrix consist of complex entries filled with the 256th complex roots of unity raised to increasing powers according to the index of the row. The construction follows the description from wikipedia: https://en.wikipedia.org/wiki/DFT_matrix.
After taking some time to read about the Fast Fourier Transform, I included recursive implementations of the FFT and inverse FFT also. Even with some room to optimize my implementations, the CPU savings were remarkable, giving room to increase and experiment with the size of the input signal vector block at each process step.
I'll update this page with more information at some point, but for now, I'll leave with the program's visual spectrum output of a sine sweep from 20Hz to 20kHz: