changeset 76:d398e73b46e0 matthiasm-plugin

it's broken at the moment, work in progress (makeing bins per semitone variable, ie not necessarily 3)
author Matthias Mauch <mail@matthiasmauch.net>
date Wed, 10 Nov 2010 22:52:46 +0900
parents ec5b599fbabc
children ba930176df5b
files Chordino.cpp NNLSBase.cpp NNLSBase.h NNLSChroma.cpp Tuning.cpp chromamethods.cpp chromamethods.h
diffstat 7 files changed, 18 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/Chordino.cpp	Tue Nov 02 10:05:48 2010 +0000
+++ b/Chordino.cpp	Wed Nov 10 22:52:46 2010 +0900
@@ -29,8 +29,6 @@
 
 const bool debug_on = false;
 
-const vector<float> hw(hammingwind, hammingwind+19);
-
 Chordino::Chordino(float inputSampleRate) :
     NNLSBase(inputSampleRate)
 {
@@ -99,10 +97,10 @@
     d0.description = "Consider the cumulative energy spectrum (from low to high frequencies). All bins below the first bin whose cumulative energy exceeds the quantile [spectral roll on] x [total energy] will be set to 0. A value of 0 means that no bins will be changed.";
     d0.unit = "%";
     d0.minValue = 0;
-    d0.maxValue = 0.05;
+    d0.maxValue = 5;
     d0.defaultValue = 0;
     d0.isQuantized = true;
-	d0.quantizeStep = 0.005;
+	d0.quantizeStep = 0.5;
     list.push_back(d0);
 
     ParameterDescriptor d1;
@@ -210,7 +208,7 @@
     if (debug_on) {
         cerr << "--> initialise";
     }
-
+    
     if (!NNLSBase::initialise(channels, stepSize, blockSize)) {
         return false;
     }
@@ -238,6 +236,7 @@
 Chordino::FeatureSet
 Chordino::getRemainingFeatures()
 {
+    cerr << hw[0] << hw[1] << endl;
     if (debug_on) cerr << "--> getRemainingFeatures" << endl;
     FeatureSet fsOut;
     if (m_logSpectrum.size() == 0) return fsOut;
--- a/NNLSBase.cpp	Tue Nov 02 10:05:48 2010 +0000
+++ b/NNLSBase.cpp	Wed Nov 10 22:52:46 2010 +0900
@@ -28,8 +28,6 @@
 
 const bool debug_on = false;
 
-const vector<float> hw(hammingwind, hammingwind+19);
-
 NNLSBase::NNLSBase(float inputSampleRate) :
     Plugin(inputSampleRate),
     m_logSpectrum(0),
@@ -354,6 +352,14 @@
         cerr << "--> initialise";
     }
 	
+	int hamwinlength = nBPS * 6 + 1;
+    float hamwinsum = 0;
+    for (int i = 0; i < hamwinlength; ++i) { 
+        hw.push_back(0.54 - 0.46 * cos((2*M_PI*i)/(hamwinlength-1)));    
+        hamwinsum += 0.54 - 0.46 * cos((2*M_PI*i)/(hamwinlength-1));
+    }
+    for (int i = 0; i < hamwinlength; ++i) hw[i] = round(hw[i] / hamwinsum * 10000)*1.0/10000;
+	
     if (channels < getMinChannelCount() ||
 	channels > getMaxChannelCount()) return false;
     m_blockSize = blockSize;
--- a/NNLSBase.h	Tue Nov 02 10:05:48 2010 +0000
+++ b/NNLSBase.h	Wed Nov 10 22:52:46 2010 +0900
@@ -81,6 +81,7 @@
     vector<string> m_chordnames;
     float m_doNormalizeChroma;
     float m_rollon;
+    vector<float> hw;
 };
 
 
--- a/NNLSChroma.cpp	Tue Nov 02 10:05:48 2010 +0000
+++ b/NNLSChroma.cpp	Wed Nov 10 22:52:46 2010 +0900
@@ -28,8 +28,6 @@
 
 const bool debug_on = false;
 
