summaryrefslogtreecommitdiff
path: root/rotord/rotor.h
diff options
context:
space:
mode:
authorTim Redfern <tim@herge.(none)>2013-06-21 16:33:01 +0100
committerTim Redfern <tim@herge.(none)>2013-06-21 16:33:01 +0100
commitba8a37228891c868030464b91ebb2ffe306219a7 (patch)
tree20096effa50f93b2364d9edfc8e9ad397792e989 /rotord/rotor.h
parentb438fa8772d071663692c6c936881e1f44590523 (diff)
adding hash function
Diffstat (limited to 'rotord/rotor.h')
-rwxr-xr-xrotord/rotor.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h
index f27d99d..ed566c7 100755
--- a/rotord/rotor.h
+++ b/rotord/rotor.h
@@ -599,6 +599,34 @@ namespace Rotor {
return 0.0f;
}
};
+ //pseudo random repeatable hash function
+ //http://create.stephan-brumme.com/fnv-hash/
+ const uint32_t Prime = 0x01000193; // 16777619
+ const uint32_t Seed = 0x811C9DC5; // 2166136261
+ class Random: public Signal_node {
+ public:
+ Random(){};
+ Random(map<string,string> &settings) {
+ base_settings(settings);
+ seed=ofToFloat(find_setting(settings,"amount"));
+ for (auto p:parameter_inputs){
+ if (p->parameter=="seed") p->receiver=&seed;
+ }
+ key=0xffffffff;
+ };
+ Random* clone(map<string,string> &_settings) { return new Random(_settings);};
+ const float output(const Time_spec &time) {
+ if (inputs.size()) { //there should there be a way to specify number of inputs in the code rather than in xml
+ if (inputs[0]->connection) {
+ return 0.0f;
+ //return (((Signal_node*)inputs[0]->connection)->get_output(time))/divide_amount;
+ }
+ }
+ return 0.0f;
+ }
+ float seed;
+ uint32_t key;
+ };
class Signal_output: public Signal_node {
public:
Signal_output(){};