diff options
| author | Comment <tim@gray.(none)> | 2013-11-24 11:12:28 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-11-24 11:12:28 +0000 |
| commit | 0582c81b7499281cfd9e8643e763c7521a67aec9 (patch) | |
| tree | 109d275201454cc0031411042e981dc197b98f69 /rotord/src/rotor.h | |
| parent | b46286b8262cd5a4b96ac318a6d85d3db39e09e5 (diff) | |
analytics
Diffstat (limited to 'rotord/src/rotor.h')
| -rw-r--r-- | rotord/src/rotor.h | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 0833096..c86eae8 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,7 @@ namespace Rotor { Node* connection; string description; string title; + virtual float get_time_used()=0; }; class Image_input: public Input{ public: @@ -188,6 +196,7 @@ namespace Rotor { connect(_connect); }; Image* get(const Frame_spec& time); + float get_time_used(); }; class Signal_input: public Input{ public: @@ -197,6 +206,7 @@ namespace Rotor { connect(_connect); }; float get(const Time_spec& time); + float get_time_used(); }; class Parameter: public Signal_input{ public: @@ -258,6 +268,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 +284,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: @@ -343,6 +355,7 @@ namespace Rotor { } } void update(const Time_spec &time){ + gettimeofday(&frame_time, NULL); for (auto p: parameters){ p.second->get(time); } @@ -350,18 +363,37 @@ 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_used=0.0f; + } + void time_frame(){ + struct timeval end_time; + gettimeofday(&end_time, NULL); + time_used+=((end_time.tv_sec-frame_time.tv_sec) + (end_time.tv_usec-frame_time.tv_usec)/1000000.0); + } + virtual float get_time_used()=0; + protected: + float time_used; + 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_used; + for (auto i:inputs) t-=i->get_time_used(); + return t; + } }; class Image_node: public Node{ public: @@ -375,10 +407,18 @@ namespace Rotor { Image *get_image_output(const Frame_spec &frame) { image.setup(frame.w,frame.h); update((Time_spec)frame); - return output(frame); + 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_used; + for (auto i:inputs) t-=i->get_time_used(); + for (auto i:image_inputs) t-=i->get_time_used(); + return t; + } private: float image_time; //? could be used to detect image reuse? @@ -518,8 +558,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 @@ -798,7 +838,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); |
