diff options
| author | Comment <tim@gray.(none)> | 2013-12-05 01:36:58 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-12-05 01:36:58 +0000 |
| commit | 674173fb17ca25b1b35d6482de6f603cc3d8209c (patch) | |
| tree | fb651966aa14b4acc92d1355938575c10e2090f0 /rotord/src/rotor.h | |
| parent | 8cfc0a3581cad5da07da69b70c71e67256739166 (diff) | |
signal output
Diffstat (limited to 'rotord/src/rotor.h')
| -rw-r--r-- | rotord/src/rotor.h | 73 |
1 files changed, 59 insertions, 14 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 943464d..50fcef7 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -373,6 +373,7 @@ namespace Rotor { }; virtual void init_attribute(const string &attr){ }; + virtual void init(){}; //initialise any state variables that expect a linear render string description; string type; string ID; @@ -410,8 +411,9 @@ 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(){ + void reset(){ time_taken=0.0f; + int(); } void time_frame(){ struct timeval end_time; @@ -508,6 +510,15 @@ namespace Rotor { #define CYCLER_abs 1 #define CYCLER_rel 2 #define CYCLER_stretch 3 + + #define CYCLER_screen 3 + #define CYCLER_multiply 4 + #define CYCLER_alpha 5 + #define CYCLER_wrap 6 + #define CYCLER_xor 7 + #define CYCLER_overlay 8 + #define CYCLER_min 9 + #define CYCLER_max 10 //new mode that remaps sequence length to segments //combined with a video mode that maps video length to duration //time remapper object @@ -537,25 +548,26 @@ namespace Rotor { Video_cycler(){ create_image_input("Image input","Image input"); create_signal_input("Selector","Selector input"); - create_attribute("mode","Cycling mode","Mode","cut",{"cut","mix"}); - create_attribute("length_mode","Transition length mode","Length mode","seconds",{"seconds","fraction"}); + create_attribute("mode","Cycling mode","Mode","cut",{"cut","mix","screen","multiply","alpha","wrap","xor","overlay","min","max"}); + create_attribute("length_mode","Transition length mode","Length mode","fraction",{"seconds","fraction"}); create_attribute("time_mode","Time mode","time mode","absolute",{"absolute","relative"}); - create_parameter("transition_length","number","transition length","Transition length",-1.0f,0.0f,0.0f); + create_parameter("transition_length","number","transition length","Transition length",1.0f,0.0f,0.0f); title="Video cycler"; description="Cycles through video inputs according to selector signal"; duplicate_inputs=true; NODEID="93dd9d76-2d09-11e3-9589-5bbbeea1b304"; - segment=0; - segment_start=segment_end=0.0f; - prevseg=0; - prevseg_start=0.0f; - lastframe=0; } Video_cycler(map<string,string> &settings):Video_cycler() { base_settings(settings); }; ~Video_cycler(){}; bool load(const string &filename); + void init(){ + segment=0; + segment_start=0.0f; + prevseg_start=0.0f; + lastframe=0; + } Image *output(const Frame_spec &frame){ //work out timing @@ -575,6 +587,7 @@ namespace Rotor { while ((int)inputs[0]->get(testframe)==seg&&testframe.time<frame.duration){ testframe=testframe.nextframe(); } + //nextseg=(int)inputs[0]->get(testframe); segment_end=((Time_spec)testframe).time; //cerr<<"Video_cycler: segment "<<seg<<" preroll: "<<prevseg_start<<" start: "<<segment_start<<" end: "<<segment_end<<endl; } @@ -643,7 +656,7 @@ namespace Rotor { //awkward, its getting close to the point where we just need access to all of the segments data everywhere? //we have 2 times here - if (attributes["mode"]->intVal==CYCLER_mix&&image_inputs.size()>1){ + if (attributes["mode"]->intVal>=CYCLER_mix&&image_inputs.size()>1){ int im1=seg%image_inputs.size(); int im2=prevseg%image_inputs.size(); @@ -658,6 +671,8 @@ namespace Rotor { break; } + //cerr<<f<<" of input "<<(seg%image_inputs.size())<<" & "<<(1.0f-f)<<" of input "<<(prevseg%image_inputs.size())<<endl; + Image *in1=image_inputs[im1]->get(attributes["time_mode"]->intVal==CYCLER_abs?frame:inframe); if (in1){ @@ -668,7 +683,37 @@ namespace Rotor { image*=f; Image i2=(*in2); i2*=(1.0f-f); - image+=i2; + switch(attributes["mode"]->intVal){ + case CYCLER_screen: + image+=i2; + break; + case CYCLER_multiply: + image*=i2; + break; + case CYCLER_xor: + image^=i2; + break; + case CYCLER_alpha: + image=image.alpha_blend(i2); + break; + case CYCLER_wrap: + image=image.add_wrap(i2); + break; + case CYCLER_overlay: + image=image.overlay(i2); + break; + case CYCLER_min: + image=image.min(i2); + break; + case CYCLER_max: + image=image.max(i2); + break; + case CYCLER_mix: //has to be last because of initialser of *in? go figure + + image+=i2; + break; + } + return ℑ } } @@ -678,9 +723,9 @@ namespace Rotor { } //cut mode //for (uint32_t i=0;i<image_inputs.size();i++){ //this skipped a beat for some reason - int whichinput=(((int)inputs[0]->get((Time_spec)frame)))%image_inputs.size(); //+i - Image *in=image_inputs[whichinput]->get(inframe); - if (in) return in; + int whichinput=(((int)inputs[0]->get((Time_spec)frame)))%image_inputs.size(); //+i + Image *in=image_inputs[whichinput]->get(inframe); + if (in) return in; //} return nullptr; } |
