diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-17 12:53:15 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-17 12:53:15 +0000 |
| commit | 293c540eecb2bf2566c96e40f6b66186652a0933 (patch) | |
| tree | de40c333a0c9888f77793a5bd252bdeb8c8c6193 /rotord/src | |
| parent | e1d54b6b3a95b37e2e8e807387a725fe5d202c2c (diff) | |
frequency parameter for cyclic functions
Diffstat (limited to 'rotord/src')
| -rw-r--r-- | rotord/src/nodes_maths.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/rotord/src/nodes_maths.h b/rotord/src/nodes_maths.h index 1043599..7b37290 100644 --- a/rotord/src/nodes_maths.h +++ b/rotord/src/nodes_maths.h @@ -76,6 +76,7 @@ namespace Rotor { Arithmetic(){ create_signal_input("signal","Signal"); create_parameter("value","number","Value or signal for operation","Value",1.0); + create_parameter("frequency","number","Frequency for trigonometric functions","Frequency",1.0); create_attribute("operator","operator for image","Operator","+",{"+","-","*","/","%","^","sin","cos","ease","jolt","floor","2pow","reciprocal","rminus"}); title="Arithmetic"; description="Performs arithmetic on a signal with a signal or value"; @@ -127,13 +128,13 @@ namespace Rotor { //sin/cos needs a phase accumulator to allow frequency modulation case ARITHMETIC_sin: - phase+=in*parameters["value"]->value; + phase+=(in-inputs[0]->get(time.lastframe()))*parameters["frequency"]->value; //return sin(phase); need to review this - return sin(in)*parameters["value"]->value; + return sin(phase)*parameters["value"]->value; break; case ARITHMETIC_cos: - phase+=in*parameters["value"]->value; - return cos(in)*parameters["value"]->value; + phase+=(in-inputs[0]->get(time.lastframe()))*parameters["frequency"]->value; + return cos(phase)*parameters["value"]->value; break; case ARITHMETIC_ease: return ((1.0-parameters["value"]->value)*in)+(parameters["value"]->value*(0.5f+((cos((fmod(in,1.0)+1.0)*M_PI))*0.5f))); |
