summaryrefslogtreecommitdiff
path: root/rotord/src/nodes_maths.h
diff options
context:
space:
mode:
authorTim Redfern <tim@herge.(none)>2013-08-09 17:43:30 +0100
committerTim Redfern <tim@herge.(none)>2013-08-09 17:43:30 +0100
commit668077a990bb8f09d3e34b37b63cfd58e82a50f9 (patch)
tree6ec6bdff6e20ea8a1da57f5fd99f411a2715eec5 /rotord/src/nodes_maths.h
parent135823808575cc376e4c011cc9f78f15fbf5971b (diff)
working on noise node
Diffstat (limited to 'rotord/src/nodes_maths.h')
-rw-r--r--rotord/src/nodes_maths.h28
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