changeset 115:526250b06fe0 monophonicness

some comments, some variable renamings
author Matthias Mauch <mail@matthiasmauch.net>
date Thu, 31 Mar 2011 14:26:53 +0100
parents 3f104bceac99
children 9f7ba52207dc
files Chordino.cpp NNLSBase.cpp NNLSBase.h chromamethods.cpp chromamethods.h
diffstat 5 files changed, 25 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/Chordino.cpp	Thu Mar 31 13:51:45 2011 +0100
+++ b/Chordino.cpp	Thu Mar 31 14:26:53 2011 +0100
@@ -36,8 +36,6 @@
     m_chordnames(0)    
 {
     if (debug_on) cerr << "--> Chordino" << endl;
-    // get the *chord* dictionary from file (if the file exists)
-    
 }
 
 Chordino::~Chordino()
@@ -259,7 +257,7 @@
     if (!NNLSBase::initialise(channels, stepSize, blockSize)) {
         return false;
     }
-    m_chordnames = chordDictionary(&m_chorddict, &m_chordnotes, m_boostN, m_useHarte);
+    m_chordnames = chordDictionary(&m_chorddict, &m_chordnotes, m_boostN, m_harte_syntax);
     return true;
 }
 
@@ -315,10 +313,6 @@
     **/
     cerr << endl << "[Chordino Plugin] Tuning Log-Frequency Spectrogram ... ";
 					
-    float tempValue = 0;
-    float dbThreshold = 0; // relative to the background spectrum
-    float thresh = pow(10,dbThreshold/20);
-    // cerr << "tune local ? " << m_tuneLocal << endl;
     int count = 0;
 		
     FeatureList tunedSpec;
@@ -342,7 +336,7 @@
         // cerr << intShift << " " << floatShift << endl;
 		        
         for (int k = 2; k < (int)currentLogSpectrum.values.size() - 3; ++k) { // interpolate all inner bins
-            tempValue = currentLogSpectrum.values[k + intShift] * (1-floatShift) + currentLogSpectrum.values[k+intShift+1] * floatShift;
+            float tempValue = currentLogSpectrum.values[k + intShift] * (1-floatShift) + currentLogSpectrum.values[k+intShift+1] * floatShift;
             currentTunedSpec.values.push_back(tempValue);
         }
 		        
--- a/NNLSBase.cpp	Thu Mar 31 13:51:45 2011 +0100
+++ b/NNLSBase.cpp	Thu Mar 31 14:26:53 2011 +0100
@@ -51,7 +51,7 @@
     m_rollon(0.0),
     m_boostN(0.1),
 	m_s(0.7),
-	m_useHarte(0),
+	m_harte_syntax(0),
 	sinvalues(0),
 	cosvalues(0)
 {
@@ -153,8 +153,8 @@
 
     ParameterDescriptor d0;
     d0.identifier = "rollon";
-    d0.name = "spectral roll-on";
-    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.name = "bass noise threshold";
+    d0.description = "Consider the cumulative energy spectrum (from low to high frequencies). All bins below the first bin whose cumulative energy exceeds the quantile [bass noise threshold] x [total energy] will be set to 0. A threshold value of 0 means that no bins will be changed.";
     d0.unit = "%";
     d0.minValue = 0;
     d0.maxValue = 5;
@@ -262,7 +262,7 @@
     }
     
 	if (identifier == "usehartesyntax") {
-		return m_useHarte;
+		return m_harte_syntax;
 	}
 
     return 0;
@@ -325,7 +325,7 @@
     }
 
 	if (identifier == "usehartesyntax") {
-		m_useHarte = value;
+		m_harte_syntax = value;
 	}
 }
 
--- a/NNLSBase.h	Thu Mar 31 13:51:45 2011 +0100
+++ b/NNLSBase.h	Thu Mar 31 14:26:53 2011 +0100
@@ -76,7 +76,7 @@
     float m_rollon;
     float m_boostN;
     float m_s;
-	float m_useHarte;
+	float m_harte_syntax;
     vector<float> hw;
     vector<float> sinvalues;
     vector<float> cosvalues;
--- a/chromamethods.cpp	Thu Mar 31 13:51:45 2011 +0100
+++ b/chromamethods.cpp	Thu Mar 31 14:26:53 2011 +0100
@@ -38,9 +38,11 @@
 
 
 /** Special Convolution
-    special convolution is as long as the convolvee, i.e. the first argument. in the valid core part of the 
-    convolution it contains the usual convolution values, but the pads at the beginning (ending) have the same values
-    as the first (last) valid convolution bin.
+    Special convolution is as long as the convolvee, i.e. the first argument. 
+	In the "valid" core part of the convolution it contains the usual convolution 
+	values, but the parts at the beginning (ending) that would normally be 
+	calculated using zero padding simply have the same values as the first 
+	(last) valid convolution bin.
 **/
 
 vector<float> SpecialConvolution(vector<float> convolvee, vector<float> kernel)
@@ -71,15 +73,6 @@
     return Z;
 }
 
-// vector<float> FftBin2Frequency(vector<float> binnumbers, int fs, int blocksize)
-// {
-// 	vector<float> freq(binnumbers.size, 0.0);
-// 	for (unsigned i = 0; i < binnumbers.size; ++i) {
-// 		freq[i] = (binnumbers[i]-1.0) * fs * 1.0 / blocksize;	
-// 	}
-// 	return freq;
-// }
-
 float cospuls(float x, float centre, float width) 
 {
     float recipwidth = 1.0/width;
@@ -103,7 +96,13 @@
     return out;
 }
 
