changeset 27:6ccea73d6a88

removing last (?) remnants of that weird little dummy state that created unexpected zeros in Viterbi
author matthiasm
date Tue, 21 Jan 2014 21:41:00 +0000
parents 0ce1c877f73f
children 401855ab368e
files MonoPitch.cpp PYIN.cpp SparseHMM.cpp
diffstat 3 files changed, 24 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/MonoPitch.cpp	Tue Jan 21 18:34:15 2014 +0000
+++ b/MonoPitch.cpp	Tue Jan 21 21:41:00 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/PYIN.cpp	Tue Jan 21 18:34:15 2014 +0000
+++ b/PYIN.cpp	Tue Jan 21 21:41:00 2014 +0000
@@ -354,6 +354,7 @@
 PYIN::FeatureSet
 PYIN::process(const float *const *inputBuffers, RealTime timestamp)
 {
+    std::cerr << "new pyin new pyin" << std::endl;
     timestamp = timestamp + Vamp::RealTime::frame2RealTime(m_blockSize/4, lrintf(m_inputSampleRate));
     FeatureSet fs;
     
@@ -361,7 +362,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 +386,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 +400,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,25 +410,13 @@
     }
     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;
 }
 
 PYIN::FeatureSet
 PYIN::getRemainingFeatures()
 {
+    std::cerr << m_timestamp[0] << std::endl;
     FeatureSet fs;
     Feature f;
     f.hasTimestamp = true;
--- a/SparseHMM.cpp	Tue Jan 21 18:34:15 2014 +0000
+++ b/SparseHMM.cpp	Tue Jan 21 21:41:00 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;
 }