This program provides a real-time audio pitch detection capabilities using both the Discrete Fourier transform and the Harmonic Product Spectrum method. It analyzes audio input from your microphone and displays the closest musical note along with the corresponding pitch.
Before you start, ensure you have the following libraries installed:
- sounddevice
- numpy
- scipy
- tkinter (optional for a graphical user interface)
You can install these libraries using:
pip install sounddevice numpy scipy
- Clone the repository or download the files DFT_tuner.py and HPS_tuner.py.
- Run the script:
python3 DFT_tuner.py
or
python3 HPS_tuner.py
- Play a musical note or sound into your microphone.
- The application will display the closest musical note and your note pitch vs the closest standard note pitch in the terminal.
- Discrete Fourier Transform
- The application captures audio input and processes the data in chunks.
- A DFT is applied to extract the magnitude spectrum and determine the peak frequency.
- The closest musical note is calculated based on the detected pitch.
- Harmonic Product Spectrum
- Similar to the DFT-based method, but with additional steps:
- The magnitude spectrum undergoes multiple interpolations to increase its resolution.
- HPS is applied to the interpolated spectrum to identify the fundamental frequency even in noisy signals.
- The closest musical note is calculated based on the detected pitch.