From 4aa8f7c20c5e8bbe1ed9b007a1193ced8b019f4d Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 2 May 2013 18:35:29 +0100 Subject: include problems - added makde Clang for clarity --- rotord/rotor.h | 123 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 63 insertions(+), 60 deletions(-) (limited to 'rotord/rotor.h') diff --git a/rotord/rotor.h b/rotord/rotor.h index 2915fb6..441be2f 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -1,48 +1,7 @@ /* -requirement driven design - -do we store graphs as files or in a db with UUID as key? - -we traverse the graph as recursive function calls until we satisfy all dependencies - -NO NODE HAS MORE THAN ONE OUTPUT -WE DON'T LINK TO AN OUTPUT OBJECT WE LINK TO THE NODE - GET_OUTPUT IS THE RENDER FUNCTION -MORE THAN ONE NODE CAN LINK THE SAME OUTPUT -NODES CACHE AT LEAST ONE FRAME - -??the only node with more than 1 output is audio? -??lets rethink this -??audio analysis nodes can be seperate - they can all load from the same audio file - were gonna have to process each pass -??output splitter? channel splitter? these can be done as 1 object per channel? -??I think so - -settings - how do we deal with settings being controllable -signal inputs can have a gui representation as well -other gui items don't have an input - -scaling to come - -time is always in floating points seconds - time has to be requested when rendering - either a preview -what about testing a float for equality? -maybe we should look at time in int (frames) - - what does this imply -is it easier to have a function like: -bool Same_frame(float time1, float time2); - -nb where a signal enters a channel comp input - it is duplicated - so nodes should cache a value (more for time effects) - -sql stuff - -NB best way to use is: interface uploads audio and makes thumbnail: graph determines what kind of audio analysis is used by referring to plugins -jesus where is it hanging in the frigging debugger - -GOOD GOOD GOOD - -next - build signal_output and make a working chain with dummy data - - - -main definitions of libavcodec.h are in utils.c +nodes can have many inputs but only 1 output +image nodes that use an image as input can pass on the incoming image only if its unchanged. */ #include @@ -69,6 +28,7 @@ main definitions of libavcodec.h are in utils.c #include "Poco/Path.h" #include + using Poco::UUID; using Poco::UUIDGenerator; using Poco::Net::HTTPResponse; @@ -116,6 +76,20 @@ namespace Rotor { #define PREVIEW 2 #define RENDER 3 +#ifndef FEQUAL +//float equality +bool fequal(const float u,const float v){ + if (abs(u-v)<.001) return true; + else return false; +}; +bool flessorequal(const float u,const float v){ + //v is less or equal to u + if (u-v>-.001) return true; + else return false; +}; +#define FEQUAL +#endif + //forward declaration class Node; class Signal_node; @@ -209,11 +183,11 @@ namespace Rotor { }; class Time_spec{ public: - Time_spec(float _seconds,float _framerate){ seconds=_seconds; framerate=_framerate; }; - float seconds; + Time_spec(float _time,float _framerate){ time=_time; framerate=_framerate; }; + float time; float framerate; - Time_spec lastframe(){ - return Time_spec(seconds-(1.0f/framerate),framerate); + Time_spec lastframe() const{ + return Time_spec(time-(1.0f/framerate),framerate); } }; class Frame_spec{ @@ -244,7 +218,7 @@ namespace Rotor { }; class Input{ public: - Input(const string &_desc): description(_desc),connection(nullptr){}; + Input(const string &_desc): connection(nullptr),description(_desc){}; Node* connection; string description; }; @@ -280,7 +254,7 @@ namespace Rotor { }; class Signal_node: public Node{ public: - virtual float get_output(const Time_spec &time) { return 0.0f; }; + virtual const float get_output(const Time_spec &time) { return 0.0f; }; }; class Image_node: public Node{ public: @@ -313,15 +287,15 @@ namespace Rotor { bool init(int _channels,int _bits,int _samples,int _rate); void cleanup(); int process_frame(uint8_t *data,int samples_in_frame); - float get_output(const Time_spec &time) { + const float get_output(const Time_spec &time) { if (analyser.features.size()) { - auto i=analyser.features.lower_bound(time.seconds); + auto i=analyser.features.lower_bound(time.time); if (i!=analyser.features.end()){ float lk=i->first; int ln=i->second; if (i++!=analyser.features.end()){ float uk=i->first; - return (((time.seconds-lk)/(uk-lk))+ln); + return (((time.time-lk)/(uk-lk))+ln); } else return (float)ln; } @@ -342,10 +316,12 @@ namespace Rotor { divide_amount=ofToFloat(check(settings,"amount")); }; Signal_divide* clone(map &_settings) { return new Signal_divide(_settings);}; - float get_output(const Time_spec &time) { - if (inputs[0]->connection) { - return (((Signal_node*)inputs[0]->connection)->get_output(time))/divide_amount; - } + const float get_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 (((Signal_node*)inputs[0]->connection)->get_output(time))/divide_amount; + } + } return 0.0f; } float divide_amount; @@ -357,7 +333,7 @@ namespace Rotor { base_settings(settings); }; Is_new_integer* clone(map &_settings) { return new Is_new_integer(_settings);}; - float get_output(const Time_spec &time) { + const float get_output(const Time_spec &time) { if (inputs[0]->connection) { float s1=(((Signal_node*)(inputs[0]->connection))->get_output(time)); float s2=(((Signal_node*)(inputs[0]->connection))->get_output(time.lastframe())); @@ -376,7 +352,7 @@ namespace Rotor { }; Signal_output* clone(map &_settings) { return new Signal_output(_settings);}; bool render(const float duration, const float framerate,string &xml_out); - float get_output(const Time_spec &time) { + const float get_output(const Time_spec &time) { if (inputs[0]->connection) { return ((Signal_node*)(inputs[0]->connection))->get_output(time); } @@ -394,10 +370,10 @@ namespace Rotor { Testcard* clone(map &_settings) { return new Testcard(_settings);}; Image *get_output(const Frame_spec &frame){ if (image->setup(frame.w,frame.h)) { - + } //always create testcard - float ws=(255.0f/frame.w); + //float ws=(255.0f/frame.w); float hs=(255.0f/frame.h); for (int i=0;i &settings) { + base_settings(settings); + image=new Image(); + }; + ~Invert(){ delete image;}; + Invert* clone(map &_settings) { return new Invert(_settings);}; + Image *get_output(const Frame_spec &frame){ + if (inputs.size()) { + if (inputs[0]->connection) { + Time_spec requested=Time_spec(frame.time,frame.framerate); + if (fequal((((Signal_node*)inputs[0]->connection)->get_output(requested)),1.0f)) { + //invert=!invert; + } + } + } + if (image_inputs[0]->connection) { + + } + return image; + } + private: + Image *image; //is an image generator + //bool invert; + }; class Video_output: public Image_node { public: Video_output(){}; -- cgit v1.2.3