0
$\begingroup$

I wish to control a simple pitch tracker using my voice. So far I have experimented with fft and yin. I am extracting the frequency and amplitude in real time. I then feed these into:

a*sin(2 * pi * f * t)

where a is my amplitude and f is the frequency. I'm wondering though if I should also be calculating the phase of the fundamental and adding that parameter to the equation. I have read that our ears are not sensitive to phase but I still think that there can be glitches in the output as the frequency changes. What do you think, should I also be calculating phase in your opinion?

I'm also thinking I might try to band pass filter around the fundamental and compare that signal with the signal I am producing, to see how they differ and if they sound different.

$\endgroup$
2
  • $\begingroup$ Consider the possibility that there is no energy or insufficient energy for the first harmonic. $\endgroup$ Jun 19 at 19:45
  • $\begingroup$ Are you intending to implement this for a live, real-time application? So you're singing into a microphone and the device tells you immediately what your pitch is? $\endgroup$ Jun 20 at 2:47

1 Answer 1

1
$\begingroup$

There are better pitch detection/estimation algorithms than either using FFT (and doing what with the FFT results) or YIN. In fact YIN is a spin off of the autocorrelation and AMDF methods known since the 1970s.

About phase locking, it might not be all that necessary unless you're tracking and analyzing a note for wavetable synthesis.

Now, if you are tracking phase of the fundamental (and I mean of the whole quasi-periodic waveform, not necessarily the first harmonic, which might slide a little in phase), the way you do that is, for each analysis frame that are spaced apart by a known difference in time, you take the phase of the previous frame, add to it the phase change during that time based equally on the fundamental frequencies (the reciprocal of the periods) of both the last previous frame and that of the new current frame.

$\endgroup$
3
  • $\begingroup$ Thanks for your reply. I am applying the Harmonic Product Spectrum to the fft. I am using this algorithm: gist.github.com/carlthome/1e7244e31bd628a0dba233b6dceebaef I have seen your post before about ASDF, so I am interested in trying that too :) What size hop length am I likely to get good results with, generally speaking, when trying to do pitch tracking in real time on a computer? $\endgroup$
    – Baz
    Jun 19 at 19:17
  • 1
    $\begingroup$ Yeah, I remember reading about that HPS thing back in the 1980s. Totally forgot about it as one of the alternatives. It's very old (Noll 1969) and I think it's in the Rabiner and Schafer speech processing book. It's super expensive, computationally, and has no advantage over autocorrelation (or AMDF) based technique. It also breaks if there is no energy in the first harmonic. $\endgroup$ Jun 19 at 19:59
  • $\begingroup$ Sorry I forgot to answer you about the hop. In my experience analyzing music notes, I had a frame hop of 1 or 2 ms. If it was a recording of a single note (that I wanted to break into wavetables), I might start 10 or 20 ms into the note, past the attack, and then track backwards (every hop) from there to the attack and use the pitch information to track back to the attack. I would also then adjust the phases of the tracked waveform so that the first (or zeroth) frame had a phase defined to be zero. $\endgroup$ Jun 20 at 2:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.