From 913bb43738c7d7391cd990ff1fc3f261afdf78ee Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 24 Jan 2014 13:26:49 +0000 Subject: random frequency --- rotord/src/nodes_maths.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'rotord/src/nodes_maths.h') 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 -- cgit v1.2.3