# HG changeset patch # User Chris Cannam # Date 1401351675 -3600 # Node ID 462b165c8c0f42d0347c3a01d5e04cbd367ace92 # Parent 1697457458b7141e5862aa6e281d490721e7a68b Emit "MIDI-compatible" frequencies only, unless in fine tuning mode diff -r 1697457458b7 -r 462b165c8c0f src/AgentFeederPoly.h --- a/src/AgentFeederPoly.h Wed May 28 15:16:00 2014 +0100 +++ b/src/AgentFeederPoly.h Thu May 29 09:21:15 2014 +0100 @@ -22,7 +22,7 @@ #include #include -#define DEBUG_FEEDER 1 +//#define DEBUG_FEEDER 1 /** * Take a series of observations or estimates (one at a time) and feed diff -r 1697457458b7 -r 462b165c8c0f src/NoteHypothesis.cpp --- a/src/NoteHypothesis.cpp Wed May 28 15:16:00 2014 +0100 +++ b/src/NoteHypothesis.cpp Thu May 29 09:21:15 2014 +0100 @@ -28,7 +28,7 @@ using std::cerr; using std::endl; -#define DEBUG_NOTE_HYPOTHESIS 1 +//#define DEBUG_NOTE_HYPOTHESIS 1 NoteHypothesis::NoteHypothesis() { @@ -119,6 +119,7 @@ return ((int)m_pending.size() > lengthRequired); } +#ifdef DEBUG_NOTE_HYPOTHESIS static void printState(NoteHypothesis::State s) { switch (s) { @@ -129,6 +130,7 @@ case NoteHypothesis::Expired: cerr << "Expired"; break; } } +#endif bool NoteHypothesis::accept(Observation s) diff -r 1697457458b7 -r 462b165c8c0f src/Silvet.cpp --- a/src/Silvet.cpp Wed May 28 15:16:00 2014 +0100 +++ b/src/Silvet.cpp Thu May 29 09:21:15 2014 +0100 @@ -334,6 +334,15 @@ return float(27.5 * pow(2.0, (note + pshift) / 12.0)); } +float +Silvet::roundToMidiFrequency(float freq) const +{ + // n is our note number, not actually MIDI note number as we have + // a different origin + float n = 12.0 * (log(freq / 27.5) / log(2.0)); + return 27.5 * pow(2.0, round(n) / 12.0); +} + bool Silvet::initialise(size_t channels, size_t stepSize, size_t blockSize) { @@ -397,7 +406,8 @@ } m_postFilter.clear(); for (int i = 0; i < m_instruments[0].templateNoteCount; ++i) { - m_postFilter.push_back(new MedianFilter(3)); +//!!! m_postFilter.push_back(new MedianFilter(3)); + m_postFilter.push_back(new MedianFilter(1));//!!! } m_columnCountIn = 0; @@ -709,13 +719,18 @@ int velocity = n.confidence * 127; if (velocity > 127) velocity = 127; + float freq = n.freq; + if (!m_fineTuning) { + freq = roundToMidiFrequency(freq); + } + Feature f; f.hasTimestamp = true; f.hasDuration = true; f.timestamp = n.time; f.duration = n.duration; f.values.clear(); - f.values.push_back(n.freq); + f.values.push_back(freq); f.values.push_back(velocity); // f.label = noteName(note, partShift, shiftCount); noteFeatures.push_back(f); diff -r 1697457458b7 -r 462b165c8c0f src/Silvet.h --- a/src/Silvet.h Wed May 28 15:16:00 2014 +0100 +++ b/src/Silvet.h Thu May 29 09:21:15 2014 +0100 @@ -102,6 +102,7 @@ string noteName(int n, int shift, int shiftCount) const; float noteFrequency(int n, int shift, int shiftCount) const; + float roundToMidiFrequency(float f) const; int m_blockSize; int m_columnCountIn;