summaryrefslogtreecommitdiff
path: root/rotord/src/nodes_audio_analysis.h
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-12-09 01:53:14 +0000
committerComment <tim@gray.(none)>2013-12-09 01:53:14 +0000
commit08e7c5e59b5a7bfecb60ec98bfa191629d522ec8 (patch)
tree95ee80e1c6b4ef9d4f927676d91ebaa128d06bfe /rotord/src/nodes_audio_analysis.h
parent1d05d2380bb4f1fd265aef55744f432af38b08aa (diff)
audio analysis segments output fix
Diffstat (limited to 'rotord/src/nodes_audio_analysis.h')
-rw-r--r--rotord/src/nodes_audio_analysis.h57
1 files changed, 31 insertions, 26 deletions
diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h
index 7c4893a..3f0416f 100644
--- a/rotord/src/nodes_audio_analysis.h
+++ b/rotord/src/nodes_audio_analysis.h
@@ -57,25 +57,30 @@ namespace Rotor {
const double output(const Time_spec &time) {
if (features.size()) {
auto i=features.upper_bound(time.time); //the first element in the container whose key is considered to go after k
- if (i==features.end()) i--;
- double uk=i->first;
- double v1,v2;
- v1=v2=0.0;
+ double uk;
+ double v1,v2;
+ v1=v2=0.0;
+ if (i==features.end()) {
+ uk=time.duration;
+ }
+ else {
+ uk=i->first;
if (i->second.values.size()) v2=i->second.values[0];
- i--;
- double lk=i->first;
- 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 (double)ln;
- case VAMPHOST_Valueline:
- return ((((time.time-lk)/(uk-lk))*(v2-v1))+v1);
- case VAMPHOST_Values:
- return v1;
- }
+ }
+ i--;
+ double lk=i->first;
+ 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 (double)ln;
+ case VAMPHOST_Valueline:
+ return ((time.time-lk)/(uk-lk))+v1; //((((time.time-lk)/(uk-lk))*(v2-v1))+v1);
+ case VAMPHOST_Values:
+ return v1;
+ }
//}
//return (--features.end())->second.values[0];
}
@@ -89,7 +94,7 @@ namespace Rotor {
string soname,id;
int outputNo;
map <string,float> params;
- map<float,vampHost::feature> features;
+ map<double,vampHost::feature> features;
private:
vampHost::Analyser analyser;
};
@@ -177,7 +182,7 @@ namespace Rotor {
Act_segmenter* clone(map<string,string> &_settings) { return new Act_segmenter(_settings);};
void cleanup(){
Vamp_node::cleanup();
- map<float,vampHost::feature> acts; //temporary storage for new set of features
+ map<double,vampHost::feature> acts; //temporary storage for new set of features
vector<int> act_count;
for (int i=0;i<(int)parameters["acts"]->value;i++) act_count.push_back(0);
@@ -189,10 +194,10 @@ namespace Rotor {
//keep going
//finally copy out
while (features.size()<(uint32_t)parameters["acts"]->value+1){
- map<int,float> durations;
- map<int,float> times;
+ map<int,double> durations;
+ map<int,double> times;
int i=0;
- for (map<float,vampHost::feature>::iterator f=features.begin();f!=features.end();++f){
+ for (map<double,vampHost::feature>::iterator f=features.begin();f!=features.end();++f){
auto g=f;
if (++g!=features.end()){
durations[i]=g->first-f->first;
@@ -200,7 +205,7 @@ namespace Rotor {
}
i++;
}
- float f=0;
+ double f=0;
int n=-1;
for (auto d: durations){
if (d.second>f){
@@ -227,7 +232,7 @@ namespace Rotor {
//start with a set of the segments numbers
//(the aim: to access the segment numbers by the time that they start)
- map<float,vampHost::feature> segments=features;
+ map<double,vampHost::feature> segments=features;
segments.erase(--segments.end());
//assign the acts from the beginning and end in towards the middle
@@ -237,7 +242,7 @@ namespace Rotor {
while (segments.size()){
int act=-1;
vampHost::feature f;
- float t;
+ double t;
if (take_start){
f=(*segments.begin()).second;
t=(*segments.begin()).first;