summaryrefslogtreecommitdiff
path: root/rotord/src/nodes_audio_analysis.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src/nodes_audio_analysis.cpp')
-rw-r--r--rotord/src/nodes_audio_analysis.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/rotord/src/nodes_audio_analysis.cpp b/rotord/src/nodes_audio_analysis.cpp
index 9ad33f6..a6aa4ec 100644
--- a/rotord/src/nodes_audio_analysis.cpp
+++ b/rotord/src/nodes_audio_analysis.cpp
@@ -8,7 +8,7 @@ namespace Rotor{
samples=_samples;
samples_per_column=samples/width;
offset=0x1<<(bits-1); //signed audio
- scale=1.0f/offset;
+ scale=1.0/offset;
out_sample=0; //sample in whole track
sample=0;
@@ -106,7 +106,7 @@ namespace Rotor{
}
return data;
}
- bool sortsegments(std::pair<int,float> i,std::pair<int,float> j){
+ bool sortsegments(std::pair<int,double> i,std::pair<int,double> j){
return (i.second<j.second);
}
void Intensity_segmenter::cleanup(){
@@ -124,22 +124,22 @@ namespace Rotor{
cerr<<analysers["tempo"].features.size()<<" tempo features"<<endl;
cerr<<analysers["intensity"].features.size()<<" intensity features"<<endl;
uint32_t i=0;
- float min_tempo=9999999.0f;
- float min_intensity=9999999.0f;
- float max_tempo=0.0f;
- float max_intensity=0.0f;
- vector<float> tempos;
- vector<float> intensities;
- vector<float> times;
+ double min_tempo=9999999.0;
+ double min_intensity=9999999.0;
+ double max_tempo=0.0;
+ double max_intensity=0.0;
+ vector<double> tempos;
+ vector<double> intensities;
+ vector<double> times;
auto g=++analysers["segmenter"].features.begin();
for (auto f=analysers["segmenter"].features.begin();g!=analysers["segmenter"].features.end();f++,g++,i++){
cerr<<"segment "<<i<<": "<<f->first<<" to "<<g->first<<endl;
times.push_back(f->first);
//integrate tempo and intensity algorithmically
- float tempo=0;
+ double tempo=0;
if (analysers["tempo"].features.size()) {
- float pt=f->first;
- float pv=analysers["tempo"].get_value(f->first);
+ double pt=f->first;
+ double 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;
@@ -153,10 +153,10 @@ namespace Rotor{
tempos.push_back(tempo);
cerr<<"segment "<<i<<" average tempo: "<<tempo<<endl;
- float intensity=0;
+ double intensity=0;
if (analysers["intensity"].features.size()) {
- float pt=f->first;
- float pv=analysers["intensity"].get_value(f->first);
+ double pt=f->first;
+ double 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;
@@ -170,7 +170,7 @@ namespace Rotor{
intensities.push_back(intensity);
}
//make relative scale 0.0-1.0 and save weighted totals
- vector< pair<int,float>> totals;
+ vector< pair<int,double>> totals;
for (i=0;i<tempos.size();i++){
tempos[i]=(tempos[i]-min_tempo)/(max_tempo-min_tempo);
intensities[i]=(intensities[i]-min_intensity)/(max_intensity-min_intensity);
@@ -181,13 +181,13 @@ namespace Rotor{
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&&parameters["levels"]->value<totals.size()){
+ vector<double> bucketoffsets;
+ for (auto t:totals) bucketoffsets.push_back(0.0);
+ if (parameters["levels"]->value>0.0&&parameters["levels"]->value<totals.size()){
//use bucketoffsets to redistribute into smaller number of buckets
int numbertoredistribute=totals.size()-((int)parameters["levels"]->value);
- float numberperbin=((float)numbertoredistribute/totals.size());
- float toadd=0.5f;
+ double numberperbin=((double)numbertoredistribute/totals.size());
+ double toadd=0.5f;
int added=0;
for (int j=0;j<totals.size();j++){
int numbertoadd=min(numbertoredistribute-added,(int)toadd);
@@ -205,7 +205,7 @@ namespace Rotor{
}
for (i=0;i<totals.size();i++){
vampHost::feature f;
- f.values.push_back((float)i-bucketoffsets[i]);
+ f.values.push_back((double)i-bucketoffsets[i]);
features[times[totals[i].first]]=f;
}
}