changeset 112:846b552ea3b0 monophonicness

Harte syntax as option in Chordino
author Matthias Mauch <mail@matthiasmauch.net>
date Tue, 29 Mar 2011 15:12:19 +0100
parents 96cea9c05046
children 5bcba43e2317
files Chordino.cpp NNLSBase.cpp NNLSBase.h chord.dict chord.dictold chromamethods.cpp chromamethods.h
diffstat 7 files changed, 95 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/Chordino.cpp	Tue Mar 29 13:56:02 2011 +0100
+++ b/Chordino.cpp	Tue Mar 29 15:12:19 2011 +0100
@@ -156,6 +156,20 @@
     boostn.isQuantized = false;
     list.push_back(boostn);
 
+    ParameterDescriptor usehartesyntax;
+    usehartesyntax.identifier = "usehartesyntax";
+    usehartesyntax.name = "use Harte syntax";
+    usehartesyntax.description = "Use the chord syntax proposed by Harte";
+    usehartesyntax.unit = "";
+    usehartesyntax.minValue = 0.0;
+    usehartesyntax.maxValue = 1.0;
+    usehartesyntax.defaultValue = 0.0;
+    usehartesyntax.isQuantized = true;
+	usehartesyntax.quantizeStep = 1.0;
+	usehartesyntax.valueNames.push_back("no");
+    usehartesyntax.valueNames.push_back("yes");
+    list.push_back(usehartesyntax);
+
     return list;
 }
 
@@ -245,7 +259,7 @@
     if (!NNLSBase::initialise(channels, stepSize, blockSize)) {
         return false;
     }
-    m_chordnames = chordDictionary(&m_chorddict, &m_chordnotes, m_boostN);
+    m_chordnames = chordDictionary(&m_chorddict, &m_chordnotes, m_boostN, m_useHarte);
     return true;
 }
 
--- a/NNLSBase.cpp	Tue Mar 29 13:56:02 2011 +0100
+++ b/NNLSBase.cpp	Tue Mar 29 15:12:19 2011 +0100
@@ -51,6 +51,7 @@
     m_rollon(0.0),
     m_boostN(0.1),
 	m_s(0.7),
+	m_useHarte(0),
 	sinvalues(0),
 	cosvalues(0)
 {
@@ -260,6 +261,10 @@
         return m_useHMM;
     }
     
+	if (identifier == "usehartesyntax") {
+		return m_useHarte;
+	}
+
     return 0;
     
 }
@@ -318,6 +323,10 @@
     if (identifier == "rollon") {
         m_rollon = value;
     }
+
+	if (identifier == "usehartesyntax") {
+		m_useHarte = value;
+	}
 }
 
 NNLSBase::ProgramList
--- a/NNLSBase.h	Tue Mar 29 13:56:02 2011 +0100
+++ b/NNLSBase.h	Tue Mar 29 15:12:19 2011 +0100
@@ -76,6 +76,7 @@
     float m_rollon;
     float m_boostN;
     float m_s;
+	float m_useHarte;
     vector<float> hw;
     vector<float> sinvalues;
     vector<float> cosvalues;
