diff options
| -rw-r--r-- | rotord/src/nodes_audio_analysis.cpp | 11 | ||||
| -rw-r--r-- | rotord/src/nodes_audio_analysis.h | 1 |
2 files changed, 8 insertions, 4 deletions
diff --git a/rotord/src/nodes_audio_analysis.cpp b/rotord/src/nodes_audio_analysis.cpp index 5770fb2..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,19 +178,22 @@ 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-2); + int numbertoredistribute=totals.size()-((int)parameters["levels"]->value); float numberperbin=((float)numbertoredistribute/totals.size()); - float toadd=0.0f; + float toadd=0.5f; int added=0; for (int j=0;j<totals.size();j++){ int numbertoadd=min(numbertoredistribute-added,(int)toadd); - bucketoffsets[j]=added; toadd=(toadd+numberperbin)-numbertoadd; added+=numbertoadd; + bucketoffsets[j]=added; } if (numbertoredistribute>0) { cerr<<"reducing number of levels by "<<numbertoredistribute<<", offsets:"<<endl; diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h index 21da1cc..aa0aeb0 100644 --- a/rotord/src/nodes_audio_analysis.h +++ b/rotord/src/nodes_audio_analysis.h @@ -296,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); |
