Audio and Acoustic Signal Processing - Mini Project - Pitch Detection Vivien du Bois de Dunilac & David Pittet
What is this project ? This is a real time pitch detector intended for monophonic audio signals. It takes the input from a microphone and outputs the detected pitch to the console.
How to run it To run this program you will need python3, sounddevice, scipy and numpy. For reference we used the following versions:
- Python 3.6.1
- SoundDevice 0.3.12
- SciPy 1.1.0
- NumPy 1.15.4
Then you can simply run our program like any other python program: python dft_pitch.py
This will grab the input of your machine's default microphone and output the detected pitch values to the console.
- Command line arguments Our program can take various parameters to improve its performance for different use cases.
--list-devices or -l prints a list of available audio devices and exits
--bin-value or -b (float, default=5) sets the maximum acceptable bin value for the DFT, a smaller value means more frequency resolution but also more computation time
--noise-threshold or -n (float, default=0.2) sets the minimum volume that is required to output a pitch
--peak-threshold or -p (float, default=0.6) sets the minimum value for peak detectino as a function of the maximum value of the current DFT
--repeat-count or -rc (int, default=2) sets the number of times that the same prediction must be made in a row in order to output a pitch
--device or -d (int or string) selects the preferred input device either with its numeric ID or with a substring of its name
--samplerate or -r (float, default=16000) sets the preferred sampling rate for the microphone input, will return an error if the rate is not supported
- Provided examples We recommend using Virtual Audio Cable to input the standard audio output of your machine into a virtual microphone. (www.vb-audio.com/Cable)
We also recommend Tomasz P. Szynalski's online tone generator (http://www.szynalski.com/tone-generator/) and Stéphane Pigeon's noise generator (mynoise.net/NoiseMachines/whiteNoiseGenerator.php) for quick tests.
We provide several mp3 files that contain recordings of two melodies played on an electric guitar without any effects at different tempos and reference text files that contain the notes that are played in order.
Using Virtual Audio Cable it is then easy to feed the contents of the files to our program to check that the output corresponds to the reference. (Note that the reference files are not 100% complete because the last notes of both melodies are fast hammer-on/pull-offs and we do not expect our program to correctly detect them)