From 668077a990bb8f09d3e34b37b63cfd58e82a50f9 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 9 Aug 2013 17:43:30 +0100 Subject: working on noise node --- rotord/src/nodes_maths.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 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 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 +#include 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 &settings) { base_settings(settings); seed=(Seed+find_setting(settings,"seed",0)); - cerr<<"random:: seed "< &_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 &settings) { + base_settings(settings); + seed=find_setting(settings,"seed",0); + }; + Noise* clone(map &_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 -- cgit v1.2.3