From be19f5a21dc1fe717711d76f500f6bfe0c4d166b Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 4 Sep 2013 15:30:03 +0100 Subject: adding final audio feature --- rotord/src/nodes_audio_analysis.h | 12 +++++++----- rotord/src/nodes_drawing.h | 14 ++++++++++---- rotord/src/rotor.h | 13 +++++++------ rotord/src/vampHost.cpp | 6 ++++++ 4 files changed, 30 insertions(+), 15 deletions(-) (limited to 'rotord') diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h index 619b60a..d192d26 100644 --- a/rotord/src/nodes_audio_analysis.h +++ b/rotord/src/nodes_audio_analysis.h @@ -36,7 +36,7 @@ namespace Rotor { 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()) { + 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; @@ -45,15 +45,17 @@ namespace Rotor { if (i->second.values.size()) v2=i->second.values[0]; i--; float lk=i->first; - int ln=i->second.number; + int ln=i->second.number-1; //vamp numbers the first segment 0 if (i->second.values.size()) v1=i->second.values[0]; + int m=attributes["mode"]->intVal; + // switch (attributes["mode"]->intVal){ case VAMPHOST_Timeline: - return ((time.time-lk)+ln); + return (((time.time-lk)/(uk-lk))+ln); case VAMPHOST_Timesteps: return (float)ln; case VAMPHOST_Valueline: - return (((time.time-lk)*(v2-v1))+v1); + return ((((time.time-lk)/(uk-lk))*(v2-v1))+v1); case VAMPHOST_Values: return v1; } @@ -73,4 +75,4 @@ namespace Rotor { }; } -#endif \ No newline at end of file +#endif diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h index d91ad87..db1d934 100644 --- a/rotord/src/nodes_drawing.h +++ b/rotord/src/nodes_drawing.h @@ -47,6 +47,7 @@ namespace Rotor { title="Text"; description="Draws text"; create_attribute("text","Text to draw","Text","hello, world!"); + create_parameter("number","number","Number to draw","Number",-99999999.0f); }; Text(map &settings):Text() { base_settings(settings); @@ -54,14 +55,19 @@ namespace Rotor { ~Text(){}; Text* clone(map &_settings) { return new Text(_settings);}; void vector_output(cairo_t * cr,const Frame_spec &frame){ + string text; + if (parameters["number"]->value>-99999998.0f){ + text=ofToString(parameters["number"]->value,4); + } + else text=attributes["text"]->value; cairo_text_extents_t te; cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); cairo_select_font_face (cr, "Georgia", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); - cairo_set_font_size (cr, 250); - cairo_text_extents(cr, attributes["text"]->value.c_str(), &te); - cairo_move_to (cr,(frame.w-te.width)/2,(frame.h-te.height)/2); - cairo_show_text (cr, attributes["text"]->value.c_str()); + cairo_set_font_size (cr, 120); + cairo_text_extents(cr, text.c_str(), &te); + cairo_move_to (cr,(frame.w-te.width)/2,frame.h*0.6); + cairo_show_text (cr, text.c_str()); cairo_fill(cr); } private: diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index a769430..d6426f5 100755 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -159,9 +159,9 @@ namespace Rotor { }; class Node{ public: + Node(){duplicate_inputs=false;}; virtual Node* clone(map &_settings)=0; //pure virtual virtual ~Node(){ - duplicate_inputs=false; }; vector inputs; //simple node can have signal inputs, output depends on node type unordered_map parameters; //linked parameters can convert from settings to inputs @@ -199,12 +199,13 @@ namespace Rotor { for (auto a: attributes){ if (find_setting(settings,a.first,"")!="") { attributes[a.first]->init(find_setting(settings,a.first,"")); + cerr<<"setting attribute '"<intVal<<")"<init(find_setting(settings,p.first,0.0f)); - cerr<<"setting parameter "<value,parameters["weight_s"]->value,parameters["weight_v"]->value}; float weight_total=255.0f/pow(pow(weights[0]*255,2)+pow(weights[1]*255,2)+pow(weights[2]*255,2),0.5); - + for (int i=0;igetIdentifier()<<" found "<<(features.size()-1)<<" features"<