From 06848f0cc48de1d7fa0f06636adeb1d30faf10de Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 15 May 2013 15:54:27 +0100 Subject: all ready for new sins render --- rotord/01.xml | 2 +- rotord/04.xml | 8 ++--- rotord/05.xml | 46 ++++++++++++++++++++++++++++ rotord/06.xml | 29 ++++++++++++++++++ rotord/rendercontext.cpp | 4 +-- rotord/rotor.cpp | 15 ++++++--- rotord/rotor.h | 79 ++++++++++++++++++++++++++++++++++++------------ 7 files changed, 151 insertions(+), 32 deletions(-) create mode 100644 rotord/05.xml create mode 100644 rotord/06.xml diff --git a/rotord/01.xml b/rotord/01.xml index 29d709e..dd34ed8 100755 --- a/rotord/01.xml +++ b/rotord/01.xml @@ -5,7 +5,7 @@ on off signal 1 to make on off - performance video + performance video invert video invert signal diff --git a/rotord/04.xml b/rotord/04.xml index 7552ae3..b7b38e5 100644 --- a/rotord/04.xml +++ b/rotord/04.xml @@ -2,13 +2,13 @@ Sample template ©Rotor 2013 beats - performance video + performance video - performance video + performance video - performance video + performance video - performance video + performance video video cycler switching signal diff --git a/rotord/05.xml b/rotord/05.xml new file mode 100644 index 0000000..93191dd --- /dev/null +++ b/rotord/05.xml @@ -0,0 +1,46 @@ + +Sample template ©Rotor 2013 + beats + + segmentation + + fraction of audio track + + comparison + comparison signal + + arithmetic + arithmetic signal + value control + + comparison + comparison signal + + divide + signal to divide + + performance video + + performance video + + video cycler + switching signal + image to switch + image to switch + + echo trails + image input + mode control + + divide + signal to divide + + video cycler + switching signal + image to switch + image to switch + + video output + image to output + + diff --git a/rotord/06.xml b/rotord/06.xml new file mode 100644 index 0000000..1794914 --- /dev/null +++ b/rotord/06.xml @@ -0,0 +1,29 @@ + +Testing parameter controls ©Rotor 2013 + beats + + on off + signal 1 to make on off + + performance video + + fraction of audio track + + arithmetic + arithmetic signal + + arithmetic + arithmetic signal + + arithmetic + arithmetic signal + value control + + luma levels + image input + white_out control + + video output + image to output + + diff --git a/rotord/rendercontext.cpp b/rotord/rendercontext.cpp index fc5936b..624b7c1 100644 --- a/rotord/rendercontext.cpp +++ b/rotord/rendercontext.cpp @@ -451,8 +451,8 @@ bool Render_context::load_video(const string &nodeID,const string &filename){ //this is a good standard example of how to find //a node of a specific type by ID and do something if (graph.nodes.find(nodeID)!=graph.nodes.end()){ - if (graph.nodes[nodeID]->type=="video_input") { - if (((Video_input*)graph.nodes[nodeID])->load(filename)) { + if (graph.nodes[nodeID]->type=="video_loader") { + if (((Video_loader*)graph.nodes[nodeID])->load(filename)) { return true; } } diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index 59a1697..52c76df 100755 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -12,7 +12,7 @@ Node_factory::Node_factory(){ add_type("signal_output",new Signal_output()); add_type("testcard",new Testcard()); add_type("video_output",new Video_output()); - add_type("video_input",new Video_input()); + add_type("video_loader",new Video_loader()); add_type("on_off",new On_off()); add_type("invert",new Invert()); add_type("video_cycler",new Video_cycler()); @@ -30,6 +30,11 @@ bool Signal_input::connect(Signal_node* source) { } else return false; } +void Parameter_input::update(const Time_spec& time){ //gets input and updates variable + if (receiver){ + *receiver=((Signal_node*)connection)->get_output(time); + } +} bool Image_input::connect(Image_node* source) { if (source->output_type=="image") { connection=(Node*)source; @@ -215,7 +220,7 @@ bool Video_output::render(const float duration, const float framerate,const stri return false; } -bool Video_input::load(const string &filename){ +bool Video_loader::load(const string &filename){ //gstreamer needs absolute paths ALWAYS //string uri="file:///home/tim/workspace/rotor/rotord/"+filename; Poco::Path path; @@ -226,13 +231,13 @@ bool Video_input::load(const string &filename){ player->setPaused(true); player->setFrameByFrame(true); player->update(); - cerr<<"Rotor::Video_input loaded "<getDuration()<<" seconds "<<", "<getWidth()<<"x"<getHeight()<getDuration()<<" seconds "<<", "<getWidth()<<"x"<getHeight()<setup_fromRGB(player->getWidth(),player->getHeight(),(uint8_t*) player->getPixels()); return true; } return false; } -Image* Video_input::get_output(const Frame_spec &frame){ +Image* Video_loader::output(const Frame_spec &frame){ //wonder about the actual mechanism used by gstreamer //have to implment callback when seek is ready? //presume gstreamer caches a loaded frame? @@ -260,7 +265,7 @@ Image* Video_input::get_output(const Frame_spec &frame){ //} player->update(); image->RGBdata=player->getPixels(); //don't really know why this is needed every frame - //cerr<<"Video_input: retrieving frame "<<((int) (frame.time*frame.framerate))< @@ -210,6 +212,18 @@ namespace Rotor { } return *this; } + Image & add_wrap(const Image &other) { + if (other.w!=w||other.h!=h) { + cerr<<"Rotor: cannot add images with different sizes! (wanted "<setup(w,h); @@ -264,11 +278,7 @@ namespace Rotor { public: Parameter_input(const string &_param,const string &_desc): Signal_input(_desc),receiver(nullptr),parameter(_param){}; float *receiver; - void update(const Time_spec& time){ //gets input and updates variable - if (receiver){ - *receiver=((Signal_node*)connection)->get_output(time); - } - } + void update(const Time_spec& time); string parameter; }; class Node{ @@ -304,7 +314,8 @@ namespace Rotor { public: vector image_inputs; //image node also has image inputs and outputs void create_image_input(const string &description) {image_inputs.push_back(new Image_input(description));}; - virtual Image *get_output(const Frame_spec &frame)=0; + Image *get_output(const Frame_spec &frame) { update_params((Time_spec)frame); return output(frame); }; + virtual const Image *output(const Frame_spec &frame)=0; Image *get_preview(const Frame_spec &frame); Image *image; //this can be privately allocated or just passed on as the node see fit private: @@ -382,6 +393,9 @@ namespace Rotor { if (_op=="<") op=COMPARISON_Less; if (_op==">=") op=COMPARISON_Greater_or_equal; if (_op=="<=") op=COMPARISON_Less_or_equal; + for (auto p:parameter_inputs){ + if (p->parameter=="value") p->receiver=&value; + } }; Comparison* clone(map &_settings) { return new Comparison(_settings);}; const float output(const Time_spec &time) { @@ -432,6 +446,9 @@ namespace Rotor { if (_op=="*") op=ARITHMETIC_multiply; if (_op=="/") op=ARITHMETIC_divide; if (_op=="%") op=ARITHMETIC_modulo; + for (auto p:parameter_inputs){ + if (p->parameter=="value") p->receiver=&value; + } }; Arithmetic* clone(map &_settings) { return new Arithmetic(_settings);}; const float output(const Time_spec &time) { @@ -468,6 +485,9 @@ namespace Rotor { Signal_divide(map &settings) { base_settings(settings); divide_amount=ofToFloat(find_setting(settings,"amount")); + for (auto p:parameter_inputs){ + if (p->parameter=="divide_amount") p->receiver=÷_amount; + } }; Signal_divide* clone(map &_settings) { return new Signal_divide(_settings);}; const float output(const Time_spec &time) { @@ -537,7 +557,7 @@ namespace Rotor { }; ~Testcard(){ delete image;}; Testcard* clone(map &_settings) { return new Testcard(_settings);}; - Image *get_output(const Frame_spec &frame){ + Image *output(const Frame_spec &frame){ if (image->setup(frame.w,frame.h)) { } @@ -567,7 +587,7 @@ namespace Rotor { }; ~Invert(){ delete image;}; Invert* clone(map &_settings) { return new Invert(_settings);}; - Image *get_output(const Frame_spec &frame){ + Image *output(const Frame_spec &frame){ if (inputs.size()) { if (image_inputs[0]->connection){ if (inputs[0]->connection) { @@ -602,7 +622,7 @@ namespace Rotor { exporter=new libav::Exporter(); }; ~Video_output(){ delete exporter; }; - Image *get_output(const Frame_spec &frame){ + Image *output(const Frame_spec &frame){ if (image_inputs[0]->connection) { return ((Image_node*)(image_inputs[0]->connection))->get_output(frame); } @@ -616,21 +636,21 @@ namespace Rotor { libav::Exporter *exporter; libav::Audioloader audioloader; }; - class Video_input: public Image_node { + class Video_loader: public Image_node { //video input using gstreamer //seems slow //TODO: scaling public: - Video_input(){}; - Video_input(map &settings) { + Video_loader(){}; + Video_loader(map &settings) { base_settings(settings); player=new ofGstVideoPlayer(); image=new Image(); }; - ~Video_input(){ delete player; delete image;}; + ~Video_loader(){ delete player; delete image;}; bool load(const string &filename); - Image *get_output(const Frame_spec &frame); - Video_input* clone(map &_settings) { return new Video_input(_settings);}; + Image *output(const Frame_spec &frame); + Video_loader* clone(map &_settings) { return new Video_loader(_settings);}; private: ofGstVideoPlayer *player; Image *image; @@ -644,7 +664,7 @@ namespace Rotor { }; ~Video_cycler(){}; bool load(const string &filename); - Image *get_output(const Frame_spec &frame){ + Image *output(const Frame_spec &frame){ int which_input=0; if (inputs[0]->connection) { which_input=((int)((Signal_node*)inputs[0]->connection)->get_output((Time_spec)frame))%image_inputs.size(); @@ -667,6 +687,13 @@ namespace Rotor { base_settings(settings); levels_settings(settings); image=new Image(); + for (auto p:parameter_inputs){ + if (p->parameter=="black_in") p->receiver=&black_in; + if (p->parameter=="white_in") p->receiver=&white_in; + if (p->parameter=="gamma") p->receiver=γ + if (p->parameter=="black_out") p->receiver=&black_out; + if (p->parameter=="white_out") p->receiver=&white_out; + } }; ~Luma_levels(){if (LUT) {delete[] LUT;} if (image) {delete image;} }; void levels_settings(map &settings){ @@ -695,7 +722,7 @@ namespace Rotor { out.RGBdata[i]=LUT[in.RGBdata[i]]; } } - Image *get_output(const Frame_spec &frame){ + Image *output(const Frame_spec &frame){ if (image_inputs.size()) { if (image_inputs[0]->connection){ if (LUT) { @@ -710,7 +737,6 @@ namespace Rotor { protected: unsigned char *LUT; Image *image; - private: float black_in,white_in,gamma,black_out,white_out; }; class Echo_trails: public Luma_levels { @@ -751,9 +777,20 @@ namespace Rotor { levels_settings(settings); image=new Image(); lastframe=-1; + mode=find_setting(settings,"mode",0.0f); + for (auto p:parameter_inputs){ + if (p->parameter=="black_in") p->receiver=&black_in; + if (p->parameter=="white_in") p->receiver=&white_in; + if (p->parameter=="gamma") p->receiver=γ + if (p->parameter=="black_out") p->receiver=&black_out; + if (p->parameter=="white_out") p->receiver=&white_out; + + //TODO: control an integer + if (p->parameter=="mode") p->receiver=&mode; + } }; ~Echo_trails(){if (image) {delete image;} }; - Image *get_output(const Frame_spec &frame){ + Image *output(const Frame_spec &frame){ //check if cache is valid if (frame.w!=image->w||frame.h!=image->h){ //or framerate changed? //clear cache and start over @@ -801,7 +838,8 @@ namespace Rotor { //cerr<<"Rotor: about to apply image ("<add_wrap(*temp); delete temp; } else (*image)+=*images[absframe]; @@ -824,6 +862,7 @@ namespace Rotor { int number; int interval,total,lastframe; //number of frames between displayed echoes unordered_map images; + float mode; //TODO make int, enum string parameter types }; //------------------------------------------------------------------- class Node_factory{ -- cgit v1.2.3