I'm using the YIN algorithm to establish the pitch of my humming / whistling voice.
This is a time domain algorithm and gives me the instantaneous frequency as a function of time ($f(t)$). I now wish to establish the instantaneous amplitude, $a(t)$. I am then plugging these values into the equation:
a(t) * cos(2*pi*integral_of_f(t))
to reproduce the signal based on $f(t)$ and $a(t)$.
At the moment, I am establishing $a(t)$ as follows:
If I establish that $f(t)$ for a given sample is say 20.1 samples in terms of its period, I then create a window centred around this sample t, of length 21. I choose 21 because it is the next whole odd number above the period. I then apply the root mean square equation to this window:
amp = np.sqrt((w * w).sum() / len(w))
My samples are
Does this sound like a reasonable approach?
One issue would be if I have a signal with a period drifting between between say 15.01 and 14.99 over time. In that case I would use a window of 17 when the instantaneous period of t is 15.01 and 15 when it is 14.99. Not sure if that is a big issue.