summaryrefslogtreecommitdiff
path: root/rotord/src/nodes_maths.h
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2014-01-24 13:26:49 +0000
committerTim Redfern <tim@eclectronics.org>2014-01-24 13:26:49 +0000
commit913bb43738c7d7391cd990ff1fc3f261afdf78ee (patch)
tree9734168818fbbe6dd78cb3747576ce1f2fdc9d07 /rotord/src/nodes_maths.h
parent6ef14b732971507794ceda70b8a067b874098b9c (diff)
random frequency
Diffstat (limited to 'rotord/src/nodes_maths.h')
-rw-r--r--rotord/src/nodes_maths.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/rotord/src/nodes_maths.h b/rotord/src/nodes_maths.h
index 6bbccdc..b2aa9c7 100644
--- a/rotord/src/nodes_maths.h
+++ b/rotord/src/nodes_maths.h
@@ -229,6 +229,9 @@ namespace Rotor {
description="Randomises integer part of signal (seedable)";
create_signal_input("signal","Signal");
create_parameter("seed","number","Seed value","Seed",1.0);
+ create_parameter("frequency","number","Frequency of randomisation","Frequency",1.0);
+ //kind of a hack
+ //need to think of a better way to randomise periodically
NODEID="1de86932-2d0b-11e3-96d3-77aa4558e6cd";
std::uniform_int_distribution<> d(-9999, 9999);
};
@@ -243,9 +246,9 @@ namespace Rotor {
o=inputs[0]->get(time);
}
else o=time.time;
- uint32_t m=(int)o;
+ uint32_t m=(int)(o/parameters["frequency"]->value);
PRNG.seed(m^(int)parameters["seed"]->value);
- return ((double)(PRNG()&0xffff))+(o-m);
+ return ((double)(PRNG()&0xffff))+(((o/parameters["frequency"]->value)*parameters["frequency"]->value)-m);
//uint32_t seed=Seed+parameters["seed"]->value;
//hash the integer part and add the fractional part back on