diff options
Diffstat (limited to 'rotord/rotor.h')
| -rwxr-xr-x | rotord/rotor.h | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h index 6ca5da2..3b328bf 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -243,8 +243,7 @@ namespace Rotor { return *this; } Image * operator*(const float &amount) { - Image *other=new Image(); - other->setup(w,h); + Image *other=new Image(w,h); uint8_t *LUT=new uint8_t[0xFF]; for (int i=0;i<0xFF;i++) { LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i*amount))); @@ -252,42 +251,43 @@ namespace Rotor { for (int i=0;i<w*h*3;i++){ other->RGBdata[i]=LUT[RGBdata[i]]; } + delete LUT; return other; } Image * operator+(const float &amount) { - Image *other=new Image(); - other->setup(w,h); + Image *other=new Image(w,h); uint8_t *LUT=new uint8_t[0xFF]; for (int i=0;i<0xFF;i++) { - LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i+amount))); //should normalise to 0-255? + LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i+(amount*255.0f)))); } for (int i=0;i<w*h*3;i++){ other->RGBdata[i]=LUT[RGBdata[i]]; } + delete LUT; return other; } Image * operator-(const float &amount) { - Image *other=new Image(); - other->setup(w,h); + Image *other=new Image(w,h); uint8_t *LUT=new uint8_t[0xFF]; for (int i=0;i<0xFF;i++) { - LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i-amount))); //should normalise to 0-255? + LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i-(amount*255.0f)))); } for (int i=0;i<w*h*3;i++){ other->RGBdata[i]=LUT[RGBdata[i]]; } + delete LUT; return other; } Image * operator/(const float &amount) { - Image *other=new Image(); - other->setup(w,h); + Image *other=new Image(w,h); uint8_t *LUT=new uint8_t[0xFF]; for (int i=0;i<0xFF;i++) { - LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i/amount))); //should normalise to 0-255? + LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i/amount))); } for (int i=0;i<w*h*3;i++){ other->RGBdata[i]=LUT[RGBdata[i]]; } + delete LUT; return other; } uint8_t *RGBdata; @@ -358,6 +358,7 @@ namespace Rotor { output_type=find_setting(settings,"output"); ID=find_setting(settings,"ID"); } + virtual void set_parameter(const std::string &key,const std::string &value){}; virtual void link_params(){}; //TODO make param classes that link automatically void update_params(const Time_spec& time); }; @@ -380,7 +381,7 @@ namespace Rotor { class Base_audio_processor: public Signal_node { public: virtual int process_frame(uint8_t *data,int samples)=0; - virtual bool init(int _channels,int _bits,int _samples,int _rate,const map<string,float> ¶ms)=0; + virtual bool init(int _channels,int _bits,int _samples,int _rate)=0; virtual void cleanup()=0; virtual void print_summary(){}; int channels,bits,samples,rate; @@ -396,8 +397,9 @@ namespace Rotor { 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,const map<string,float> ¶ms); + 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()) { @@ -420,6 +422,7 @@ namespace Rotor { string soname,id; int outputNo; vampHost::Analyser analyser; + map <string,float> params; }; class Track_time: public Signal_node { public: @@ -795,8 +798,7 @@ namespace Rotor { if (inputs.size()) { if (inputs[0]->connection){ float sig= ((((Signal_node*)inputs[0]->connection)->get_output(frame))); - float seg=fmod(sig,(int)sig); - uint8_t col=255-((uint8_t)(seg*255.0f)); + uint8_t col=255-((uint8_t)(sig*255.0f)); if (col!=prevcol||image.w!=frame.w||image.h!=frame.h){ image.setup(frame.w,frame.h); for (int i=0;i<image.w*image.h*3;i++){ @@ -1123,7 +1125,7 @@ namespace Rotor { delete[] data; }; Audio_thumbnailer* clone(map<string,string> &_settings) { return new Audio_thumbnailer();}; - bool init(int _channels,int _bits,int _samples,int _rate,const map<string,float> ¶ms); + bool init(int _channels,int _bits,int _samples,int _rate); void cleanup(){}; int process_frame(uint8_t *data,int samples_in_frame); string print(); @@ -1143,6 +1145,14 @@ namespace Rotor { state=IDLE; output_framerate=25.0f; audio_loaded=false; + + xmlIO xml; + if(xml.loadFile("settings.xml") ){ + graph_dir=xml.getAttribute("Rotor","graph_dir","",0); + media_dir=xml.getAttribute("Rotor","media_dir","",0); + output_dir=xml.getAttribute("Rotor","output_dir","",0); + } + else cerr<<"Rotor: settings.xml not found, using defaults"<<endl; }; ~Render_context(){delete audio_thumb;}; void runTask(); @@ -1162,6 +1172,9 @@ namespace Rotor { Poco::Mutex mutex; //lock for access from parent thread std::string audio_filename; std::string output_filename; + std::string graph_dir; + std::string media_dir; + std::string output_dir; Audio_thumbnailer *audio_thumb; vampHost::QMAnalyser audio_analyser; |
