tone: Exploit sine-wave symmetry to save space.
The sine wave basically can be divided into four quadrants, 0→0.5pi,
0.5pi→pi, pi→1.5pi and 1.5pi→2pi. If we call these Q1, Q2, Q3 and Q4,
we can see:
- Q2 is basically Q1 in reverse
- Q3 is Q1 negated
- Q4 is Q2 negated
We can therefore exploit this to store ¼ of the waveform. We do some if
statement trickery to stitch the partial waveforms together. End result
is we've now quadrupled the definition of our sine wave at minimal
code-size cost.
CPU wise is a wee bit more expensive, but still a lot better than
actually calculating sine with a math library!
git-svn-id: https://svn.code.sf.net/p/freetel/code@2381
01035d8c-6547-0410-b346-
abe4f91aad63