summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rotord/src/nodes_maths.h9
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)));