Skip to content

richard-hartmann/tuner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tuner

by Richard Hartmann

Tuner - frequency analysis of the microphone input suitable to tune instruments.

image gui

Install and Run

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

Usage

  1. Make sure the desired microphone is selected. If you do not want to tune to a at 440Hz, change the value
  2. 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.
  3. 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.

License

GNU General Public License v3.0

Donation

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.ⅾⅇ.

Basic Idea of the Algorithm

  1. 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).
  2. 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)
  3. 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)
  4. 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)

Acknowledgements

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!