changeset 53:71be7023e9d6

Merge
author Chris Cannam <chris.cannam@eecs.qmul.ac.uk>
date Thu, 06 Mar 2014 15:48:46 +0000
parents 83ee5e6d1577 (current diff) 24943b76a109 (diff)
children 619c01e3467e a2102b3641b9
files
diffstat 7 files changed, 33 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.osx	Thu Mar 06 15:45:36 2014 +0000
+++ b/Makefile.osx	Thu Mar 06 15:48:46 2014 +0000
@@ -1,4 +1,4 @@
-ARCHFLAGS := -arch x86_64 -arch i386 -mmacosx-version-min=10.7
+ARCHFLAGS := -arch x86_64 -mmacosx-version-min=10.7
 CFLAGS := $(ARCHFLAGS) -O3 -I../vamp-plugin-sdk -I/usr/local/boost -Wall -fPIC 
 CXXFLAGS := $(CFLAGS)
 
--- a/MonoPitch.cpp	Thu Mar 06 15:45:36 2014 +0000
+++ b/MonoPitch.cpp	Thu Mar 06 15:48:46 2014 +0000
@@ -40,12 +40,6 @@
     {
         obsProb.push_back(hmm.calculateObsProb(pitchProb[iFrame]));
     }
-    for (size_t i = 0; i < obsProb[0].size(); ++i) {
-        obsProb[0][i] = 0;
-    }
-    obsProb[0][obsProb[0].size()-1] = 1;
-    
-    // std::cerr << "after observation prob calculation" << std::endl;
     
     vector<double> *scale = new vector<double>(pitchProb.size());
     
--- a/MonoPitchHMM.cpp	Thu Mar 06 15:45:36 2014 +0000
+++ b/MonoPitchHMM.cpp	Thu Mar 06 15:48:46 2014 +0000
@@ -23,7 +23,7 @@
 
 MonoPitchHMM::MonoPitchHMM() :
 m_minFreq(55),
-m_nBPS(10),
+m_nBPS(5),
 m_nPitch(0),
 m_transitionWidth(0),
 m_selfTrans(0.99),
@@ -32,15 +32,12 @@
 {
     m_transitionWidth = 5*(m_nBPS/2) + 1;
     m_nPitch = 48 * m_nBPS;
-    m_freqs = vector<double>(2*m_nPitch+1);
+    m_freqs = vector<double>(2*m_nPitch);
     for (size_t iPitch = 0; iPitch < m_nPitch; ++iPitch)
     {
         m_freqs[iPitch] = m_minFreq * std::pow(2, iPitch * 1.0 / (12 * m_nBPS));
-        // m_freqs[iPitch+m_nPitch] = -2;
         m_freqs[iPitch+m_nPitch] = -m_freqs[iPitch];
-        // std::cerr << "pitch " << iPitch << " = " << m_freqs[iPitch] << std::endl;
     }
-    m_freqs[2*m_nPitch] = -1;
     build();
 }
 
@@ -84,8 +81,7 @@
 MonoPitchHMM::build()
 {
     // INITIAL VECTOR
-    init = vector<double>(2*m_nPitch+1);
-    init[2*m_nPitch] = 1; // force first frame to be unvoiced.
+    init = vector<double>(2*m_nPitch, 1.0 / 2*m_nPitch);
     
     // TRANSITIONS
     for (size_t iPitch = 0; iPitch < m_nPitch; ++iPitch)
@@ -139,9 +135,9 @@
         // transProb.push_back(1-m_selfTrans);
         
         // TRANSITION FROM UNVOICED TO PITCH
-        from.push_back(2*m_nPitch);
-        to.push_back(iPitch+m_nPitch);
-        transProb.push_back(1.0/m_nPitch);
+        // from.push_back(2*m_nPitch);
+        // to.push_back(iPitch+m_nPitch);
+        // transProb.push_back(1.0/m_nPitch);
     }
     // UNVOICED SELFTRANSITION
     // from.push_back(2*m_nPitch);
--- a/PYIN.cpp	Thu Mar 06 15:45:36 2014 +0000
+++ b/PYIN.cpp	Thu Mar 06 15:48:46 2014 +0000
@@ -361,7 +361,21 @@
     for (size_t i = 0; i < m_blockSize; ++i) dInputBuffers[i] = inputBuffers[0][i];
     
     Yin::YinOutput yo = m_yin.processProbabilisticYin(dInputBuffers);
