diff options
Diffstat (limited to 'rotord/src/rotor.h')
| -rw-r--r-- | rotord/src/rotor.h | 66 |
1 files changed, 54 insertions, 12 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index e882c05..75e7914 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -64,6 +64,13 @@ Requirements this is why I think Sasha's video is the most succesful attempt so far- it takes a recognisable style that people understand and deconstructs it. + + + + + http://www.ogre3d.org/forums/viewtopic.php?f=16&t=52936 + chaiscript binding to cairo + -------------------------*/ @@ -179,6 +186,8 @@ namespace Rotor { Node* connection; string description; string title; + virtual float get_time_used()=0; + virtual float get_time_taken()=0; }; class Image_input: public Input{ public: @@ -188,6 +197,8 @@ namespace Rotor { connect(_connect); }; Image* get(const Frame_spec& time); + float get_time_used(); + float get_time_taken(); }; class Signal_input: public Input{ public: @@ -197,6 +208,8 @@ namespace Rotor { connect(_connect); }; float get(const Time_spec& time); + float get_time_used(); + float get_time_taken(); }; class Parameter: public Signal_input{ public: @@ -258,6 +271,7 @@ namespace Rotor { description=_desc; title=_title; type="lyrics"; + blank_response=""; }; void init(const std::map<float,std::pair<string,float> > _lyrics){ lyrics=_lyrics; @@ -273,10 +287,11 @@ namespace Rotor { //cerr<<(time.time)<<" "<<l->second.first<<","<<(l->first)<<" ("<<(l->second.second)<<")"<<endl; if ((time.time>l->first)&&((time.time-l->first) < l->second.second)) return l->second.first; } - return ""; + return blank_response; } private: std::map<float,std::pair<string,float> > lyrics; //lyrics[startime]=pair<lyric,endtime> + std::string blank_response; }; class Node{ public: @@ -344,6 +359,7 @@ namespace Rotor { } } void update(const Time_spec &time){ + gettimeofday(&frame_time, NULL); for (auto p: parameters){ p.second->get(time); } @@ -351,18 +367,38 @@ namespace Rotor { void set_parameter(const std::string &key,const std::string &value){ if (parameters.find(key)!=parameters.end()) parameters[key]->value=toFloat(value); }; + void reset_timer(){ + time_taken=0.0f; + } + void time_frame(){ + struct timeval end_time; + gettimeofday(&end_time, NULL); + time_taken+=((end_time.tv_sec-frame_time.tv_sec) + (end_time.tv_usec-frame_time.tv_usec)/1000000.0); + } + virtual float get_time_used()=0; + float time_taken; + protected: + struct timeval frame_time; }; class Signal_node: public Node{ public: virtual ~Signal_node(){}; const float get_output(const Time_spec &time) { update(time); - return output(time); + float o=output(time); + time_frame(); + return o; }; const float get_time_for_value(const float &value) { return 0.0f; }; virtual const float output(const Time_spec &time) { return 0.0f; }; + float get_time_used(){ + float t=time_taken; + for (auto i:inputs) t-=i->get_time_taken(); + for (auto p:parameters) t-=p.second->get_time_taken(); + return t; + } }; class Image_node: public Node{ public: @@ -374,12 +410,21 @@ namespace Rotor { image_inputs.push_back(new Image_input(_desc,_title,_connect)); }; Image *get_image_output(const Frame_spec &frame) { - image.setup(frame.w,frame.h); update((Time_spec)frame); - return output(frame); + image.setup(frame.w,frame.h); + Image *i=output(frame); + time_frame(); + return i; } virtual Image *output(const Frame_spec &frame)=0; Image image; + float get_time_used(){ + float t=time_taken; + for (auto i:inputs) t-=i->get_time_taken(); + for (auto p:parameters) t-=p.second->get_time_taken(); + for (auto i:image_inputs) t-=i->get_time_taken(); + return t; + } private: float image_time; //? could be used to detect image reuse? @@ -519,8 +564,8 @@ namespace Rotor { } } lastframe=thisframe; - float start_time=(((Time_spec)frame).time-segment_start); - float end_time=(((Time_spec)frame).time-segment_end); + //float start_time=(((Time_spec)frame).time-segment_start); + //float end_time=(((Time_spec)frame).time-segment_end); float in_time=(((Time_spec)frame).time-segment_start); //time in seconds for the incoming sequence: starts at 0 @@ -799,7 +844,6 @@ namespace Rotor { } } if (isLoaded){ - int tests=0; int wanted=0.0f; int thisframe=((Time_spec)frame).frame(); float clipframerate=(parameters["framerate"]->value==0.0f?player.get_framerate():parameters["framerate"]->value); @@ -844,9 +888,7 @@ namespace Rotor { return nullptr; } Video_bank* clone(map<string,string> &_settings) { return new Video_bank(_settings);}; - ~Video_bank(){ - - }; + ~Video_bank(){}; private: int clip_loaded; float segment_start; @@ -909,11 +951,11 @@ namespace Rotor { amount = 1.0f-((track_time-end_peak)/(end_silence-end_peak)); } } - if (amount<(1.0f/254.0f)){ + if (amount<(1.0f/256.0f)){ image.clear(); } image=(*in); - if (amount<1.0f){ + if (amount<(255.0f/256.0f)){ image*=amount; } //seems to be outputting correctly but not saving frames |
