changeset 185:78212f764251 noteagent

Merge from default branch
author Chris Cannam
date Wed, 28 May 2014 14:56:01 +0100
parents 9b9cdfccbd14 (current diff) 59e3cca75b8d (diff)
children 9d70d687e4eb
files src/Silvet.cpp
diffstat 4 files changed, 35 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/EM.h	Wed May 28 14:54:01 2014 +0100
+++ b/src/EM.h	Wed May 28 14:56:01 2014 +0100
@@ -26,6 +26,8 @@
     EM(const InstrumentPack *pack, bool useShifts); // pack must outlive me
     ~EM();
 
+    void setPitchSparsity(float sparsity) { m_pitchSparsity = sparsity; }
+
     int getBinCount() const { return m_binCount; }
     int getNoteCount() const { return m_noteCount; }
     int getSourceCount() const { return m_sourceCount; }
@@ -90,9 +92,9 @@
     const int m_binCount;
     const int m_sourceCount;
     
-    const float m_pitchSparsity;
-    const float m_shiftSparsity;
-    const float m_sourceSparsity;
+    float m_pitchSparsity;
+    float m_shiftSparsity;
+    float m_sourceSparsity;
 
     const int m_lowestPitch;
     const int m_highestPitch;
--- a/src/Instruments.cpp	Wed May 28 14:54:01 2014 +0100
+++ b/src/Instruments.cpp	Wed May 28 14:56:01 2014 +0100
@@ -131,6 +131,8 @@
 			 silvet_templates_highest_note,
 			 "Piano",
 			 pianoTemplates);
+    piano.maxPolyphony = 8;
+    piano.levelThreshold = 3;
     if (isOK(piano)) {
 	ii.push_back(piano);
     }
@@ -145,16 +147,21 @@
 	Templates t = templatesFor(simpleInstruments[i+1]);
 	tt.push_back(t);
 	allTemplates.push_back(t);
-	if (isString(i)) {
-	    stringTemplates.push_back(t);
-	}
-	if (isWind(i)) {
-	    windTemplates.push_back(t);
-	}
 	InstrumentPack instr(t.lowestNote,
 			     t.highestNote,
 			     simpleInstruments[i],
 			     tt);
+        instr.pitchSparsity = 1.5;
+	if (isString(i)) {
+            instr.maxPolyphony = 2;
+            instr.levelThreshold = 3;
+	    stringTemplates.push_back(t);
+	}
+	if (isWind(i)) {
+            instr.maxPolyphony = 1;
+            instr.levelThreshold = 5;
+	    windTemplates.push_back(t);
+	}
 	if (isOK(instr)) {
 	    ii.push_back(instr);
 	}
@@ -164,6 +171,8 @@
 		       silvet_templates_highest_note,
 		       "Multiple or unknown instruments",
 		       allTemplates);
+    all.maxPolyphony = 5;
+    all.levelThreshold = 6;//!!! but this does need to be a parameter too, or else we need to be able to detect very quiet stuff somehow
     if (isOK(all)) {
 	ii.insert(ii.begin(), all);
     }
@@ -172,6 +181,8 @@
 			   silvet_templates_highest_note, // violin
 			   "String ensemble",
 			   stringTemplates);
+    strings.maxPolyphony = 5;
+    strings.levelThreshold = 3;
     if (isOK(strings)) {
 	ii.push_back(strings);
     }
@@ -180,6 +191,8 @@
 			 silvet_templates_highest_note,  // flute
 			 "Wind ensemble",
 			 windTemplates);
+    winds.maxPolyphony = 5;
+    winds.levelThreshold = 5;
     if (isOK(winds)) {
 	ii.push_back(winds);
     }
--- a/src/Instruments.h	Wed May 28 14:54:01 2014 +0100
+++ b/src/Instruments.h	Wed May 28 14:56:01 2014 +0100
@@ -39,6 +39,11 @@
 
     int lowestNote;
     int highestNote;
+
+    int maxPolyphony; // realistic practical limit, not a theoretical one
+    float pitchSparsity;
+    float levelThreshold;
+
     std::string name;
 
     struct Templates {
@@ -57,6 +62,9 @@
 		   std::vector<Templates> tt) :
 	lowestNote(lowest),
 	highestNote(highest),
+        maxPolyphony(5),
+        pitchSparsity(1.1),
+        levelThreshold(5),
 	name(n),
 	templates(tt) { }
 };
--- a/src/Silvet.cpp	Wed May 28 14:54:01 2014 +0100
+++ b/src/Silvet.cpp	Wed May 28 14:56:01 2014 +0100
@@ -499,6 +499,8 @@
 
         EM em(&pack, m_hqMode);
 
+        em.setPitchSparsity(pack.pitchSparsity);
+
         for (int j = 0; j < iterations; ++j) {
             em.iterate(filtered.at(i).data());
         }
@@ -648,7 +650,7 @@
         filtered.push_back(m_postFilter[j]->get());
     }
 
-    double threshold = 1;
+    double threshold = 1; //!!! pack.levelThreshold
 
     double columnDuration = 1.0 / m_colsPerSec;
     int postFilterLatency = int(m_postFilter[0]->getSize() / 2);