by Richard Hartmann
Tuner - frequency analysis of the microphone input suitable to tune instruments.
if you have not, install poetry
, dependency management and packaging in Python.
Use poetry install
to install dependencies.
Run the app by poetry run python start_tuner.py
- Make sure the desired microphone is selected. If you do not want to tune to a at 440Hz, change the value
- Select the key you want to tune to. Use the 'next' and 'prev' to see how the inputs 'key' and 'level' work. It also shows the target frequency of that key.
- Play a tone and tune such that the relative difference (upper right panel) is well below 1% (0.01) for some time. You can use the mouse (drag and scroll) to adjust the axes.
GNU General Public License v3.0
If you like the tuner-App, feel free to donate with PayPal. If you don't like PayPal, contact me at richard_hartmann(at)gmx.ⅾⅇ.
- Perform Fourier integral (finite integral over several oscillations of the recoded microphone signal) for frequencies in the vicinity of a given target frequency Ω, and multiples of that (higher harmonics contributions).
- Plot such spectra and shift the frequency axis by -nΩ (different shift for each higher harmonic!). In that way, if the base frequency of the recoded signal ω1 is resonant with Ω, all maxima should align at ω-nΩ = 0. In practice the maxima of the spectra vary much over time, so their alignment is not well suited to judge the resonance, i.e. the tuning to the target frequency Ω. (upper left plot)
- Use the amplitude and phase information from the Fourier integral as initial condition to fit a harmonic model signal with base frequency ω1 and its higher harmonics nω1 to the recoded input. (lower plot)
- Show the relative difference of the optimal value ω1 with respect to the target frequency Ω. Keep track of its value over some time. Record no value if the least square fitting does not converge sufficiently fast. (upper right plot)
As of the great collection of numeric routines provided by numpy putting the algorithm in place was straight forward. The plotting was made possible using Qt wrapped to Python via pyqtgraph. Thanks!