diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-09-06 16:11:27 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-09-06 16:11:27 +0100 |
| commit | 37ca0efe3a3e50c2e7debff5f3f1779377e22ab3 (patch) | |
| tree | dbe3f79802d95b1b432e1e172f887208726a6609 /rotord/src/nodes_audio_analysis.h | |
| parent | 48ec56201e2240dcda68f2c384bacc3bdcb405ba (diff) | |
act segmenter subdivide segments
Diffstat (limited to 'rotord/src/nodes_audio_analysis.h')
| -rw-r--r-- | rotord/src/nodes_audio_analysis.h | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h index 7a0ed9e..89d6c9d 100644 --- a/rotord/src/nodes_audio_analysis.h +++ b/rotord/src/nodes_audio_analysis.h @@ -102,29 +102,41 @@ namespace Rotor { vector<int> act_count; for (int i=0;i<(int)parameters["acts"]->value;i++) act_count.push_back(0); - map<float,int> durations; //list of segment durations - int i=0; - for (map<float,vampHost::feature>::iterator f=analyser.features.begin();f!=analyser.features.end();++f){ - auto g=f; - if (++g!=analyser.features.end()){ - durations[g->first-f->first]=i; - } - i++; - } - //distribute acts amongst segments; - if (analyser.features.size()==(int)parameters["acts"]->value+1){ - for (auto f: analyser.features){ - acts[f.first]=f.second; - } - } - else if (analyser.features.size()<(int)parameters["acts"]->value+1){ + if (analyser.features.size()<=(int)parameters["acts"]->value+1){ //iteratively split segments and refresh durations //this could work well on the original data //pick the longest and split it in two //refresh durations - this can be a function //keep going //finally copy out - + while (analyser.features.size()<(int)parameters["acts"]->value+1){ + map<int,float> durations; + map<int,float> times; + int i=0; + for (map<float,vampHost::feature>::iterator f=analyser.features.begin();f!=analyser.features.end();++f){ + auto g=f; + if (++g!=analyser.features.end()){ + durations[i]=g->first-f->first; + times[i]=f->first; + } + i++; + } + float f=0; + int n=-1; + for (auto d: durations){ + if (d.second>f){ + f=d.second; + n=d.first; + } + } + analyser.features[times[n]+(durations[n]/2)]=analyser.features[times[n]]; + } + int j=0; + for (auto f: analyser.features){ + f.second.number=j; + acts[f.first]=f.second; + j++; + } } else { //there are extra segments to assign to acts //assign act numbers to segments @@ -140,6 +152,8 @@ namespace Rotor { segments.erase(--segments.end()); //assign the acts from the beginning and end in towards the middle + //when all slots have bveen used it picks the middle item and uses surrrounding items again + //there is a limit of item use based on how near it is to the edge bool take_start=true; while (segments.size()){ int act=-1; |
