diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-07-26 16:28:57 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-07-26 16:28:57 +0100 |
| commit | 6f7be98c7289aedd9e45f9fafcc67ac6348cebf2 (patch) | |
| tree | f0636df3c5c1b6d34ad0a5c62c8c52454220c32c | |
| parent | 0c2b109bcac035e5fd9370b78eecad7cf40793cc (diff) | |
refactoring to split nodes to seperate files
| -rw-r--r-- | rotord/cvimage.h | 5 | ||||
| -rw-r--r-- | rotord/nodes_audio_analysis.h | 47 | ||||
| -rwxr-xr-x | rotord/rotor.cpp | 5 | ||||
| -rwxr-xr-x | rotord/rotor.h | 92 |
4 files changed, 95 insertions, 54 deletions
diff --git a/rotord/cvimage.h b/rotord/cvimage.h index 44cbca8..81233a0 100644 --- a/rotord/cvimage.h +++ b/rotord/cvimage.h @@ -1,3 +1,6 @@ +#ifndef ROTOR_CVIMAGE +#define ROTOR_CVIMAGE + #include <math.h> #include <cv.h> @@ -181,3 +184,5 @@ namespace Rotor { cv::Mat alpha; }; } + +#endif
\ No newline at end of file diff --git a/rotord/nodes_audio_analysis.h b/rotord/nodes_audio_analysis.h new file mode 100644 index 0000000..e6c1e65 --- /dev/null +++ b/rotord/nodes_audio_analysis.h @@ -0,0 +1,47 @@ +#ifndef ROTOR_NODES_AUDIO_ANALYSIS +#define ROTOR_NODES_AUDIO_ANALYSIS + +#include "rotor.h" +#include "vampHost.h" + +namespace Rotor { + class Audio_analysis: public Base_audio_processor { + public: + Audio_analysis(){}; + Audio_analysis(map<string,string> &settings) { + base_settings(settings); + soname=find_setting(settings,"soname"); + id=find_setting(settings,"id"); + outputNo=find_setting(settings,"outputNo",0); + }; + Audio_analysis* clone(map<string,string> &_settings) { return new Audio_analysis(_settings);}; + bool init(int _channels,int _bits,int _samples,int _rate); + void cleanup(); + void set_parameter(const std::string &key,const std::string &value){params[key]=ofToFloat(value);}; + int process_frame(uint8_t *data,int samples_in_frame); + const float output(const Time_spec &time) { + if (analyser.features.size()) { + auto i=analyser.features.upper_bound(time.time); //the first element in the container whose key is considered to go after k + if (i!=analyser.features.end()){ + float uk=i->first; + i--; + float lk=i->first; + int ln=i->second; + return (((time.time-lk)/(uk-lk))+ln); + } + } + return 0.0f; + } + void print_features(); + void print_summary(){ + cerr<<"vamp plugin "<<id<<" of library "<<soname<<" found "<<analyser.features.size()<<" features "<<endl; + }; + private: + string soname,id; + int outputNo; + vampHost::Analyser analyser; + map <string,float> params; + }; +} + +#endif
\ No newline at end of file diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index f1c9575..d1865ee 100755 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -1,7 +1,5 @@ #include "rotor.h" - - - +#include "nodes_audio_analysis.h" using namespace Rotor; Node_factory::Node_factory(){ @@ -31,6 +29,7 @@ Node_factory::Node_factory(){ add_type("monochrome",new Monochrome()); add_type("transform",new Transform()); add_type("alpha_merge",new Alpha_merge()); + add_type("draw",new Draw()); } bool Signal_input::connect(Signal_node* source) { diff --git a/rotord/rotor.h b/rotord/rotor.h index 293d3fa..abba4cf 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -1,3 +1,5 @@ +#ifndef ROTOR_H +#define ROTOR_H /* nodes can have many inputs but only 1 output @@ -18,6 +20,7 @@ http://stackoverflow.com/questions/5261658/how-to-seek-in-ffmpeg-c-c #include <memory> #include <sys/time.h> #include <iostream> +//#include <cairo.h> #include "Poco/Net/HTTPServer.h" @@ -69,26 +72,23 @@ extern "C" { #define AUDIO_INBUF_SIZE 20480 #define AUDIO_REFILL_THRESH 4096 -#include "vampHost.h" #include "xmlIO.h" #include "utils.h" //fequal #include "libavwrapper.h" #include "cvimage.h" namespace Rotor { -#define IDLE 0 -#define ANALYSING_AUDIO 1 -#define AUDIO_READY 2 -#define CREATING_PREVIEW 3 -#define PREVIEW_READY 4 -#define RENDERING 5 -#define RENDER_READY 6 - -#define ANALYSE_AUDIO 1 -#define PREVIEW 2 -#define RENDER 3 - + #define IDLE 0 + #define ANALYSING_AUDIO 1 + #define AUDIO_READY 2 + #define CREATING_PREVIEW 3 + #define PREVIEW_READY 4 + #define RENDERING 5 + #define RENDER_READY 6 + #define ANALYSE_AUDIO 1 + #define PREVIEW 2 + #define RENDER 3 //forward declaration class Node; @@ -97,7 +97,7 @@ namespace Rotor { class Parameter_input; //http://blog.tomaka17.com/2012/03/libavcodeclibavformat-tutorial/ - struct Packet { + /* struct Packet { explicit Packet(AVFormatContext* ctxt = nullptr) { av_init_packet(&packet); packet.data = nullptr; @@ -123,6 +123,7 @@ namespace Rotor { AVPacket packet; }; + */ class Time_spec{ public: Time_spec(){}; @@ -262,43 +263,6 @@ namespace Rotor { int channels,bits,samples,rate; }; //actual nodes------------------------------------------------- - class Audio_analysis: public Base_audio_processor { - public: - Audio_analysis(){}; - Audio_analysis(map<string,string> &settings) { - base_settings(settings); - soname=find_setting(settings,"soname"); - id=find_setting(settings,"id"); - outputNo=find_setting(settings,"outputNo",0); - }; - Audio_analysis* clone(map<string,string> &_settings) { return new Audio_analysis(_settings);}; - bool init(int _channels,int _bits,int _samples,int _rate); - void cleanup(); - void set_parameter(const std::string &key,const std::string &value){params[key]=ofToFloat(value);}; - int process_frame(uint8_t *data,int samples_in_frame); - const float output(const Time_spec &time) { - if (analyser.features.size()) { - auto i=analyser.features.upper_bound(time.time); //the first element in the container whose key is considered to go after k - if (i!=analyser.features.end()){ - float uk=i->first; - i--; - float lk=i->first; - int ln=i->second; - return (((time.time-lk)/(uk-lk))+ln); - } - } - return 0.0f; - } - void print_features(); - void print_summary(){ - cerr<<"vamp plugin "<<id<<" of library "<<soname<<" found "<<analyser.features.size()<<" features "<<endl; - }; - private: - string soname,id; - int outputNo; - vampHost::Analyser analyser; - map <string,float> params; - }; class Time: public Signal_node { public: Time(){}; @@ -1299,6 +1263,31 @@ namespace Rotor { private: Image *image; //is an image generator }; + class Draw: public Image_node { + public: + Draw(){image=nullptr;}; + Draw(map<string,string> &settings) { + base_settings(settings); + }; + ~Draw(){ if (image) delete image;}; + Draw* clone(map<string,string> &_settings) { return new Draw(_settings);}; + Image *output(const Frame_spec &frame){ + if (image_inputs.size()) { + if (image_inputs[0]->connection){ + //copy incoming image **writable + if (image) delete image; + image=(((Image_node*)image_inputs[0]->connection)->get_output(frame))->clone(); + } + else image->setup(frame.w,frame.h); + } + else image->setup(frame.w,frame.h); //do this twice or use a goto + //draw onto new or input image + + return image; + } + private: + Image *image; //is an image generator + }; //------------------------------------------------------------------- class Node_factory{ public: @@ -1426,3 +1415,4 @@ coding style Types begin with capitals 'New_type' variables/ instances use lower case with underscore as a seperator */ +#endif
\ No newline at end of file |
