# HG changeset patch # User matthiasm # Date 1427131714 0 # Node ID 1b75e5fd4b99c635a3bf087defce25aea408ccab # Parent e9b99e85b92915da222bbd30496a4b3583f7750f sorted out precise timing, chose parameters diff -r e9b99e85b929 -r 1b75e5fd4b99 PYinVamp.cpp --- a/PYinVamp.cpp Mon Mar 23 16:37:28 2015 +0000 +++ b/PYinVamp.cpp Mon Mar 23 17:28:34 2015 +0000 @@ -46,9 +46,9 @@ m_threshDistr(2.0f), m_outputUnvoiced(0.0f), m_preciseTime(0.0f), - m_lowAmp(0.1), - m_onsetSensitivity(0.6f), - m_pruneThresh(0.07f), + m_lowAmp(0.1f), + m_onsetSensitivity(0.7f), + m_pruneThresh(0.1f), m_pitchProb(0), m_timestamp(0), m_level(0) @@ -198,7 +198,7 @@ d.unit = ""; d.minValue = 0.0f; d.maxValue = 1.0f; - d.defaultValue = 0.5f; + d.defaultValue = 0.7f; d.isQuantized = false; list.push_back(d); @@ -209,7 +209,7 @@ d.unit = ""; d.minValue = 0.0f; d.maxValue = 0.2f; - d.defaultValue = 0.05f; + d.defaultValue = 0.1f; d.isQuantized = false; list.push_back(d); @@ -418,9 +418,7 @@ { m_yin.setThresholdDistr(m_threshDistr); m_yin.setFrameSize(m_blockSize); - - //TODO: Restore this! (MM) - //!!! m_yin.setFast(!m_preciseTime); + m_yin.setFast(!m_preciseTime); m_pitchProb.clear(); m_timestamp.clear(); @@ -589,7 +587,7 @@ } else { // not currently voiced if (oldIsVoiced == 1) // end of note { - // std::cerr << notePitchTrack.size() << " " << minNoteFrames << std::endl; + std::cerr << notePitchTrack.size() << " " << minNoteFrames << std::endl; if (notePitchTrack.size() >= minNoteFrames) { std::sort(notePitchTrack.begin(), notePitchTrack.end()); diff -r e9b99e85b929 -r 1b75e5fd4b99 Yin.cpp --- a/Yin.cpp Mon Mar 23 16:37:28 2015 +0000 +++ b/Yin.cpp Mon Mar 23 17:28:34 2015 +0000 @@ -25,12 +25,13 @@ using std::vector; -Yin::Yin(size_t frameSize, size_t inputSampleRate, double thresh) : +Yin::Yin(size_t frameSize, size_t inputSampleRate, double thresh, bool fast) : m_frameSize(frameSize), m_inputSampleRate(inputSampleRate), m_thresh(thresh), m_threshDistr(2), - m_yinBufferSize(frameSize/2) + m_yinBufferSize(frameSize/2), + m_fast(fast) { if (frameSize & (frameSize-1)) { // throw "N must be a power of two"; @@ -47,7 +48,9 @@ double* yinBuffer = new double[m_yinBufferSize]; // calculate aperiodicity function for all periods - YinUtil::fastDifference(in, yinBuffer, m_yinBufferSize); + if (m_fast) YinUtil::fastDifference(in, yinBuffer, m_yinBufferSize); + else YinUtil::slowDifference(in, yinBuffer, m_yinBufferSize); + YinUtil::cumulativeDifference(yinBuffer, m_yinBufferSize); int tau = 0; @@ -86,7 +89,9 @@ double* yinBuffer = new double[m_yinBufferSize]; // calculate aperiodicity function for all periods - YinUtil::fastDifference(in, yinBuffer, m_yinBufferSize); + if (m_fast) YinUtil::fastDifference(in, yinBuffer, m_yinBufferSize); + else YinUtil::slowDifference(in, yinBuffer, m_yinBufferSize); + YinUtil::cumulativeDifference(yinBuffer, m_yinBufferSize); vector peakProbability = YinUtil::yinProb(yinBuffer, m_threshDistr, m_yinBufferSize); @@ -140,9 +145,9 @@ return 0; } -// int -// Yin::setRemoveUnvoiced(bool parameter) -// { -// m_removeUnvoiced = parameter; -// return 0; -// } +int +Yin::setFast(bool parameter) +{ + m_fast = parameter; + return 0; +} diff -r e9b99e85b929 -r 1b75e5fd4b99 Yin.h --- a/Yin.h Mon Mar 23 16:37:28 2015 +0000 +++ b/Yin.h Mon Mar 23 17:28:34 2015 +0000 @@ -31,7 +31,7 @@ class Yin { public: - Yin(size_t frameSize, size_t inputSampleRate, double thresh = 0.2); + Yin(size_t frameSize, size_t inputSampleRate, double thresh = 0.2, bool fast = true); virtual ~Yin(); struct YinOutput { @@ -53,6 +53,7 @@ int setThreshold(double parameter); int setThresholdDistr(float parameter); int setFrameSize(size_t frameSize); + int setFast(bool fast); // int setRemoveUnvoiced(bool frameSize); YinOutput process(const double *in) const; YinOutput processProbabilisticYin(const double *in) const; @@ -63,6 +64,7 @@ mutable double m_thresh; mutable size_t m_threshDistr; mutable size_t m_yinBufferSize; + mutable bool m_fast; // mutable bool m_removeUnvoiced; };