diff options
Diffstat (limited to 'rotord/src/nodes_maths.h')
| -rw-r--r-- | rotord/src/nodes_maths.h | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/rotord/src/nodes_maths.h b/rotord/src/nodes_maths.h index d7aed56..16d37d3 100644 --- a/rotord/src/nodes_maths.h +++ b/rotord/src/nodes_maths.h @@ -2,6 +2,8 @@ #define ROTOR_MATHS #include "rotor.h" +#include <noise/noise.h> +#include <noise/mathconsts.h> namespace Rotor { #define COMPARISON_Equal 1 @@ -200,7 +202,7 @@ namespace Rotor { return 0.0f; } }; - //pseudo random repeatable hash function + //pseudo random hash function //http://create.stephan-brumme.com/fnv-hash/ const uint32_t Prime = 0x01000193; // 16777619 const uint32_t Seed = 0x811C9DC5; // 2166136261 @@ -226,12 +228,12 @@ namespace Rotor { return fnv1a(*ptr , hash); } class Random: public Signal_node { + //randomises integer while keeping fraction public: Random(){}; Random(map<string,string> &settings) { base_settings(settings); seed=(Seed+find_setting(settings,"seed",0)); - cerr<<"random:: seed "<<seed<<" ("<<Seed<<")"<<endl; }; Random* clone(map<string,string> &_settings) { return new Random(_settings);}; const float output(const Time_spec &time) { @@ -249,6 +251,28 @@ namespace Rotor { uint32_t seed; private: }; + class Noise: public Signal_node { + //fractal noise + public: + Noise(){}; + Noise(map<string,string> &settings) { + base_settings(settings); + seed=find_setting(settings,"seed",0); + }; + Noise* clone(map<string,string> &_settings) { return new Noise(_settings);}; + const float output(const Time_spec &time) { + if (inputs.size()) { + if (inputs[0]->connection) { + float o=(((Signal_node*)inputs[0]->connection)->get_output(time)); + + return o; + } + } + return 0.0f; + } + uint32_t seed; + private: + }; } #endif
\ No newline at end of file |
