diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-10-03 13:19:39 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-10-03 13:19:39 +0100 |
| commit | d845da50c89f9276af76829c4a95b5e1f631a85a (patch) | |
| tree | 1335b87d13606eae69c5ae05f313ce470dad9a0a /rotord/src/rotor.h | |
| parent | 951c4b40a74b87b6467770ba369e9b2e74941339 (diff) | |
fix transform Y label
Diffstat (limited to 'rotord/src/rotor.h')
| -rw-r--r-- | rotord/src/rotor.h | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index d1e42a9..baf5615 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -408,7 +408,7 @@ namespace Rotor { #define CYCLER_mix 2 //new mode that remaps sequence length to segments //combined with a video mode that maps video length to duration - //or + //or class Video_cycler: public Image_node { public: Video_cycler(){ @@ -608,7 +608,7 @@ namespace Rotor { image=image.add_wrap(*in2); break; case BLEND_blend: //has to be last because of initialser of *in? go figure - + image*=(1.0f-parameters["amount"]->value); /* //problem here with leak //opencv handles not being released @@ -882,13 +882,19 @@ namespace Rotor { }; #define VIDEOFRAMES_frame 1 #define VIDEOFRAMES_blend 2 +#define VIDEOTIME_play 1 +#define VIDEOTIME_stretch 2 + //relative timelines used to stretch video + //1. make a video position input for video node - seconds and stretch modes + //2. video mode that maps to duration- timeline remapping from cycler and others class Video_loader: public Image_node { public: Video_loader(){ create_parameter("speed","number","video playback speed","Speed",1.0f,0.0f,0.0f); create_parameter("framerate","number","framerate override","Frame rate",0.0f,0.0f,0.0f); create_attribute("filename","name of video file to load","File name",""); - create_attribute("mode","frame mode","Mode","frame",{"frame","blend"}); + create_attribute("frame_mode","frame mode","Frame mode","frame",{"frame","blend"}); + create_attribute("time_mode","time mode","Time mode","play",{"play","stretch"}); title="Video loader"; description="Loads a video file"; }; @@ -898,7 +904,7 @@ namespace Rotor { if (attributes["filename"]->value!="") { load(find_setting(settings,"media_path","")+attributes["filename"]->value); } - + }; ~Video_loader(){}; bool load(const string &filename){ @@ -924,8 +930,16 @@ namespace Rotor { if (isLoaded){ float clipframerate=(parameters["framerate"]->value==0.0f?player.get_framerate():parameters["framerate"]->value); float clipspeed=(clipframerate/frame.framerate)*parameters["speed"]->value; - if (attributes["mode"]->intVal==VIDEOFRAMES_blend){ - float wanted=fmod(frame.time*frame.framerate*clipspeed,(float)player.get_number_frames()); + float wanted; + switch (attributes["frame_mode"]->intVal){ + case VIDEOTIME_play: + wanted=fmod(frame.time*frame.framerate*clipspeed,(float)player.get_number_frames()); + break; + case VIDEOTIME_stretch: + wanted=fmod(frame.time*frame.framerate*clipspeed,(float)player.get_number_frames()); + break; + } + if (attributes["frame_mode"]->intVal==VIDEOFRAMES_blend){ if (((int)wanted)!=lastframe){ //get a new pair of frames possibly by switching the next one //darn peculiar, as if copying wasn't actually copying @@ -953,9 +967,8 @@ namespace Rotor { image+=in2t; } else { - int wanted=(((int) ((frame.time*frame.framerate*clipspeed)+0.5))%max(1,player.get_number_frames())); - if (wanted!=lastframe){ - if (!player.fetch_frame(frame.w,frame.h,wanted)) { //seek fail + if (((int)wanted)!=lastframe){ + if (!player.fetch_frame(frame.w,frame.h,((int)wanted))) { //seek fail Poco::Logger& logger = Poco::Logger::get("Rotor"); logger.error("Video_loader failed to seek frame "+toString(wanted)+" of "+attributes["filename"]->value); @@ -1017,7 +1030,7 @@ namespace Rotor { float amount=1.0f; float track_time=frame.time/frame.duration; if (attributes["begin_mode"]->value=="fade peak"||attributes["begin_mode"]->value=="blank silence"){ - if (track_time<start_silence){ + if (track_time<start_silence){ amount=0.0f; } else if (track_time<start_peak&&attributes["begin_mode"]->value=="fade peak"&&start_peak>start_silence){ @@ -1025,7 +1038,7 @@ namespace Rotor { } } if (attributes["end_mode"]->value=="fade peak"||attributes["end_mode"]->value=="blank silence"){ - if (track_time>end_silence){ + if (track_time>end_silence){ amount=0.0f; } else if (track_time>end_peak&&attributes["end_mode"]->value=="fade peak"&&end_silence>end_peak){ @@ -1045,7 +1058,7 @@ namespace Rotor { return nullptr; }; Video_output* clone(map<string,string> &_settings) { return new Video_output(_settings);}; - + private: float silence_threshold; float start_silence; |
