Complex sinusoid oscillator. More...
#include <Oscillator.h>
Inherits Ts.
Public Member Functions | |
CSine (Tv frq=440, Tv amp=1, Tv dcy=-1, Tv phs=0) | |
void | amp (Tv val) |
Set amplitude. | |
void | decay (Tv val) |
Set number of units to decay -60 dB. Negative = no decay. | |
void | freq (Tv val) |
Set frequency. | |
void | phase (Tv radians) |
Set phase. | |
void | reset () |
Resets amplitude and sets phase to 0. | |
complex | operator() () |
Iterate and return current complex output. | |
Tv | freq () |
Return frequency. | |
Public Attributes | |
complex | val |
Current complex output. |
Complex sinusoid oscillator.
This oscillator outputs a sine and cosine wave simultaneously. Efficiency wise, it's comparable to a non-interpolating table oscillator, but gives a quadrature (90 degree phase shifted) wave for free. The sinusoids are computed by multiplying two complex numbers to rotate a phasor. This requires only four multiplications and two additions per iteration. The main disadvantage of this oscillator is that it is expensive to change its frequency. This is implemented from Mathews, M., Smith, J. 2003. "Methods for synthesizing very high Q parametrically well behaved two pole filters."
CSine | ( | Tv | frq = 440 , |
Tv | amp = 1 , |
||
Tv | dcy = -1 , |
||
Tv | phs = 0 |
||
) |
[in] | frq | Frequency |
[in] | amp | Amplitude |
[in] | dcy | Decay time (negative means no decay) |
[in] | phs | Phase in [0, 1) |