## Background Here is a simple python instrument tuner. The idea is that you connect your instrument to your computers audio input, and the python script will tell you what note is being played (the note associated with the dominant frequency). I decided to build this application because my bass tuner has gone missing. I believe someone has taken it from me and a mild sense of pride has kept me from acknowledging it is gone, so I am therefor reluctant to buy a new one. However, this program I have written is free and I hope it will do the job. ## Setup Potential libraries needed for debian-based gnu+linux ``` sudo apt-get install libportaudio2 ``` Install python libraries ``` pip install -r requirnments.txt ``` You will need to tweak the code to choose the correct device number. Of course, this could be abstracted to a python argument with a default value. ## Run ``` python3 main.py ``` ## View Source [main.py](./main.py) ## Demo [Keyboard](./key-demo.mkv) [Bass](./bass-demo.mkv) [Trumpet](./trumpet-demo.mkv) ## Reflection This app works ok in some circumstances. Specifically, it seems to do well with mid range and high range frequencies, but was not very helpful for bass tuning. This could be for a variety of reasons including improper use of my bass amplifier, or sub-standard instrument, but I also suspect I could re-work my calculation of dominant frequenceies to better accomodate low ranges. Getting the results I have took some work. I did understand I would need to use an FFT to recover the frequencies from the signal, but understanding how to properly apply a window (hanning) and the chunk size took more work. In addition to reviewing the course notes, ChatGPT was consulted to help debug and refine the function `dominant_frequency`. Deriving the note and octave values from the frequencies was rather straightforward algebra from the [notes](https://github.com/pdx-cs-sound/course-notes/blob/main/03-freq/04-notes.md) lecture. ## Consultation [Python Sounddevice documentation](https://python-sounddevice.readthedocs.io/en/0.5.1/examples.html#plot-microphone-signal-s-in-real-time). This was my first time capturing audio from a PC audio input, rather than a wav file [Tuner example](https://github.com/mzucker/python-tuner/blob/master/tuner.py). This is a similar application, but using pyaudio rather than sounddevice. Some inspiration was taken from this.