A macOS guitar tuner built with a custom implementation of the YIN and YAAPT pitch detection algorithms. Originally developed for the 2021 Georgia Science and Technology Fair — 2nd Place in Project Programming.
pytuner detects the pitch of a live microphone input or audio file and matches it to the nearest guitar note (E2–E5). The app provides a tkinter GUI with a note display, tuning indicator, and a reference note playback feature.
Two pitch detection algorithms are implemented from scratch:
- YIN — autocorrelation-based method using the cumulative mean normalized difference function (CMNDF), based on de Cheveigné & Kawahara (2002)
- YAAPT — "Yet Another Algorithm for Pitch Tracking," using AM-FM decomposition via the
amfm_decompylibrary
YIN is the default. YAAPT is available as an alternative and is more robust on noisy or complex signals.
Requirements: Python 3.7+, macOS (tkinter is bundled with the macOS Python installer)
git clone https://github.com/vmehta-11/pytuner.git
cd pytuner
pip install -r requirements.txtIf sounddevice has trouble finding your microphone, you may need to grant Terminal microphone access in System Preferences → Security & Privacy → Microphone.
cd tuner
python tuner.pyThe GUI will open. Click Start to begin listening to your microphone. The detected note and tuning offset are displayed in real time. Use the note dropdown to play a reference pitch.
To switch between YIN and YAAPT, change the algorithm variable at the top of tuner.py.
tuner/
├── tuner.py Main application and GUI
├── tunertools.py YIN and YAAPT pitch detection, audio utilities
├── dropdown.py Custom tkinter dropdown widget
└── GuitarNotes/ Reference audio samples (one .wav per note)
docs/ Sphinx documentation source
sounddevicecaptures a short audio buffer from the microphone at 44100 Hz.- The buffer is passed to
YIN()oryaapt()intunertools.py. - The returned pitch (Hz) is averaged across frames using
avg_pitch(). quantize()snaps the frequency to the nearest note in the guitar frequency table.- The GUI updates with the detected note name and cents offset.
MIT — see LICENSE.