walking ring sine wave generator
The waveform generated by your circuit is special, because unlike a plain square wave, it contains no 3rd harmonic at all, nor any multiples of the 3rd harmonic (9th, 15th, 21st, etc.). The waveform contains only the fundamental, and the 5th, 7th, 11th, etc. harmonics:



This is a huge advantage for synthesizing sinewaves, since the filter only needs to suppress those higher-order harmonics.

In order to understand this, it's helpful to view it in terms of the phasor diagrams for each of the harmonics:



If we set the 0&deg; point of the waveform at the center of the rising zero crossing, as shown below, the symmetry of the phasor diagram becomes more obvious.



Relative to the 0&deg; point, the A waveform's fundamental crosses zero 30&deg; earlier (&#150;30&deg;) and the B waveform's fundamental does so 30&deg; later (+30&deg;). The sum of these two components aligns with the 0&deg; axis, and has a magnitude equal to 1.732&times; the amplitude of A or B alone.

The third harmonics have phase shifts that are 3&times; that of the fundamentals, putting them at &#150;90&deg; and +90&deg; on the phasor diagram.
Clearly, they directly cancel each other, leaving none of that component to appear in the output.

The fifth harmonics have phase shifts of 5&times; the fundamentals, so they add in the same proportion as the fundamental, resulting in no net change in amplitude relative to the original squarewave alone.

So, if you have four flip-flops and three resistors, how would you calculate
the resistor values to get the best approximation to a sinewave?

Start by drawing the phasor diagram for this case. We now have three waveforms, A, B and C, separated by 45&deg; as shown below.



The fundamentals have the relationship shown below. The B signal is aligned with the 0&deg; axis, but the A and C waveforms are at &#150;45&deg; and +45&deg;, respectively. The net sum will be B + 1.414&times;(A or C).



The third harmonics a A and C have 3&times; the phase shift of the fundamentals, placing them at &#150;135&deg; and +135&deg;, respectively, as shown below. It becomes clear that the sum of A and C can be used to cancel B if the amplitudes of A and C are equal to each other, and equal to \$1/\sqrt{2} = 0.707\$ the amplitude of B.

Going back to the fundamental diagram, this means that the net total of that component will be 2&times; the level of B alone.



Similarly, the fifth harmonics a A and C have 5&times; the phase shift of the fundamentals, placing them at &#150;225&deg; and +225&deg;, respectively, as shown below. Although they have switched positions, the A and C components will cancel the B component exactly as in the third-harmonic case shown above.



This technique can be generalized to even more stages. Each added stage cancels another set of harmonics if the resistor values are set correctly.

By cancelling low-order harmonics in this way, only the higher-order ones need to be filtered out, making it easy to synthesize high-quality sinewaves with a simple combination of digital and analog components.

Note that there's a limit on how far it makes sense to take this. For example, if you use 1% resistors, the cancellation of harmonics is not going to be perfect. The errors will accumulate at a rate roughly proportional to the square root of the number of stages, which means that for an N-stage synthesizer, the overall error will be \$\sqrt{N}\cdot 1\%\$.

There would be no point to adding another stage if the level of the harmonic to be cancelled would be less than this error amplitude. Since the harmonic amplitudes are proportional to 1/(2N&#150;1), we simply need to find the value of N for which 1/(2N&#150;1) &lt; \$0.01\cdot \sqrt{N}\$.

It doesn't take much trial-and-error to discover that this happens at about 13 or 14 stages.