-const vector<float> hw(hammingwind, hammingwind+19);
-
 NNLSChroma::NNLSChroma(float inputSampleRate) :
     NNLSBase(inputSampleRate)
 {
--- a/Tuning.cpp	Tue Nov 02 10:05:48 2010 +0000
+++ b/Tuning.cpp	Wed Nov 10 22:52:46 2010 +0900
@@ -28,8 +28,6 @@
 
 const bool debug_on = false;
 
-const vector<float> hw(hammingwind, hammingwind+19);
-
 Tuning::Tuning(float inputSampleRate) :
     NNLSBase(inputSampleRate)
 {
--- a/chromamethods.cpp	Tue Nov 02 10:05:48 2010 +0000
+++ b/chromamethods.cpp	Wed Nov 10 22:52:46 2010 +0900
@@ -370,20 +370,6 @@
         for (unsigned kSemitone = 0; kSemitone < 12; kSemitone++) loadedChordDict.push_back(0.5);
         for (unsigned kSemitone = 0; kSemitone < 12; kSemitone++) loadedChordDict.push_back(1.0);
 	
-        // normalise
-        // float sum = 0;
-        // for (int i = 0; i < loadedChordDict.size(); i++) {
-        //     sum += pow(loadedChordDict[i],2);
-        //     if (i % 24 == 23) {
-        //         float invertedsum = 1.0/sqrt(sum);
-        //         for (int k = 0; k < 24; k++) {
-        //             loadedChordDict[i-k] *= invertedsum; 
-        //         }
-        //         sum = 0;
-        //     }
-        //      
-        // }
-        
         float exponent = 2.0;
         float boostN = 1.1;
         
--- a/chromamethods.h	Tue Nov 02 10:05:48 2010 +0000
+++ b/chromamethods.h	Wed Nov 10 22:52:46 2010 +0900
@@ -22,7 +22,9 @@
 #include <vector>
 #include <string>
 
-const int nNote = 256;
+const int nBPS = 3; // bins per semitone
+const int nOctave = 7;
+const int nNote = nOctave * 12 * nBPS + 2 * (nBPS/2); // a core over all octaves, plus some overlap at top and bottom
 
 extern std::vector<float> SpecialConvolution(std::vector<float> convolvee, std::vector<float> kernel);
 extern void dictionaryMatrix(float* dm, float s_param);
@@ -48,13 +50,14 @@
     {"Ab","","Bb","Cb","C","Db","","Eb","","F","Gb","G"}
 };
 
-static const float hammingwind[19] = {0.0082, 0.0110, 0.0191, 0.0316, 0.0470, 0.0633, 0.0786, 0.0911, 0.0992, 0.1020, 0.0992, 0.0911, 0.0786, 0.0633, 0.0470, 0.0316, 0.0191, 0.0110, 0.0082};
 static const float basswindow[] = {0.001769, 0.015848, 0.043608, 0.084265, 0.136670, 0.199341, 0.270509, 0.348162, 0.430105, 0.514023, 0.597545, 0.678311, 0.754038, 0.822586, 0.882019, 0.930656, 0.967124, 0.990393, 0.999803, 0.995091, 0.976388, 0.944223, 0.899505, 0.843498, 0.777785, 0.704222, 0.624888, 0.542025, 0.457975, 0.375112, 0.295778, 0.222215, 0.156502, 0.100495, 0.055777, 0.023612, 0.004909, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000};
 static const float treblewindow[] = {0.000350, 0.003144, 0.008717, 0.017037, 0.028058, 0.041719, 0.057942, 0.076638, 0.097701, 0.121014, 0.146447, 0.173856, 0.203090, 0.233984, 0.266366, 0.300054, 0.334860, 0.370590, 0.407044, 0.444018, 0.481304, 0.518696, 0.555982, 0.592956, 0.629410, 0.665140, 0.699946, 0.733634, 0.766016, 0.796910, 0.826144, 0.853553, 0.878986, 0.902299, 0.923362, 0.942058, 0.958281, 0.971942, 0.982963, 0.991283, 0.996856, 0.999650, 0.999650, 0.996856, 0.991283, 0.982963, 0.971942, 0.958281, 0.942058, 0.923362, 0.902299, 0.878986, 0.853553, 0.826144, 0.796910, 0.766016, 0.733634, 0.699946, 0.665140, 0.629410, 0.592956, 0.555982, 0.518696, 0.481304, 0.444018, 0.407044, 0.370590, 0.334860, 0.300054, 0.266366, 0.233984, 0.203090, 0.173856, 0.146447, 0.121014, 0.097701, 0.076638, 0.057942, 0.041719, 0.028058, 0.017037, 0.008717, 0.003144, 0.000350};
 
 static const float sinvalue = 0.866025404;
 static const float cosvalue = -0.5;
 
+
+
 #include "nnls.h"
 
 #endif