#include <gen.h>
Public Member Functions | |
| CReson (const T &frq=T(0), const T &=T(1), const T &phs=T(0), const T &dec=T(1)) | |
| const C & | operator() () |
| Advance one iteration and return value. | |
| const C & | operator() (const C &v) |
| Filter input. | |
| const C & | recede () |
| Recede one iteration and return value. | |
| void | amp (const T &v) |
| Set amplitude. | |
| void | decay (const T &target, const T &N=T(1)) |
| Set amplitude decay/grow factor after N iterations. | |
| void | factor (const T &frq, const T &dec=T(1)) |
| Set recursive multiplication factor (frequency and decay/growth factor) | |
| void | freq (const T &v) |
| Set unit frequency. | |
| void | set (const T &frq, const T &, const T &phs, const T &dec=T(1)) |
| Set unit frequency, amplitude, unit phase, and decay/grow factor. | |
| C | ahead () const |
| Get value one iteration ahead of current state. | |
| C | behind () const |
| Get value one iteration behind current state. | |
| T | decay () const |
| Get unit decay. | |
| T | freq () const |
| Get unit frequency. | |
| C & | arg (const T &v) |
| Set phase leaving magnitude the same. | |
| T | arg () const |
| Returns argument (angle) | |
| C & | fromPhase (const T &v) |
| Set phase and normalize. | |
| C & | fromPolar (const T &m, const T &p) |
| Set magnitude and phase. | |
| T | mag () const |
| Returns norm (radius), |z|. | |
| C & | norm (const T &v) |
| Set magnitude leaving phase the same. | |
| T | norm () const |
| Returns norm (radius), |z|. | |
| bool | operator== (const C &v) const |
| Returns true if all components are equal. | |
| bool | operator== (const T &v) const |
| Returns true if real and equals value. | |
| bool | operator!= (const C &v) const |
| Returns true if any components are not equal. | |
| bool | operator> (const C &v) const |
| Returns true if norm is greater than argument's norm. | |
| bool | operator< (const C &c) const |
| Returns true if norm is less than argument's norm. | |
| C | conj () const |
| Returns conjugate, z*. | |
| T | dot (const C &v) const |
| Returns vector dot product. | |
| C | exp () const |
| Returns e^z. | |
| C | log () const |
| Returns log(z) | |
| T | norm2 () const |
| Returns square of norm, |z|^2. | |
| C & | normalize () |
| Sets norm (radius) to 1, |z|=1. | |
| C | pow (const C &v) const |
| Returns z^v. | |
| C | pow (const T &v) const |
| Returns z^v. | |
| C | recip () const |
| Return multiplicative inverse, 1/z. | |
| C | sgn () const |
| Returns signum, z/|z|, the closest point on unit circle. | |
| C | sqr () const |
| Returns square. | |
| C | sqrt () const |
| Returns square root. | |
| C | cos () const |
| Returns cos(z) | |
| C | sin () const |
| Returns sin(z) | |
| T | abs () const |
| Returns norm (radius), |z|. | |
| T | magSqr () const |
| Returns magnitude squared, |z|^2. | |
| T | phase () const |
| Returns argument (angle) | |
Complex resonator.
A complex resonator consists of two complex numbers- one is an absolute phase and amplitude and the other is a relative (differential) frequency and decay/grow factor.
| CReson | ( | const T & | frq = T(0), |
| const T & | amp = T(1), |
||
| const T & | phs = T(0), |
||
| const T & | dec = T(1) |
||
| ) |
| [in] | frq | unit frequency |
| [in] | amp | amplitude |
| [in] | phs | unit phase |
| [in] | dec | unit decay/grow factor |
| void set | ( | const T & | frq, |
| const T & | amp, | ||
| const T & | phs, | ||
| const T & | dec = T(1) |
||
| ) |
Set unit frequency, amplitude, unit phase, and decay/grow factor.
The phase state will be rewound 1 iteration so the first function call will return a complex number at the desired phase.