Mercurial > hg > silvet
changeset 183:59e3cca75b8d
Add some further parameters to the instrument pack
author | Chris Cannam |
---|---|
date | Fri, 23 May 2014 18:17:59 +0100 |
parents | 825193ef09d2 |
children | 78212f764251 ec19a15bee82 |
files | src/EM.h src/Instruments.cpp src/Instruments.h src/Silvet.cpp |
diffstat | 4 files changed, 36 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/EM.h Thu May 22 15:06:37 2014 +0100 +++ b/src/EM.h Fri May 23 18:17:59 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 Thu May 22 15:06:37 2014 +0100 +++ b/src/Instruments.cpp Fri May 23 18:17:59 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 Thu May 22 15:06:37 2014 +0100 +++ b/src/Instruments.h Fri May 23 18:17:59 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 Thu May 22 15:06:37 2014 +0100 +++ b/src/Silvet.cpp Fri May 23 18:17:59 2014 +0100 @@ -480,6 +480,8 @@ EM em(&pack, m_hqMode); + em.setPitchSparsity(pack.pitchSparsity); + for (int j = 0; j < iterations; ++j) { em.iterate(filtered.at(i).data()); } @@ -633,19 +635,13 @@ // Threshold for level and reduce number of candidate pitches - int polyphony = 5; - - //!!! make this a parameter (was 4.8, try adjusting, compare levels against matlab code) - double threshold = 6; -// double threshold = 4.8; - typedef std::multimap<double, int> ValueIndexMap; ValueIndexMap strengths; for (int j = 0; j < pack.templateNoteCount; ++j) { double strength = filtered[j]; - if (strength < threshold) continue; + if (strength < pack.levelThreshold) continue; strengths.insert(ValueIndexMap::value_type(strength, j)); } @@ -654,7 +650,7 @@ map<int, double> active; map<int, int> activeShifts; - while (int(active.size()) < polyphony && si != strengths.begin()) { + while (int(active.size()) < pack.maxPolyphony && si != strengths.begin()) { --si;