An open API service indexing awesome lists of open source software.

https://github.com/richard-hartmann/tuner

piano tuner (general pitch detection) in Python
https://github.com/richard-hartmann/tuner

audio-processing frequency-analysis piano-utils pitch-detection pitch-estimation python3 tuner

Last synced: 6 months ago
JSON representation

piano tuner (general pitch detection) in Python

Awesome Lists containing this project

README

          

# Tuner
by Richard Hartmann

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

![image gui](doc/gui.png "tuner-App")

## 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

0) Make sure the desired microphone is selected.
If you do not want to tune to a at 440Hz, change the value
1) 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.
2) 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](https://www.paypal.com/donate/?hosted_button_id=E8LH2WMYGQCGG).
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](https://numpy.org/) putting the algorithm in place was straight forward.
The plotting was made possible using [Qt](https://www.qt.io/) wrapped to
[Python](https://www.python.org/) via [pyqtgraph](https://www.pyqtgraph.org/).
Thanks!