+/**
+ * Calculates a matrix that can be used to linearly map from the magnitude spectrum to a pitch-scale spectrum.
+ * @return this always returns true, which is a bit stupid, really. The main purpose of the function is to change the values in the "matrix" pointed to by *outmatrix
+ */
 bool logFreqMatrix(int fs, int blocksize, float *outmatrix) {
+	// TODO: rewrite so that everyone understands what is done here.
+	// TODO: make this more general, such that it works with all minoctave, maxoctave and whatever nBPS (or check if it already does)
 	
     int binspersemitone = nBPS; 
     int minoctave = 0; // this must be 0
@@ -128,8 +127,6 @@
     int maxMIDI = 21 + maxoctave * 12; // this includes one additional semitone!
     vector<float> cq_f;
     float oob = 1.0/binspersemitone; // one over binspersemitone
-    // cq_f.push_back(440 * pow(2.0,0.083333 * (minMIDI-69))); // 0.083333 is approx 1/12
-    // cq_f.push_back(440 * pow(2.0,0.083333 * (minMIDI+oob-69)));
     for (int i = minMIDI; i < maxMIDI; ++i) {
         for (int k = 0; k < binspersemitone; ++k)	 {
             cq_f.push_back(440 * pow(2.0,0.083333333333 * (i+oob*k-69)));
@@ -161,34 +158,28 @@
                     // cerr << oversampled_f[iOS] << " " << cq_f[iCQ] << " " << cq_activation << endl;
                     outmatrix[iFFT + nFFT * iCQ] += cq_activation * fft_activation[iOS-curr_start];
                 }				
-                // if (iCQ == 1 || iCQ == 2) {
-                // 	cerr << " " << outmatrix[iFFT + nFFT * iCQ] << endl;
-                // }
-            }
+             }
         }
     }
     return true;	
 }
 
 void dictionaryMatrix(float* dm, float s_param) {
+	// TODO: make this more general, such that it works with all minoctave, maxoctave and even more than one note per semitone
     int binspersemitone = nBPS;
     int minoctave = 0; // this must be 0
     int maxoctave = 7; // this must be 7
-    // float s_param = 0.7;
 	
     // pitch-spaced frequency vector
     int minMIDI = 21 + minoctave * 12 - 1; // this includes one additional semitone!
     int maxMIDI = 21 + maxoctave * 12; // this includes one additional semitone!
     vector<float> cq_f;
     float oob = 1.0/binspersemitone; // one over binspersemitone
-    // cq_f.push_back(440 * pow(2.0,0.083333 * (minMIDI-69))); // 0.083333 is approx 1/12
-    // cq_f.push_back(440 * pow(2.0,0.083333 * (minMIDI+oob-69)));
     for (int i = minMIDI; i < maxMIDI; ++i) {
         for (int k = 0; k < binspersemitone; ++k)	 {
             cq_f.push_back(440 * pow(2.0,0.083333333333 * (i+oob*k-69)));
         }
     }
-    // cq_f.push_back(440 * pow(2.0,0.083333 * (minMIDI-oob-69)));
     cq_f.push_back(440 * pow(2.0,0.083333 * (maxMIDI-69)));
 
     float curr_f;
@@ -212,8 +203,6 @@
             }
         }
     }
-
-
 }
 
 static
@@ -350,7 +339,7 @@
     return chordvalues;
 }
 
-vector<string> chordDictionary(vector<float> *mchorddict, vector<vector<int> > *m_chordnotes, float boostN, float useHarte) {    
+vector<string> chordDictionary(vector<float> *mchorddict, vector<vector<int> > *m_chordnotes, float boostN, float harte_syntax) {    
     
     typedef tokenizer<char_separator<char> > Tok;
     char_separator<char> sep(",; ","=");
@@ -388,7 +377,7 @@
 	
 	vector<float> tempChordDict = staticChordvalues();
     vector<string> tempChordNames = staticChordnames();
-	if (useHarte == 1.0) {
+	if (harte_syntax == 1.0) {
 		tempChordNames.erase(tempChordNames.begin(),tempChordNames.begin()+tempChordNames.size()/2);
 	} else {
 		tempChordNames.erase(tempChordNames.begin()+tempChordNames.size()/2,tempChordNames.begin()+tempChordNames.size());
@@ -435,7 +424,7 @@
             string slashNotation = "";
             for (int kSemitone = 1; kSemitone < 12; kSemitone++) {
                 if (tempChordDict[24*iType+(kSemitone) % 12] > 0.99) {
-					if (useHarte == 0.0) {
+					if (harte_syntax == 0.0) {
 						slashNotation = bassnames[iSemitone][kSemitone];
 					} else {
 						slashNotation = bassnames[12][kSemitone];
--- a/chromamethods.h	Thu Mar 31 13:51:45 2011 +0100
+++ b/chromamethods.h	Thu Mar 31 14:26:53 2011 +0100
@@ -29,7 +29,7 @@
 
 extern std::vector<float> SpecialConvolution(std::vector<float> convolvee, std::vector<float> kernel);
 extern void dictionaryMatrix(float* dm, float s_param);
-extern std::vector<std::string> chordDictionary(std::vector<float> *mchorddict, std::vector<std::vector<int> > *m_chordnotes, float boostN, float useHarte);
+extern std::vector<std::string> chordDictionary(std::vector<float> *mchorddict, std::vector<std::vector<int> > *m_chordnotes, float boostN, float harte_syntax);
 extern bool logFreqMatrix(int fs, int blocksize, float *outmatrix);
 
 static const char* notenames[24] = {