diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-08-30 18:27:08 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-08-30 18:27:08 +0100 |
| commit | c5085b5a31c1e25bf83ae910710996863531f8b2 (patch) | |
| tree | 86bfd31285853f18f5ae436970deb0bc4f3e0fe1 /rotord/src/nodes_audio_analysis.h | |
| parent | f38cdcf952ac5c631ed285282e1bc2943f199101 (diff) | |
value output from audio analysis
Diffstat (limited to 'rotord/src/nodes_audio_analysis.h')
| -rw-r--r-- | rotord/src/nodes_audio_analysis.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h index 9252db4..fba4bcc 100644 --- a/rotord/src/nodes_audio_analysis.h +++ b/rotord/src/nodes_audio_analysis.h @@ -5,12 +5,17 @@ #include "vampHost.h" namespace Rotor { +#define VAMPHOST_Timeline 1 +#define VAMPHOST_Timesteps 2 +#define VAMPHOST_Valueline 3 +#define VAMPHOST_Values 4 class Audio_analysis: public Audio_processor { public: Audio_analysis(){ //create_attribute("soname","Plugin library to use","Plugin library","vamp-example-plugins",{"horiz","vert","horizR","vertR"}); //create_attribute("id","ID of Plugin to use","Plugin ID","percussiononsets",{"horiz","vert","horizR","vertR"}); create_attribute("analyser","Analyser Plugin to use","Analyser plugin","barbeattracker",{"barbeattracker","segmenter"}); + create_attribute("mode","Data output mode","Mode","timeline",{"timeline","timesteps","valueline","values"}); create_parameter("outputNo","number","Plugin output to use","Output number",0.0f); title="Audio analysis"; description="Analyse audio and output"; @@ -31,19 +36,32 @@ 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; + float v1,v2; + v1=v2=0.0f; + if (i->second.values.size()) v2=i->second.values[0]; i--; float lk=i->first; - int ln=i->second; - return (((time.time-lk)/(uk-lk))+ln); + int ln=i->second.number; + if (i->second.values.size()) v1=i->second.values[0]; + switch (attributes["mode"]->intVal){ + case VAMPHOST_Timeline: + return (((time.time-lk)/(uk-lk))+ln); + case VAMPHOST_Timesteps: + return (float)ln; + case VAMPHOST_Valueline: + return (((time.time-lk)/(v2-v1))+v1); + case VAMPHOST_Values: + return v1; + } } } return 0.0f; } - void print_features(); + string get_features(); void print_summary(){ cerr<<"vamp plugin "<<id<<" of library "<<soname<<" found "<<analyser.features.size()<<" features "<<endl; }; |
