diff options
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/src/graph.cpp | 8 | ||||
| -rw-r--r-- | rotord/src/nodes_audio_analysis.h | 5 | ||||
| -rw-r--r-- | rotord/src/nodes_maths.h | 42 | ||||
| -rw-r--r-- | rotord/src/vampHost.cpp | 8 |
4 files changed, 46 insertions, 17 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 737aeab..5d8d368 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -31,14 +31,14 @@ bool Graph::signal_render(xmlIO &XML,const string &node,const float framerate) { //return signal_output->render(duration,framerate,signal_xml); XML.addValue("signal_duration",duration); XML.addValue("signal_framerate",framerate); - float sig=0.0f; + //float sig=0.0f; string val=""; for (float i=0;i<duration;i+=1.0f/framerate){ float s=(signal_output->get_output(Time_spec(i,framerate,duration))); - if (!fequal(sig,s)){ + //if (!fequal(sig,s)){ val+=toString(i)+" "+toString(s)+","; - sig=s; - } + // sig=s; + //} } XML.addValue("signal",val); return true; diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h index aa0aeb0..8cb70d0 100644 --- a/rotord/src/nodes_audio_analysis.h +++ b/rotord/src/nodes_audio_analysis.h @@ -57,7 +57,7 @@ namespace Rotor { const float output(const Time_spec &time) { if (features.size()) { auto i=features.upper_bound(time.time); //the first element in the container whose key is considered to go after k - if (i!=features.end()){ + if (i==features.end()) i--; float uk=i->first; float v1,v2; v1=v2=0.0f; @@ -76,7 +76,8 @@ namespace Rotor { case VAMPHOST_Values: return v1; } - } + //} + //return (--features.end())->second.values[0]; } return 0.0f; } diff --git a/rotord/src/nodes_maths.h b/rotord/src/nodes_maths.h index 4c81f7b..2bf8b48 100644 --- a/rotord/src/nodes_maths.h +++ b/rotord/src/nodes_maths.h @@ -5,6 +5,7 @@ #include <libnoise/noise.h> #include <libnoise/mathconsts.h> #include "Poco/Logger.h" +#include "mtrand.h" using namespace noise; @@ -94,6 +95,7 @@ namespace Rotor { 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) { float in= inputs[0]->get(time); + int inint; //this old chestnut switch (attributes["operator"]->intVal) { case ARITHMETIC_plus: return in+parameters["value"]->value; @@ -108,8 +110,10 @@ namespace Rotor { return in/parameters["value"]->value; break; case ARITHMETIC_modulo: + //cerr <<in<<" % "<<parameters["value"]->value<<" = "<<fmod(in,parameters["value"]->value)<<endl; return fmod(in,parameters["value"]->value); - break; + //return (((int)in)%12); //+(in-((int)in)); + break; case ARITHMETIC_pow: return pow(in,parameters["value"]->value); break; @@ -206,6 +210,20 @@ namespace Rotor { hash = fnv1a(*ptr++, hash); return fnv1a(*ptr , hash); } + uint32_t hash( uint32_t a) + { + a = (a+0x7ed55d16) + (a<<12); + a = (a^0xc761c23c) ^ (a>>19); + a = (a+0x165667b1) + (a<<5); + a = (a+0xd3a2646c) ^ (a<<9); + a = (a+0xfd7046c5) + (a<<3); + a = (a^0xb55a4f09) ^ (a>>16); + + a -= (a>>1); + + return a; + } + class Random: public Signal_node { public: Random(){ @@ -214,18 +232,29 @@ namespace Rotor { create_signal_input("signal","Signal"); create_parameter("seed","number","Seed value","Seed",1.0f); NODEID="1de86932-2d0b-11e3-96d3-77aa4558e6cd"; + std::uniform_int_distribution<> d(-9999, 9999); }; Random(map<string,string> &settings):Random() { base_settings(settings); }; Random* clone(map<string,string> &_settings) { return new Random(_settings);}; const float output(const Time_spec &time) { - uint32_t seed=Seed+parameters["seed"]->value; - //hash the integer part and add the fractional part back on - float o=inputs[0]->get(time); + + float o; + if (inputs[0]->connection){ + o=inputs[0]->get(time); + } + else o=time.time; uint32_t m=(int)o; - return ((float)(fnv1a(m,seed)%((uint32_t)time.duration)))+(o-m); + PRNG.seed(m^(int)parameters["seed"]->value); + return ((float)(PRNG()&0xf))+(o-m); + + //uint32_t seed=Seed+parameters["seed"]->value; + //hash the integer part and add the fractional part back on + // + //return ((float)(fnv1a(m,seed)))+(o-m); //%((uint32_t)time.duration)) } + MTRand_int32 PRNG; }; class Noise: public Signal_node { //fractal noise @@ -253,9 +282,8 @@ namespace Rotor { } return perlin.GetValue(time.time,0,0)*parameters["scale"]->value; } - uint32_t seed; private: - module::RidgedMulti perlin; + module::Perlin perlin; }; } diff --git a/rotord/src/vampHost.cpp b/rotord/src/vampHost.cpp index 08984cf..e2b1e63 100644 --- a/rotord/src/vampHost.cpp +++ b/rotord/src/vampHost.cpp @@ -384,10 +384,10 @@ void vampHost::Analyser::cleanup(){ } //make a final feature at the end - feature f; - f.number=featureNo; - f.values={0}; - features[((float)rt.sec)+(((float)rt.nsec)*.000000001f)]=f; + //feature f; + //f.number=featureNo; + //f.values={0}; + //features[((float)rt.sec)+(((float)rt.nsec)*.000000001f)]=f; //cerr<<plugin->getIdentifier()<<" found "<<(features.size()-1)<<" features"<<endl; //deal with left over data? |
