Resample at 4 times the tone frequency

Unfasor
http://en.wikipedia.org/wiki/Phasor

Why do you resample the side-tone at 4 times the tone frequency to obtain its envelope? This relates to how you think of the side-tone, or sinusoids (=sine waves) in general. At first glance, the amplitude of a sine wave goes up and down, so depending on the timing you observe the signal, you will get various values as its amplitude. One idea to detect the peak value in an interval greater than its period, somewhat equivalent to an envelope detector using a diode and a CR low-pass filter circuit.

But the truth is that the amplitude of a sinusoid does not vary but is constant, as you see in the bottom half of the figure. The radius of the circle is constant! The amplitude varies because you are looking at the shadow of the rotating bar onto the y-axis.

The problem is how you can estimate the length of the rotating bar by just observing its shadow.

The clue is to observe the shadow not once in its rotating period, the phase of the observation being arbitrary, but observe twice in the period, each separated with the time equal to a quarter of the period. The sampling phase of the observation in this case does not matter with the following reasons.

phaser2

If the sample rate is 4 times the tone frequency, you will have 4 sampling points (in red) on a circle each separated with 90 degrees. With an arbitrary sampling phase of th, the two adjacent samples are at the phases of th and th+90deg, respectively, which means the two values are x(i)=A*cos(th) and x(i+1)=A*cos(th+90deg), where A is the length of the rotating bar.

Therefore, you will have
sqrt(x(i)^2+x(i+1)^2)
=sqrt(A^2*cos^2(th)+A^2*cos^2(th+90deg))
=A*sqrt(cos^2(th)+sin^2(th))
=A.

Signals with 90 deg phase difference have an important role in signal processing. One example is the SSB generator with a PSN circuit, which is somewhat more complex because you need to give the phase difference not to a sine wave with a fixed frequency but to s signal with some bandwidth, say between 0.3kHz to 2.7kHz.