diff options
| author | Comment <tim@gray.(none)> | 2013-11-26 00:57:58 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-11-26 00:57:58 +0000 |
| commit | 9e5244e5c3e190cc0b03c24b1f63b49e8d52653e (patch) | |
| tree | f76f4bc8b4fd2adbbf884d5d7a485c29e9e9e5e3 /rotord/src | |
| parent | 81d0a2a1447724d81022b29c2c6c348dad032d83 (diff) | |
| parent | 5d8f8a40b50aa9e7237d972fe6fbf30279acf518 (diff) | |
Merge branch 'master' of eclectronics.org@eclectronics.org:rotor
Diffstat (limited to 'rotord/src')
| -rw-r--r-- | rotord/src/nodes_audio_analysis.cpp | 29 | ||||
| -rw-r--r-- | rotord/src/nodes_audio_analysis.h | 2 | ||||
| -rw-r--r-- | rotord/src/nodes_drawing.h | 34 | ||||
| -rw-r--r-- | rotord/src/rotor.cpp | 5 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 9 |
5 files changed, 71 insertions, 8 deletions
diff --git a/rotord/src/nodes_audio_analysis.cpp b/rotord/src/nodes_audio_analysis.cpp index 6ec1188..9ad33f6 100644 --- a/rotord/src/nodes_audio_analysis.cpp +++ b/rotord/src/nodes_audio_analysis.cpp @@ -69,6 +69,7 @@ namespace Rotor{ bits=_bits; samples=_samples; + features.clear(); return analyser.init(soname,id,_channels,_bits,_samples,_rate,outputNo,params); @@ -167,7 +168,6 @@ namespace Rotor{ if (intensity>max_intensity) max_intensity=intensity; if (intensity<min_intensity) min_intensity=intensity; intensities.push_back(intensity); - cerr<<"segment "<<i<<" average intensity: "<<intensity<<endl; } //make relative scale 0.0-1.0 and save weighted totals vector< pair<int,float>> totals; @@ -178,9 +178,34 @@ namespace Rotor{ } //sort and convert to features std::sort(totals.begin(),totals.end(),sortsegments); + for (i=0;i<totals.size();i++) { + cerr<<"segment "<<totals[i].first<<" average intensity: "<<totals[i].second<<endl; + } + vector<float> bucketoffsets; + for (auto t:totals) bucketoffsets.push_back(0.0f); + if (parameters["levels"]->value>0.0f&¶meters["levels"]->value<totals.size()){ + //use bucketoffsets to redistribute into smaller number of buckets + int numbertoredistribute=totals.size()-((int)parameters["levels"]->value); + float numberperbin=((float)numbertoredistribute/totals.size()); + float toadd=0.5f; + int added=0; + for (int j=0;j<totals.size();j++){ + int numbertoadd=min(numbertoredistribute-added,(int)toadd); + toadd=(toadd+numberperbin)-numbertoadd; + added+=numbertoadd; + bucketoffsets[j]=added; + } + if (numbertoredistribute>0) { + cerr<<"reducing number of levels by "<<numbertoredistribute<<", offsets:"<<endl; + for (auto o:bucketoffsets) { + cerr<<o<<":"; + } + cerr<<endl; + } + } for (i=0;i<totals.size();i++){ vampHost::feature f; - f.values.push_back((float)i); + f.values.push_back((float)i-bucketoffsets[i]); features[times[totals[i].first]]=f; } } diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h index 5b0a9c8..aa0aeb0 100644 --- a/rotord/src/nodes_audio_analysis.h +++ b/rotord/src/nodes_audio_analysis.h @@ -288,6 +288,7 @@ namespace Rotor { analysers["intensity"]=vampHost::Analyser(); create_parameter("intensity_weight","number","intensity weight","Intensity weighting",1.0f); create_parameter("tempo_weight","number","tempo weight","Tempo weighting",1.0f); + create_parameter("levels","number","levels","Number of intensity levels",0.0f); }; Intensity_segmenter(map<string,string> &settings):Intensity_segmenter() { base_settings(settings); @@ -295,6 +296,7 @@ namespace Rotor { ~Intensity_segmenter(){}; Intensity_segmenter* clone(map<string,string> &_settings) { return new Intensity_segmenter(_settings);}; bool init(int _channels,int _bits,int _samples,int _rate) { + features.clear(); return analysers["segmenter"].init("qm-vamp-plugins","qm-segmenter",_channels,_bits,_samples,_rate,0,params)\ &&analysers["tempo"].init("qm-vamp-plugins","qm-tempotracker",_channels,_bits,_samples,_rate,2,params)\ &&analysers["intensity"].init("bbc-vamp-plugins","bbc-intensity",_channels,_bits,_samples,_rate,0,params); diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h index 77a74cb..8fe5d71 100644 --- a/rotord/src/nodes_drawing.h +++ b/rotord/src/nodes_drawing.h @@ -62,7 +62,7 @@ namespace Rotor { public: Text_base(){ create_attribute("colour","Colour to fill","Colour","FFFFFF"); - create_attribute("font","font to use","Font","Sans",{"Sans","Sans Mono","Serif"}); + create_attribute("font","font to use","Font","Akzidenz",{"Sans","Sans Mono","Serif","Akzidenz"}); create_parameter("size","number","Point size of font","size",50.0f); NODEID="7da93b94-2d0b-11e3-8940-77bce0f9d3e8"; }; @@ -76,7 +76,18 @@ namespace Rotor { string text=select_text(frame); cairo_text_extents_t te; cairo_set_source_rgb(cr, colour.Rfloat(),colour.Gfloat(),colour.Bfloat()); - cairo_select_font_face (cr, ("DejaVu "+attributes["font"]->value).c_str(), + string fontname; + switch (attributes["font"]->intVal){ + case 1: + case 2: + case 3: + fontname="DejaVu "+attributes["font"]->value; + break; + case 4: + fontname="Akzidenz-Grotesk Condensed BQ"; + break; + } + cairo_select_font_face (cr,fontname.c_str(), CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size (cr, parameters["size"]->value*(((float)frame.w)/360.0f)); cairo_text_extents(cr, text.c_str(), &te); @@ -111,6 +122,25 @@ namespace Rotor { } private: }; + class UI_text: public Text_base { + public: + UI_text(){ + title="UI_text"; + description="Draws text entered by the user"; + create_attribute("text","Text to draw","Text","hello, world!"); + NODEID="22b47bea-52a9-11e3-b2b3-74d02b29f6a6"; + UItype="text"; + }; + UI_text(map<string,string> &settings):UI_text() { + base_settings(settings); + }; + ~UI_text(){}; + UI_text* clone(map<string,string> &_settings) { return new UI_text(_settings);}; + string select_text(const Frame_spec &frame){ + return attributes["text"]->value; + } + private: + }; class Lyrics: public Text_base { public: Lyrics(){ diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp index b1ef2b6..83a0fa7 100644 --- a/rotord/src/rotor.cpp +++ b/rotord/src/rotor.cpp @@ -77,6 +77,9 @@ Node_factory::Node_factory(){ add_type("echo_trails",new Echo_trails(),category["FX"]); add_type("video_feedback",new Video_feedback(),category["FX"]); + category["UI"]=vector<Node*>(); + add_type("ui_text",new UI_text(),category["UI"]); + } float Signal_input::get_time_used(){ if (connection){ @@ -159,6 +162,7 @@ Json::Value Node_factory::list_node(Rotor::Node* _node){ if (dynamic_cast<Image_node*> (_node)!=nullptr) node["output"]="image"; node["description"]=_node->description; node["NODEID"]=_node->NODEID; + node["UItype"]=_node->UItype; if (_node->inputs.size()){ node["signal_inputs"]=Json::arrayValue; for (auto& input: _node->inputs) { @@ -228,6 +232,7 @@ void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i){ XML.addAttribute("node","title",type->title,i); XML.addAttribute("node","description",type->description,i); XML.addAttribute("node","NODEID",type->NODEID,i); + XML.addAttribute("node","UItype",type->UItype,i); if (dynamic_cast<Signal_node*> (type)!=nullptr) XML.addAttribute("node","output","signal",i); if (dynamic_cast<Image_node*> (type)!=nullptr) XML.addAttribute("node","output","image",i); XML.pushTag("node",i); diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index bebb0e2..75e7914 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -295,7 +295,7 @@ namespace Rotor { }; class Node{ public: - Node(){duplicate_inputs=false;}; + Node(){duplicate_inputs=false;UItype="";}; virtual Node* clone(map<string,string> &_settings)=0; //pure virtual virtual ~Node(){ for (auto a: attributes) delete a.second; @@ -335,6 +335,7 @@ namespace Rotor { string ID; string NODEID; string title; + string UItype; bool duplicate_inputs; string find_setting(map<string,string> &settings,string key,string def=""){ if (settings.find(key)!=settings.end()) return settings[key]; else return def;}; float find_setting(map<string,string> &settings,string key,float def){ if (settings.find(key)!=settings.end()) return toFloat(settings[key]); else return def;}; @@ -628,11 +629,11 @@ namespace Rotor { return nullptr; } //cut mode - for (uint32_t i=0;i<image_inputs.size();i++){ - int whichinput=((int)inputs[0]->get((Time_spec)frame)+i)%image_inputs.size(); + //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; - } + //} return nullptr; } Video_cycler* clone(map<string,string> &_settings) { return new Video_cycler(_settings);}; |
