List of Audio Libraries and References
The following list of C / C++ libraries and references for audio processing is provided for your convenience only.
You are not required to use any of these libraries / references for this homework.
-
Keep It Simple, Stupid FFT library.
-
Audacity. Useful for analyzing raw audio (waves) and modifying audio files (ie. stereo <--> mono).
-
Example code for computing the spectrogram in C: alsgram.zip.
Part 1a: Slow DFT
Implement the Discrete Fourier Transform (DFT) in C, C++, MATLAB, Java, or Python. Implement the slow version that multiplies the transform matrix by the input vector in O(N2) time. Your code should support input vectors of size up to 1024. In addition, you must implement your own functions to deal with complex numbers.
// Insert your code here
Part 1b: Slow IDFT
Implement the Inverse Discrete Fourier Transform (IDFT) in C, C++, MATLAB, Java, or Python. Implement the slow version that multiplies the transform matrix by the input vector in O(N2) time. Your code should support input vectors of size up to 1024. In addition, you must implement your own functions to deal with complex numbers.
// Insert your code here
Part 2a: FFT
Implement the Fast Fourier Transform (FFT) in C, C++, MATLAB, Java, or Python. Implement the fast version that uses recursion and runs in O(n log2 n) time. Note that you are not allowed to use MATLAB's implementation nor any other existing library for this problem. Your code should support input vectors of size up to 1024. Use your code from Part 1a to cross-check your implementation. In part 2, you can use any library functions that work with complex numbers (but not in part 1).
// Insert your code here
Part 2b: IFFT
Implement the Inverse Fast Fourier Transform (IFFT) in C, C++, MATLAB, Java, or Python. Implement the fast version that uses recursion and runs in O(n log2 n) time. Note that you are not allowed to use MATLAB's implementation nor any other existing library for this problem. Your code should support input vectors of size up to 1024. Use your code from Part 1b to cross-check your implementation. In part 2, you can use any library functions that work with complex numbers (but not in part 1).
// Insert your code here
Part 3a: FFT check
Using your implementation from Part 2a, compute the Discrete Fourier Transform of the following vector:
[0, 0.7071, 1, 0.7071, 0, -0.7071, -1, -0.7071]
Note: you may want to use sqrt(2)/2 instead of 0.7071.
// Insert your resulting vector here
Compare your output with the output generated by MATLAB's fft() method for the same vector 'x'. Include the result below, and point out any discrepancies. You may also use one of the FFT libraries above, if you choose.
// Insert your new resulting vector here // Insert any comments here
Part 3b: IFFT check
Using your implementation from Part 2b, compute the inverse Discrete Fourier Transform of the following vector:
[0, -4i, 0, 0, 0, 0, 0, 4i]
// Insert your resulting vector here
Compare your output with the output generated by MATLAB's ifft() method for the same vector 'X'. Include the result below, and point out any discrepancies. You may also use one of the IFFT libraries above, if you choose.
// Insert your new resulting vector here // Insert any comments here
Part 4a
Using any FFT and IFFT implementation, compute and plot the spectrograms for the following 3 audio files. In case you are curious, these audio snippets came from a video game.
Audio Data | Spectrogram |
---|---|
![]() |
|
![]() |
|
![]() |
// Insert your code here
Part 4b
Repeat what you did in part 4a, but now process three audio files that you recorded while playing your favorite game. Describe how you recorded the audio and what parameters were used (e.g., sampling frequency, duration). Also, describe the parameters that you used to compute the spectrograms (you can put this in the comments for your code). Modify the HTML template so that your files are linked and your spectrograms are shown to the right of each audio file. Replace the three audio files in this folder with your own files.
Audio Data | Spectrogram |
---|---|
![]() |
|
![]() |
|
![]() |
// Insert your code here
Part 5
Your task is to write a program that can detect a single note in an audio data and print it. The program should handle audio generated by different musical instruments. The notes will be restricted to piano notes listed in this Wikipedia page (also cached here in PDF), but any of these notes may be the one. The program should print the note in the scientific notation.
Hint: one way to solve this problem is to perform frequency-domain analysis (e.g., using a spectrogram) of the audio data and look for the location of peaks. The highest peak should be at the frequency of the note.
Students with perfect pitch are not exempt from solving this problem. The note must be detected by the program and not by the programmer.
Part 5a. Piano
Audio Data | Note | Program Output |
---|---|---|
C4 | Output of your program. | |
B2 | Output of your program. | |
F6 | Output of your program. | |
Output of your program. | Output of your program. | |
Output of your program. | Output of your program. | |
Output of your program. | Output of your program. | |
Output of your program. | Output of your program. |
// Insert your code here
Part 5b. Different Instruments
Instrument | Audio Data | Note | Program Output |
---|---|---|---|
Piano | C4 | Output of your program. | |
Electric Guitar | C4 | Output of your program. | |
Violin | A4 | Output of your program. | |
Violin | Output of your program. | Output of your program. | |
Trumpet | Output of your program. | Output of your program. | |
Trumpet | Output of your program. | Output of your program. | |
Tuba | D2 | D3 | |
Bassoon | Output of your program. | Output of your program. | |
Marimba | Output of your program. | Output of your program. | |
Marimba | Output of your program. | Output of your program. |
// Insert your code here
Extra Credit 1
In this problem you have to write a program that can recognize single notes in a sequence and print them in the same order as they are played. The program should print the note in the scientific notation. There are no chords in the audio data.
Part A. Short Piano Melodies, Single Notes
Audio Data | Notes | Program Output |
---|---|---|
C4 C4 G4 G4 A4 A4 G4 | Output of your program. | |
Output of your program. | Output of your program. | |
Output of your program. | Output of your program. |
// Insert your code here
Part B. Short Melodies Played with Different Instruments, Single Notes
Instrument | Audio Data | Notes | |
---|---|---|---|
Electric Piano | C#2 C#2 C#2 C#2 B2 B2 B2 C#3 D3 | Output of your program. | |
Electric Piano | Output of your program. | Output of your program. | |
Radio Tuning Signal | Output of your program. | Output of your program. |
// Insert your code here
Extra Credit 2
Non-Recursive FFT
Implement a non-recursive version of the Fast Fourier Transform (FFT) in C, C++, MATLAB, Java, or Python. This is the iterative version of the algorithm that still runs in O(N log2N) time, but does not use recursion. Your code should support input vectors of size up to 1024. Once again, this must be your own implementation. Run your code on the vector from part 3a and report the result.
// Insert your code here
// Insert your resulting vector here