Open pavlos163 opened 7 years ago
I cut out 2.4 to 4.0 seconds, which should be E4 = 329.63 Hz:
freq_from_fft
says 329.366907 Hz (E4 -1 cent)freq_from_crossings
says 634.629287 Hz, (which I would expect to be wrong because it's not a sine)freq_from_autocorr
says 329.605440 Hz (E3 -0 cent)freq_from_hps
says 330.929520 Hz (E3 +6.8 cents)freq_from_hps
says 329.405667 Hz (E3 -1 cent) after changing to decimate(X, h, zero_phase=True)
(which it probably should be)So it looks like it's working to me. It's off by 1.3 Hz in the worst case, not 10 Hz.
>>> filename = "E4 only.wav"
>>> signal, fs, channels = load(filename)
>>> freq_from_hps(signal, fs)
329.40566724171208
Looks like I should also have de-meaned the spectra before summing them. HPS function was only half-finished
With a 1 kHz sqrtsin test wave, and zero_phase=False
(default):
1000.462192 Hz
After changing to zero_phase=True
:
1000.018354 Hz
So the decimation was making it inaccurate, but your inaccuracy seems a lot higher?
@pavlos163
Have you tried it since I fixed the bug in HPS?
I am using
freq_from_hps
as described here to detect pitch in monophonic guitar samples.I noticed that the results I get often have a slight estimation error which is always +10-15Hz. For example, when I want to detect pitch for this audio file (see end of post for the correct pitches) I get:
[['F4'], ['F#4'], ['G4'], ['G#4'], ['A4'], ['A4'], ['A#4'], ['B4'], ['C5'], ['C#5'], ['D5'], ['D#5'], ['E5'], ['F5'], ['F#5'], ['G5'], ['G#5'], ['A5'], ['A#5'], ['B5'], ['C6'], ['C#6'], ['F4']]
When I increase every of these pitches by 10Hz I get:
[['E4'], ['F4'], ['F#4'], ['G4'], ['G#4'], ['A4'], ['A#4'], ['B4'], ['C5'], ['C#5'], ['D5'], ['D#5'], ['E5'], ['F5'], ['F#5'], ['G5'], ['G#5'], ['A5'], ['A#5'], ['B5'], ['C6'], ['C#6'], ['E4']]
Which is actually 100% correct.
This basically happens for almost every note below G#4 (and above E2). What could be the issue here? Any ideas about how there is such a fixed estimation error?
Furthermore, as I am designing this application specifically for the guitar, do you have any recommendations/tips as to how I could optimise this method?
Thanks.