summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-09-04 15:30:03 +0100
committerTim Redfern <tim@eclectronics.org>2013-09-04 15:30:03 +0100
commitbe19f5a21dc1fe717711d76f500f6bfe0c4d166b (patch)
tree8cffe4ea47bd5cd66f8fe5fd1fb537c40a52e8f4
parentbb4e23344b03c4f0947852530e13885035a6c3fb (diff)
adding final audio feature
-rw-r--r--rotord/src/nodes_audio_analysis.h12
-rw-r--r--rotord/src/nodes_drawing.h14
-rwxr-xr-xrotord/src/rotor.h13
-rw-r--r--rotord/src/vampHost.cpp6
4 files changed, 30 insertions, 15 deletions
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<string,string> &settings):Text() {
base_settings(settings);
@@ -54,14 +55,19 @@ namespace Rotor {
~Text(){};
Text* clone(map<string,string> &_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<string,string> &_settings)=0; //pure virtual
virtual ~Node(){
- duplicate_inputs=false;
};
vector<Signal_input*> inputs; //simple node can have signal inputs, output depends on node type
unordered_map<string,Parameter*> 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 '"<<a.first<<"'' to "<<find_setting(settings,a.first,"")<<" (index: "<<attributes[a.first]->intVal<<")"<<endl;
}
}
for (auto p: parameters){
if (find_setting(settings,p.first,"")!="") {
parameters[p.first]->init(find_setting(settings,p.first,0.0f));
- cerr<<"setting parameter "<<p.first<<" to "<<find_setting(settings,p.first,0.0f)<<endl;
+ cerr<<"setting parameter '"<<p.first<<"'' to "<<find_setting(settings,p.first,0.0f)<<endl;
}
}
}
@@ -778,7 +779,7 @@ namespace Rotor {
float weights[3] = {parameters["weight_h"]->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;i<frame.w*frame.h;i++){
dist=0;
for (int j=0;j<3;j++){
@@ -788,8 +789,8 @@ namespace Rotor {
uint8_t id=(uint8_t)(sqrt((float)dist)*weight_total);
mask.data[i]=id;
}
-
- /*
+
+ /*
for (int i=0;i<frame.w*frame.h;i++){
dist=0;
@@ -1142,7 +1143,7 @@ namespace Rotor {
private:
Node_factory factory;
int outW,outH;
-
+
};
class Audio_thumbnailer: public Audio_processor {
public:
diff --git a/rotord/src/vampHost.cpp b/rotord/src/vampHost.cpp
index de7bb53..b265c3d 100644
--- a/rotord/src/vampHost.cpp
+++ b/rotord/src/vampHost.cpp
@@ -814,6 +814,12 @@ void vampHost::Analyser::cleanup(){
featureNo++;
}
+ //make a final feature at the end
+ feature f;
+ f.number=featureNo;
+ f.values={0};
+ features[((float)rt.sec)+(((float)rt.nsec)*.000000001f)]=f;
+
//cerr<<plugin->getIdentifier()<<" found "<<(features.size()-1)<<" features"<<endl;
//deal with left over data?
for (int c = 0; c < channels; ++c) {