-    
+    delete [] dInputBuffers;
+
+    // First, get the things out of the way that we don't want to output 
+    // immediately, but instead save for later.
+    vector<pair<double, double> > tempPitchProb;
+    for (size_t iCandidate = 0; iCandidate < yo.freqProb.size(); ++iCandidate)
+    {
+        double tempPitch = 12 * std::log(yo.freqProb[iCandidate].first/440)/std::log(2.) + 69;
+        tempPitchProb.push_back(pair<double, double>
+            (tempPitch, yo.freqProb[iCandidate].second));
+    }
+    m_pitchProb.push_back(tempPitchProb);
+    m_timestamp.push_back(timestamp);
+
+    // F0 CANDIDATES
     Feature f;
     f.hasTimestamp = true;
     f.timestamp = timestamp;
@@ -371,6 +385,7 @@
     }
     fs[m_oF0Candidates].push_back(f);
     
+    // VOICEDPROB
     f.values.clear();
     float voicedProb = 0;
     for (size_t i = 0; i < yo.freqProb.size(); ++i)
@@ -384,6 +399,7 @@
     f.values.push_back(voicedProb);
     fs[m_oVoicedProb].push_back(f);
 
+    // SALIENCE -- maybe this should eventually disappear
     f.values.clear();
     float salienceSum = 0;
     for (size_t iBin = 0; iBin < yo.salience.size(); ++iBin)
@@ -393,19 +409,6 @@
     }
     fs[m_oCandidateSalience].push_back(f);
 
-    delete [] dInputBuffers;
-
-    vector<pair<double, double> > tempPitchProb;
-    for (size_t iCandidate = 0; iCandidate < yo.freqProb.size(); ++iCandidate)
-    {
-        double tempPitch = 12 * std::log(yo.freqProb[iCandidate].first/440)/std::log(2.) + 69;
-        tempPitchProb.push_back(pair<double, double>
-            (tempPitch, yo.freqProb[iCandidate].second));
-    }
-    m_pitchProb.push_back(tempPitchProb);
-        
-    m_timestamp.push_back(timestamp);
-
     return fs;
 }
 
@@ -423,9 +426,7 @@
 
     // MONO-PITCH STUFF
     MonoPitch mp;
-//    std::cerr << "before viterbi" << std::endl;
     vector<float> mpOut = mp.process(m_pitchProb);
-    // std::cerr << "after viterbi " << mpOut.size() << " "<< m_timestamp.size() << std::endl;
     for (size_t iFrame = 0; iFrame < mpOut.size(); ++iFrame)
     {
         if (mpOut[iFrame] < 0 && (m_outputUnvoiced==0)) continue;
@@ -433,7 +434,7 @@
         f.values.clear();
         if (m_outputUnvoiced == 1)
         {
-            f.values.push_back(abs(mpOut[iFrame]));
+            f.values.push_back(fabs(mpOut[iFrame]));
         } else {
             f.values.push_back(mpOut[iFrame]);
         }
--- a/SparseHMM.cpp	Thu Mar 06 15:45:36 2014 +0000
+++ b/SparseHMM.cpp	Thu Mar 06 15:48:46 2014 +0000
@@ -104,7 +104,7 @@
             scale->push_back(1.0/deltasum);
         } else
         {
-            std::cerr << "WARNING: Viterbi has been fed some zero probabilities, at least they become zero in combination with the model." << std::endl;
+            std::cerr << "WARNING: Viterbi has been fed some zero probabilities, at least they become zero at frame " <<  iFrame << " in combination with the model." << std::endl;
             for (size_t iState = 0; iState < nState; ++iState)
             {
                 oldDelta[iState] = 1.0/nState;
@@ -132,10 +132,10 @@
         path[iFrame] = psi[iFrame+1][path[iFrame+1]];
     }
     
-    for (size_t iState = 0; iState < nState; ++iState)
-    {
-        // std::cerr << psi[2][iState] << std::endl;
-    }
+    // for (size_t iState = 0; iState < nState; ++iState)
+    // {
+    //     // std::cerr << psi[2][iState] << std::endl;
+    // }
     
     return path;
 }
--- a/VampYin.cpp	Thu Mar 06 15:45:36 2014 +0000
+++ b/VampYin.cpp	Thu Mar 06 15:48:46 2014 +0000
@@ -338,13 +338,13 @@
         }
     } else if (m_outputUnvoiced == 1.0f)
     {
-        if (abs(yo.f0) < m_fmax && abs(yo.f0) > m_fmin) {
-            f.values.push_back(abs(yo.f0));
+        if (fabs(yo.f0) < m_fmax && fabs(yo.f0) > m_fmin) {
+            f.values.push_back(fabs(yo.f0));
             fs[m_outNoF0].push_back(f);
         }
     } else
     {
-        if (abs(yo.f0) < m_fmax && abs(yo.f0) > m_fmin) {
+        if (fabs(yo.f0) < m_fmax && fabs(yo.f0) > m_fmin) {
             f.values.push_back(yo.f0);
             fs[m_outNoF0].push_back(f);
         }
Binary file testdata/DontTellMe.wav has changed