summaryrefslogtreecommitdiff
path: root/rotord
diff options
context:
space:
mode:
Diffstat (limited to 'rotord')
-rw-r--r--rotord/src/nodes_audio_analysis.cpp22
-rw-r--r--rotord/src/nodes_audio_analysis.h1
-rw-r--r--rotord/src/rotor.h2
3 files changed, 23 insertions, 2 deletions
diff --git a/rotord/src/nodes_audio_analysis.cpp b/rotord/src/nodes_audio_analysis.cpp
index 6ec1188..ad6f5ad 100644
--- a/rotord/src/nodes_audio_analysis.cpp
+++ b/rotord/src/nodes_audio_analysis.cpp
@@ -178,9 +178,29 @@ namespace Rotor{
}
//sort and convert to features
std::sort(totals.begin(),totals.end(),sortsegments);
+ vector<float> bucketoffsets;
+ for (auto t:totals) bucketoffsets.push_back(0.0f);
+ if (parameters["levels"]->value>0.0f&&parameters["levels"]->value<totals.size()){
+ //use bucketoffsets to redistribute into smaller number of buckets
+ int numbertoredistribute=totals.size()-((int)parameters["levels"]->value);
+ int numberperbin=ceil((float)numbertoredistribute/totals.size());
+ int added=0;
+ for (int j=0;j<numbertoredistribute-numberperbin;j+=numberperbin){
+ int numbertoadd=min(numbertoredistribute-added,numberperbin);
+ bucketoffsets[j]=numbertoadd;
+ added+=numbertoadd;
+ }
+ if (numbertoredistribute>0) {
+ cerr<<"reducing number of levels by "<<numbertoredistribute<<", offsets:"<<endl;
+ for (auto o:bucketoffsets) {
+ cerr<<o<<":";
+ }
+ cerr<<endl;
+ }
+ }
for (i=0;i<totals.size();i++){
vampHost::feature f;
- f.values.push_back((float)i);
+ f.values.push_back((float)i+bucketoffsets[i]);
features[times[totals[i].first]]=f;
}
}
diff --git a/rotord/src/nodes_audio_analysis.h b/rotord/src/nodes_audio_analysis.h
index 5b0a9c8..21da1cc 100644
--- a/rotord/src/nodes_audio_analysis.h
+++ b/rotord/src/nodes_audio_analysis.h
@@ -288,6 +288,7 @@ namespace Rotor {
analysers["intensity"]=vampHost::Analyser();
create_parameter("intensity_weight","number","intensity weight","Intensity weighting",1.0f);
create_parameter("tempo_weight","number","tempo weight","Tempo weighting",1.0f);
+ create_parameter("levels","number","levels","Number of intensity levels",0.0f);
};
Intensity_segmenter(map<string,string> &settings):Intensity_segmenter() {
base_settings(settings);
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index 624e0f0..e882c05 100644
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -584,7 +584,7 @@ namespace Rotor {
return nullptr;
}
//cut mode
- //for (uint32_t i=0;i<image_inputs.size();i++){
+ //for (uint32_t i=0;i<image_inputs.size();i++){ //this skipped a beat for some reason
int whichinput=(((int)inputs[0]->get((Time_spec)frame)))%image_inputs.size(); //+i
Image *in=image_inputs[whichinput]->get(inframe);
if (in) return in;