If I'm not mistaken, the "SHO" is an example of semi-implicit euler and it is symplectic but only first-order accurate. It doesn't conserve energy exactly, but IIRC in fixed-point the oscillation does cancel the error accumulation. I seem to remember it doing this in floating-point too, at least assuming a specific rounding mode, but I can't seem to find good reference either way for the floating-point case. [Here's some fun discussion.]
Don't take my word for the following (I didn't verify it in any way) but intuitively, I'd guess the phase-quadrature is essentially off by about half a sample.
- KVRAF
- 4792 posts since 11 Feb, 2006, from Helsinki, Finland

- KVRAF
- 4792 posts since 11 Feb, 2006, from Helsinki, Finland
shabby wrote:Interesting stuff mystran. I'm going to look at the phase issue on the weekend, if it's out by .5 sample maybe use v before adjusting it for position:
p+=v;
cosv=v/(dt*2*pi);
v-=p*dts;
That adjusts the phase by one full sample.


-
- KVRAF
- 11810 posts since 7 Dec, 2004
It won't stay in-phase with an ideal phase accumulator, there is non-zero error. If you're generating several harmonics this way they will drift out of phase over time as opposed to generating each scaled from a single phase accumulator.
Same issue as rotation matrices, recomputing the matrices from a rotation vector will be stable because error does not accumulate.
Rotations obviously are worse because the error not only accumulates but does so non-linearly, so rotation matrices can "explode". While that doesn't happen in this case you'll still end up out of phase and the error is dependent upon all of frequency, amplitude and phase.
Same issue as rotation matrices, recomputing the matrices from a rotation vector will be stable because error does not accumulate.
Rotations obviously are worse because the error not only accumulates but does so non-linearly, so rotation matrices can "explode". While that doesn't happen in this case you'll still end up out of phase and the error is dependent upon all of frequency, amplitude and phase.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
-
- KVRian
- 1020 posts since 8 Feb, 2012, from South - Africa