changeset 117:1b75e5fd4b99 tony

sorted out precise timing, chose parameters
author matthiasm
date Mon, 23 Mar 2015 17:28:34 +0000
parents e9b99e85b929
children 1629209f5bf2
files PYinVamp.cpp Yin.cpp Yin.h
diffstat 3 files changed, 25 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- 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());
--- 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<double> 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;
+}
--- 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;
 };