From b3abde4531510b7accbc58174ecd9ec27c52ee3a Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 30 Oct 2013 14:15:47 +0000 Subject: intensity segmenter --- rotord/src/nodes_audio_analysis.cpp | 80 +++++++++++++++++++++++++++++++++++++ rotord/src/nodes_audio_analysis.h | 20 +++------- 2 files changed, 85 insertions(+), 15 deletions(-) (limited to 'rotord') diff --git a/rotord/src/nodes_audio_analysis.cpp b/rotord/src/nodes_audio_analysis.cpp index 1e65668..5318bb1 100644 --- a/rotord/src/nodes_audio_analysis.cpp +++ b/rotord/src/nodes_audio_analysis.cpp @@ -105,4 +105,84 @@ namespace Rotor{ } return data; } + bool sortsegments(std::pair i,std::pair j){ + return (i.second tempos; + vector intensities; + vector times; + for (auto f=analysers["segmenter"].features.begin();g!=analysers["segmenter"].features.end();f++,g++,i++){ + cerr<<"segment "<first<<" to "<first<first); + //integrate tempo and intensity algorithmically + float tempo=0; + if (analysers["tempo"].features.size()) { + float pt=f->first; + float pv=analysers["tempo"].get_value(f->first); + for (auto u=analysers["tempo"].features.upper_bound(f->first);u!=analysers["tempo"].features.upper_bound(g->first);u++){ + tempo +=(u->first-pt)*(u->second.values[0]+pv)*0.5f; //area of the slice + pt=u->first; + pv=u->second.values[0]; + } + tempo +=(g->first-pt)*(analysers["tempo"].get_value(g->first)+pv)*0.5f; //area of the last slice + tempo /=g->first-f->first; //average value; + } + if (tempo>max_tempo) max_tempo=tempo; + if (tempofirst; + float pv=analysers["intensity"].get_value(f->first); + for (auto u=analysers["intensity"].features.upper_bound(f->first);u!=analysers["intensity"].features.upper_bound(g->first);u++){ + intensity +=(u->first-pt)*(u->second.values[0]+pv)*0.5f; //area of the slice + pt=u->first; + pv=u->second.values[0]; + } + intensity +=(g->first-pt)*(analysers["intensity"].get_value(g->first)+pv)*0.5f; //area of the last slice + intensity /=g->first-f->first; //average value; + } + if (intensity>max_intensity) max_intensity=intensity; + if (intensity> totals; + for (i=0;ivalue)+(intensities[i]*parameters["intensity_weight"]->value))); + } + //sort and convert to features + std::sort(totals.begin(),totals.end(),sortsegments); + for (int i=0;i &settings):Intensity_segmenter() { base_settings(settings); @@ -306,21 +308,7 @@ namespace Rotor { analysers["intensity"].process_frame(data,samples_in_frame); return 1; } - void cleanup(){ - //for (auto a:analysers) a.second.cleanup(); //WHY NOT WORK - its as if the call is const - analysers["segmenter"].cleanup(); - analysers["tempo"].cleanup(); - analysers["intensity"].cleanup(); - cerr<