--- a/chord.dict	Tue Mar 29 13:56:02 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-### Comma-Separated Chord Dictionaries
-# 
-# field 1 is chord type name,
-# fields 2-25 indicate whether a pitch class is present (1) or not (0) :
-#   - fields 2-13 correspond to bass pitch classes A through Ab
-#   - fields 14-25 correspond to chord pitch classes A through Ab
-
-### Advanced Learners Chord Dictionary
-# =1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
-# =0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
-# m=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
-# m=0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
-# dim7=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0
-# dim7=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0
-# 6=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0
-# 7=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0
-# maj7=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1
-# m7=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0
-# m6=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,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,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
-=0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
-:dim=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0
-:aug=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0
-=0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
-=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0 
-:7=0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0
-# sus4=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,0,0,0
-
-### Rock'n'Roll
-# :1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
-# m:1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/chord.dictold	Tue Mar 29 15:12:19 2011 +0100
@@ -0,0 +1,31 @@
+### Comma-Separated Chord Dictionaries
+# 
+# field 1 is chord type name,
+# fields 2-25 indicate whether a pitch class is present (1) or not (0) :
+#   - fields 2-13 correspond to bass pitch classes A through Ab
+#   - fields 14-25 correspond to chord pitch classes A through Ab
+
+### Advanced Learners Chord Dictionary
+=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
+=0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
+m=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
+m=0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
+dim7=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0
+dim7=1,0,0,0,0,0,0,0,0,0,0,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     chordnames.push_back("m");//=0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
-    chordnames.push_back("dim7");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0
-    chordnames.push_back("dim7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0
+    chordnames.push_back("hdim7");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0
+    chordnames.push_back("hdim7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0
     chordnames.push_back("6");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0
     chordnames.push_back("7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0
     chordnames.push_back("maj7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1
@@ -299,6 +299,26 @@
     chordnames.push_back("");//=0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
     chordnames.push_back("");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0 
     chordnames.push_back("7");//=0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0
+	// from here: Harte syntax
+    chordnames.push_back("");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
+    chordnames.push_back("");// =0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
+    chordnames.push_back(":min");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
+    chordnames.push_back(":min");//=0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0
+    chordnames.push_back(":hdim7");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0
+    chordnames.push_back(":hdim7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,1,0
+    chordnames.push_back(":maj6");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0
+    chordnames.push_back(":7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0
+    chordnames.push_back(":maj7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1
+    chordnames.push_back(":min7");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0
+    chordnames.push_back(":min6");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,1,0,0
+    chordnames.push_back("");//=0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
+    chordnames.push_back("");//=0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
+    chordnames.push_back("");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0
+    chordnames.push_back(":aug");//=1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0
+    chordnames.push_back("");//=0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0
+    chordnames.push_back("");//=0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0 
+    chordnames.push_back(":7");//=0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0
+	// TODO: what about a dim chord?
     return chordnames;
 }
 
@@ -330,7 +350,7 @@
     return chordvalues;
 }
 
-vector<string> chordDictionary(vector<float> *mchorddict, vector<vector<int> > *m_chordnotes, float boostN) {    
+vector<string> chordDictionary(vector<float> *mchorddict, vector<vector<int> > *m_chordnotes, float boostN, float useHarte) {    
     
     typedef tokenizer<char_separator<char> > Tok;
     char_separator<char> sep(",; ","=");
@@ -366,8 +386,14 @@
     // int iElement = 0;
     int nChord = 0;
 	
+	vector<float> tempChordDict = staticChordvalues();
     vector<string> tempChordNames = staticChordnames();
-    vector<float> tempChordDict = staticChordvalues();
+	if (useHarte == 1.0) {
+		tempChordNames.erase(tempChordNames.begin(),tempChordNames.begin()+tempChordNames.size()/2);
+	} else {
+		tempChordNames.erase(tempChordNames.begin()+tempChordNames.size()/2,tempChordNames.begin()+tempChordNames.size());
+	}
+
     vector<string> loadedChordNames;
     vector<float> loadedChordDict;
     if (hasExternalDictinoary && chordDictFile.is_open()) {
@@ -409,7 +435,11 @@
             string slashNotation = "";
             for (int kSemitone = 1; kSemitone < 12; kSemitone++) {
                 if (tempChordDict[24*iType+(kSemitone) % 12] > 0.99) {
-                    slashNotation = bassnames[iSemitone][kSemitone];
+					if (useHarte == 0.0) {
+						slashNotation = bassnames[iSemitone][kSemitone];
+					} else {
+						slashNotation = bassnames[12][kSemitone];
+					}                    
                 }
             }
             if (slashNotation=="") tempchordnotes.push_back(MIDI_basenote + (iSemitone+12) % 12);
--- a/chromamethods.h	Tue Mar 29 13:56:02 2011 +0100
+++ b/chromamethods.h	Tue Mar 29 15:12:19 2011 +0100
@@ -29,14 +29,14 @@
 
 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);
+extern std::vector<std::string> chordDictionary(std::vector<float> *mchorddict, std::vector<std::vector<int> > *m_chordnotes, float boostN, float useHarte);
 extern bool logFreqMatrix(int fs, int blocksize, float *outmatrix);
 
 static const char* notenames[24] = {
     "A  (bass)","Bb (bass)","B  (bass)","C  (bass)","C# (bass)","D  (bass)","Eb (bass)","E  (bass)","F  (bass)","F# (bass)","G  (bass)","Ab (bass)",
     "A","Bb","B","C","C#","D","Eb","E","F","F#","G","Ab"};
 
-static const char* bassnames[12][12] ={
+static const char* bassnames[13][12] ={
     {"A","","B","C","C#","D","","E","","F#","G","G#"},
     {"Bb","","C","Db","D","Eb","","F","","G","Ab","A"},
     {"B","","C#","D","D#","E","","F#","","G#","A","A#"},
@@ -48,7 +48,8 @@
     {"F","","G","Ab","A","Bb","","C","","D","Eb","E"},
     {"F#","","G#","A","A#","B","","C#","","D#","E","E#"},
     {"G","","A","Bb","B","C","","D","","E","F","F#"},
-    {"Ab","","Bb","Cb","C","Db","","Eb","","F","Gb","G"}
+    {"Ab","","Bb","Cb","C","Db","","Eb","","F","Gb","G"},
+	{"1","","2","b3","3","4","","5","","6","b7","7"}
 };
 
 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};