From 293c540eecb2bf2566c96e40f6b66186652a0933 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 17 Dec 2013 12:53:15 +0000 Subject: frequency parameter for cyclic functions --- rotord/src/nodes_maths.h | 9 +++++---- 1 file 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))); -- cgit v1.2.3