NO-OP: remove trailing whitespace
authorRobin Gareus <robin@gareus.org>
Tue, 3 Sep 2019 02:52:01 +0000 (04:52 +0200)
committerRobin Gareus <robin@gareus.org>
Tue, 3 Sep 2019 02:52:01 +0000 (04:52 +0200)
25 files changed:
libs/vamp-pyin/LocalCandidatePYIN.cpp
libs/vamp-pyin/LocalCandidatePYIN.h
libs/vamp-pyin/MeanFilter.h
libs/vamp-pyin/MonoNote.cpp
libs/vamp-pyin/MonoNote.h
libs/vamp-pyin/MonoNoteHMM.cpp
libs/vamp-pyin/MonoNoteHMM.h
libs/vamp-pyin/MonoNoteParameters.cpp
libs/vamp-pyin/MonoNoteParameters.h
libs/vamp-pyin/MonoPitch.cpp
libs/vamp-pyin/MonoPitch.h
libs/vamp-pyin/MonoPitchHMM.cpp
libs/vamp-pyin/MonoPitchHMM.h
libs/vamp-pyin/PYinVamp.cpp
libs/vamp-pyin/PYinVamp.h
libs/vamp-pyin/README [new file with mode: 0644]
libs/vamp-pyin/SparseHMM.cpp
libs/vamp-pyin/SparseHMM.h
libs/vamp-pyin/Yin.cpp
libs/vamp-pyin/Yin.h
libs/vamp-pyin/YinUtil.cpp
libs/vamp-pyin/YinUtil.h
libs/vamp-pyin/YinVamp.cpp
libs/vamp-pyin/YinVamp.h
libs/vamp-pyin/libmain.cpp

index 3d33a969fab4e2595d46612086aed2f50d387d31..35682b1887886d6a917b30f440c4639223a9a9d7 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -106,7 +106,7 @@ LocalCandidatePYIN::getPreferredBlockSize() const
     return 2048;
 }
 
-size_t 
+size_t
 LocalCandidatePYIN::getPreferredStepSize() const
 {
     return 256;
@@ -128,7 +128,7 @@ LocalCandidatePYIN::ParameterList
 LocalCandidatePYIN::getParameterDescriptors() const
 {
     ParameterList list;
-    
+
     ParameterDescriptor d;
 
     d.identifier = "threshdistr";
@@ -196,7 +196,7 @@ LocalCandidatePYIN::getParameter(string identifier) const
 }
 
 void
-LocalCandidatePYIN::setParameter(string identifier, float value) 
+LocalCandidatePYIN::setParameter(string identifier, float value)
 {
     if (identifier == "threshdistr")
     {
@@ -268,7 +268,7 @@ LocalCandidatePYIN::initialise(size_t channels, size_t stepSize, size_t blockSiz
     m_channels = channels;
     m_stepSize = stepSize;
     m_blockSize = blockSize;
-    
+
     reset();
 
     return true;
@@ -276,10 +276,10 @@ LocalCandidatePYIN::initialise(size_t channels, size_t stepSize, size_t blockSiz
 
 void
 LocalCandidatePYIN::reset()
-{    
+{
     m_pitchProb.clear();
     m_timestamp.clear();
-/*    
+/*
     std::cerr << "LocalCandidatePYIN::reset"
           << ", blockSize = " << m_blockSize
           << std::endl;
@@ -291,25 +291,25 @@ LocalCandidatePYIN::process(const float *const *inputBuffers, RealTime timestamp
 {
     int offset = m_preciseTime == 1.0 ? m_blockSize/2 : m_blockSize/4;
     timestamp = timestamp + Vamp::RealTime::frame2RealTime(offset, lrintf(m_inputSampleRate));
-    
+
     double *dInputBuffers = new double[m_blockSize];
     for (size_t i = 0; i < m_blockSize; ++i) dInputBuffers[i] = inputBuffers[0][i];
-    
+
     size_t yinBufferSize = m_blockSize/2;
     double* yinBuffer = new double[yinBufferSize];
     if (!m_preciseTime) YinUtil::fastDifference(dInputBuffers, yinBuffer, yinBufferSize);
-    else YinUtil::slowDifference(dInputBuffers, yinBuffer, yinBufferSize);    
-    
+    else YinUtil::slowDifference(dInputBuffers, yinBuffer, yinBufferSize);
+
     delete [] dInputBuffers;
 
     YinUtil::cumulativeDifference(yinBuffer, yinBufferSize);
-    
+
     float minFrequency = 60;
     float maxFrequency = 900;
-    vector<double> peakProbability = YinUtil::yinProb(yinBuffer, 
-                                                      m_threshDistr, 
-                                                      yinBufferSize, 
-                                                      m_inputSampleRate/maxFrequency, 
+    vector<double> peakProbability = YinUtil::yinProb(yinBuffer,
+                                                      m_threshDistr,
+                                                      yinBufferSize,
+                                                      m_inputSampleRate/maxFrequency,
                                                       m_inputSampleRate/minFrequency);
 
     vector<pair<double, double> > tempPitchProb;
@@ -317,7 +317,7 @@ LocalCandidatePYIN::process(const float *const *inputBuffers, RealTime timestamp
     {
         if (peakProbability[iBuf] > 0)
         {
-            double currentF0 = 
+            double currentF0 =
                 m_inputSampleRate * (1.0 /
                 YinUtil::parabolicInterpolation(yinBuffer, iBuf, yinBufferSize));
             double tempPitch = 12 * std::log(currentF0/440)/std::log(2.) + 69;
@@ -351,10 +351,10 @@ LocalCandidatePYIN::getRemainingFeatures()
     vector<float> freqSum = vector<float>(m_nCandidate);
     vector<float> freqNumber = vector<float>(m_nCandidate);
     vector<float> freqMean = vector<float>(m_nCandidate);
-    
+
     boost::math::normal normalDist(0, 8); // semitones sd
     float maxNormalDist = boost::math::pdf(normalDist, 0);
-    
+
     // Viterbi-decode multiple times with different frequencies emphasised
     for (size_t iCandidate = 0; iCandidate < m_nCandidate; ++iCandidate)
     {
@@ -369,8 +369,8 @@ LocalCandidatePYIN::getRemainingFeatures()
             float prob = 0;
             for (size_t iProb = 0; iProb < m_pitchProb[iFrame].size(); ++iProb)
             {
-                pitch = m_pitchProb[iFrame][iProb].first;                
-                prob  = m_pitchProb[iFrame][iProb].second * 
+                pitch = m_pitchProb[iFrame][iProb].first;
+                prob  = m_pitchProb[iFrame][iProb].second *
                     boost::math::pdf(normalDist, pitch-centrePitch) /
                     maxNormalDist * 2;
                 sumProb += prob;
@@ -404,13 +404,13 @@ LocalCandidatePYIN::getRemainingFeatures()
     for (size_t iCandidate = 0; iCandidate < m_nCandidate; ++iCandidate) {
         for (size_t jCandidate = iCandidate+1; jCandidate < m_nCandidate; ++jCandidate) {
             size_t countEqual = 0;
-            for (size_t iFrame = 0; iFrame < nFrame; ++iFrame) 
+            for (size_t iFrame = 0; iFrame < nFrame; ++iFrame)
             {
                 if ((pitchTracks[jCandidate][iFrame] == 0 && pitchTracks[iCandidate][iFrame] == 0) ||
                 fabs(pitchTracks[iCandidate][iFrame]/pitchTracks[jCandidate][iFrame]-1)<0.01)
                 countEqual++;
             }
-            // std::cerr << "proportion equal: " << (countEqual * 1.0 / nFrame) << std::endl;    
+            // std::cerr << "proportion equal: " << (countEqual * 1.0 / nFrame) << std::endl;
             if (countEqual * 1.0 / nFrame > 0.8) {
                 if (freqNumber[iCandidate] > freqNumber[jCandidate]) {
                     duplicates.push_back(jCandidate);
@@ -433,7 +433,7 @@ LocalCandidatePYIN::getRemainingFeatures()
     {
         bool isDuplicate = false;
         for (size_t i = 0; i < duplicates.size(); ++i) {
-    
+
             if (duplicates[i] == iCandidate) {
                 isDuplicate = true;
                 break;
@@ -446,11 +446,11 @@ LocalCandidatePYIN::getRemainingFeatures()
             candidateLabels[iCandidate] = convert.str();
             candidateActuals[iCandidate] = actualCandidateNumber;
             // std::cerr << iCandidate << " " << actualCandidateNumber << " " << freqNumber[iCandidate] << " " << freqMean[iCandidate] << std::endl;
-            for (size_t iFrame = 0; iFrame < nFrame; ++iFrame) 
+            for (size_t iFrame = 0; iFrame < nFrame; ++iFrame)
             {
                 if (pitchTracks[iCandidate][iFrame] > 0)
                 {
-                    // featureValues[m_timestamp[iFrame]][iCandidate] = 
+                    // featureValues[m_timestamp[iFrame]][iCandidate] =
                     //     pitchTracks[iCandidate][iFrame];
                     outputFrequencies[iFrame].push_back(pitchTracks[iCandidate][iFrame]);
                 } else {
@@ -473,7 +473,7 @@ LocalCandidatePYIN::getRemainingFeatures()
         f.values = outputFrequencies[iFrame];
         fs[0].push_back(f);
     }
-    
+
     // I stopped using Chris's map stuff below because I couldn't get my head around it
     //
     // for (map<RealTime, map<int, float> >::const_iterator i =
@@ -482,7 +482,7 @@ LocalCandidatePYIN::getRemainingFeatures()
     //     f.hasTimestamp = true;
     //     f.timestamp = i->first;
     //     int nextCandidate = candidateActuals.begin()->second;
-    //     for (map<int, float>::const_iterator j = 
+    //     for (map<int, float>::const_iterator j =
     //              i->second.begin(); j != i->second.end(); ++j) {
     //         while (candidateActuals[j->first] > nextCandidate) {
     //             f.values.push_back(0);
index 3648a3acddb32e325f92cb2db4395939cfab6aca..808cae417e0ae0fbe2d76a3fdf979e7ee395a1c0 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -61,9 +61,9 @@ protected:
     size_t m_blockSize;
     float m_fmin;
     float m_fmax;
-    
+
     mutable int m_oPitchTrackCandidates;
-    
+
     float m_threshDistr;
     float m_outputUnvoiced;
     float m_preciseTime;
index dc6f8a03b050de0951f972c70210e54730d2e59e..e20f82b835dc6028278dd52b2141ea04b5dc3190 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
index 82d94d205458eadce0d26ac1646618ca4c92e6d3..6c0e6343bb2d317c5d6183914dc1cff945af7ec2 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -38,13 +38,13 @@ MonoNote::process(const vector<vector<pair<double, double> > > pitchProb)
     {
         obsProb.push_back(hmm.calculateObsProb(pitchProb[iFrame]));
     }
-    
+
     vector<double> *scale = new vector<double>(pitchProb.size());
-    
-    vector<MonoNote::FrameOutput> out; 
-    
+
+    vector<MonoNote::FrameOutput> out;
+
     vector<int> path = hmm.decodeViterbi(obsProb, scale);
-    
+
     for (size_t iFrame = 0; iFrame < path.size(); ++iFrame)
     {
         double currPitch = -1;
index 554d5154218370c0bba17f1bb6d2dc8ce883a885..6e1711aa160fa41454950cb6ed2a852f5a39444c 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -28,7 +28,7 @@ class MonoNote {
 public:
     MonoNote();
     virtual ~MonoNote();
-    
+
     struct FrameOutput {
         size_t frameNumber;
         double pitch;
index 9abd92af115a37fc79b3b41d4a5499c667a43956..202467064e78cab1e687a370640b73366976f622 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -31,9 +31,9 @@ const vector<double>
 MonoNoteHMM::calculateObsProb(const vector<pair<double, double> > pitchProb)
 {
     // pitchProb is a list of pairs (pitches and their probabilities)
-    
+
     size_t nCandidate = pitchProb.size();
-    
+
     // what is the probability of pitched
     double pIsPitched = 0;
     for (size_t iCandidate = 0; iCandidate < nCandidate; ++iCandidate)
@@ -68,8 +68,8 @@ MonoNoteHMM::calculateObsProb(const vector<pair<double, double> > pitchProb)
                         minDistCandidate = iCandidate;
                     }
                 }
-                tempProb = std::pow(minDistProb, par.yinTrust) * 
-                           boost::math::pdf(pitchDistr[i], 
+                tempProb = std::pow(minDistProb, par.yinTrust) *
+                           boost::math::pdf(pitchDistr[i],
                                             pitchProb[minDistCandidate].first);
             } else {
                 tempProb = 1;
@@ -78,12 +78,12 @@ MonoNoteHMM::calculateObsProb(const vector<pair<double, double> > pitchProb)
             out[i] = tempProb;
         }
     }
-    
+
     for (size_t i = 0; i < par.n; ++i)
     {
         if (i % par.nSPP != 2)
         {
-            if (tempProbSum > 0) 
+            if (tempProbSum > 0)
             {
                 out[i] = out[i] / tempProbSum * pIsPitched;
             }
@@ -106,7 +106,7 @@ MonoNoteHMM::build()
     // 3-5. second-lowest pitch
     //    3. attack state
     //    ...
-    
+
     // observation distributions
     for (size_t iState = 0; iState < par.n; ++iState)
     {
@@ -116,7 +116,7 @@ MonoNoteHMM::build()
             // silent state starts tracking
             init.push_back(1.0/(par.nS * par.nPPS));
         } else {
-            init.push_back(0.0);            
+            init.push_back(0.0);
         }
     }
 
@@ -128,7 +128,7 @@ MonoNoteHMM::build()
         pitchDistr[index+1] = boost::math::normal(mu, par.sigmaYinPitchStable);
         pitchDistr[index+2] = boost::math::normal(mu, 1.0); // dummy
     }
-    
+
     boost::math::normal noteDistanceDistr(0, par.sigma2Note);
 
     for (size_t iPitch = 0; iPitch < (par.nS * par.nPPS); ++iPitch)
@@ -149,7 +149,7 @@ MonoNoteHMM::build()
         from.push_back(index+1);
         to.push_back(index+1); // to itself
         transProb.push_back(par.pStableSelftrans);
-        
+
         from.push_back(index+1);
         to.push_back(index+2); // to silent
         transProb.push_back(par.pStable2Silent);
@@ -158,8 +158,7 @@ MonoNoteHMM::build()
         from.push_back(index+2);
         to.push_back(index+2);
         transProb.push_back(par.pSilentSelftrans);
-        
-        
+
         // the more complicated transitions from the silent
         double probSumSilent = 0;
 
@@ -168,17 +167,17 @@ MonoNoteHMM::build()
         {
             int fromPitch = iPitch;
             int toPitch = jPitch;
-            double semitoneDistance = 
+            double semitoneDistance =
                 std::abs(fromPitch - toPitch) * 1.0 / par.nPPS;
-            
+
             // if (std::fmod(semitoneDistance, 1) == 0 && semitoneDistance > par.minSemitoneDistance)
-            if (semitoneDistance == 0 || 
-                (semitoneDistance > par.minSemitoneDistance 
+            if (semitoneDistance == 0 ||
+                (semitoneDistance > par.minSemitoneDistance
                  && semitoneDistance < par.maxJump))
             {
                 size_t toIndex = jPitch * par.nSPP; // note attack index
 
-                double tempWeightSilent = boost::math::pdf(noteDistanceDistr, 
+                double tempWeightSilent = boost::math::pdf(noteDistanceDistr,
                                                            semitoneDistance);
                 probSumSilent += tempWeightSilent;
 
index dff4697e7a3b23e53657ab6b2dcaa5f095d399c0..28f156694823f609ab04db89af1e9cb6f921499b 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
index 8d9c9508fac6b658550609ced428256925fc3811..2c8b814fd8d0231453625184104f61ec29127314 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
 #include "MonoNoteParameters.h"
 
 MonoNoteParameters::MonoNoteParameters() :
-    minPitch(35), 
-    nPPS(3), 
-    nS(69), 
+    minPitch(35),
+    nPPS(3),
+    nS(69),
     nSPP(3), // states per pitch
     n(0),
-    initPi(0), 
+    initPi(0),
     pAttackSelftrans(0.9),
     pStableSelftrans(0.99),
     pStable2Silent(0.01),
-    pSilentSelftrans(0.9999), 
+    pSilentSelftrans(0.9999),
     sigma2Note(0.7),
     maxJump(13),
     pInterSelftrans(0.0),
     priorPitchedProb(.7),
     priorWeight(0.5),
     minSemitoneDistance(.5),
-    sigmaYinPitchAttack(5), 
+    sigmaYinPitchAttack(5),
     sigmaYinPitchStable(0.8),
     sigmaYinPitchInter(.1),
     yinTrust(0.1)
index 21db7f6102939e1a571b5fc8f8dd80dabdc7880c..1647986cf30f01e6d0f35b98259fdc37200b5b07 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -25,17 +25,17 @@ class MonoNoteParameters
 public:
     MonoNoteParameters();
     virtual ~MonoNoteParameters();
-    
+
     // model architecture parameters
     size_t minPitch; // lowest pitch in MIDI notes
     size_t nPPS; // number of pitches per semitone
     size_t nS; // number of semitones
     size_t nSPP; // number of states per pitch
     size_t n; // number of states (will be calcualted from other parameters)
-    
+
     // initial state probabilities
-    vector<double> initPi; 
-    
+    vector<double> initPi;
+
     // transition parameters
     double pAttackSelftrans;
     double pStableSelftrans;
@@ -44,18 +44,17 @@ public:
     double sigma2Note; // standard deviation of next note Gaussian distribution
     double maxJump;
     double pInterSelftrans;
-    
+
     double priorPitchedProb;
     double priorWeight;
 
     double minSemitoneDistance; // minimum distance for a transition
-    
+
     double sigmaYinPitchAttack;
     double sigmaYinPitchStable;
     double sigmaYinPitchInter;
-    
+
     double yinTrust;
-    
 };
 
 #endif
index 01830f5419116c15a4cb7d021cb9420f5e47d5c3..ae771940d52136087236edf5716d82f93efc632c 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -40,15 +40,15 @@ MonoPitch::process(const vector<vector<pair<double, double> > > pitchProb)
     {
         obsProb.push_back(hmm.calculateObsProb(pitchProb[iFrame]));
     }
-    
+
     vector<double> *scale = new vector<double>(0);
-    
-    vector<float> out; 
-    
+
+    vector<float> out;
+
     // std::cerr << "before Viterbi decoding" << obsProb.size() << "ng" << obsProb[1].size() << std::endl;
     vector<int> path = hmm.decodeViterbi(obsProb, scale);
     // std::cerr << "after Viterbi decoding" << std::endl;
-    
+
     for (size_t iFrame = 0; iFrame < path.size(); ++iFrame)
     {
         // std::cerr << path[iFrame] << " " << hmm.m_freqs[path[iFrame]] << std::endl;
index 6e466d95e1b383283a9de755ea606dc8f84eb039..68c626e8d7d169916c98db90d3269991cf406488 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -27,7 +27,7 @@ class MonoPitch {
 public:
     MonoPitch();
     virtual ~MonoPitch();
-    
+
     // pitchProb is a frame-wise vector carrying a vector of pitch-probability pairs
     const vector<float> process(const vector<vector<pair<double, double> > > pitchProb);
 private:
index c52b64e635eb269d684b1ad3acdb2a0d0fc25910..29dd7e04dfa99ca84ae15c95ea297abf16dba67e 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -66,7 +66,7 @@ MonoPitchHMM::calculateObsProb(const vector<pair<double, double> > pitchProb)
             oldd = d;
         }
     }
-    
+
     double probReallyPitched = m_yinTrust * probYinPitched;
     // std::cerr << probReallyPitched << " " << probYinPitched << std::endl;
     // damn, I forget what this is all about...
@@ -84,14 +84,14 @@ MonoPitchHMM::build()
 {
     // INITIAL VECTOR
     init = vector<double>(2*m_nPitch, 1.0 / 2*m_nPitch);
-    
+
     // TRANSITIONS
     for (size_t iPitch = 0; iPitch < m_nPitch; ++iPitch)
     {
         int theoreticalMinNextPitch = static_cast<int>(iPitch)-static_cast<int>(m_transitionWidth/2);
         int minNextPitch = iPitch>m_transitionWidth/2 ? iPitch-m_transitionWidth/2 : 0;
         int maxNextPitch = iPitch<m_nPitch-m_transitionWidth/2 ? iPitch+m_transitionWidth/2 : m_nPitch-1;
-        
+
         // WEIGHT VECTOR
         double weightSum = 0;
         vector<double> weights;
@@ -107,7 +107,7 @@ MonoPitchHMM::build()
             }
             weightSum += weights[weights.size()-1];
         }
-        
+
         // std::cerr << minNextPitch << "  " << maxNextPitch << std::endl;
         // TRANSITIONS TO CLOSE PITCH
         for (size_t i = minNextPitch; i <= maxNextPitch; ++i)
@@ -124,7 +124,7 @@ MonoPitchHMM::build()
             to.push_back(i+m_nPitch);
             transProb.push_back(weights[i-minNextPitch] / weightSum * m_selfTrans);
             // transProb.push_back(weights[i-minNextPitch] / weightSum * 0.5);
-            
+
             from.push_back(iPitch+m_nPitch);
             to.push_back(i);
             transProb.push_back(weights[i-minNextPitch] / weightSum * (1-m_selfTrans));
@@ -135,7 +135,7 @@ MonoPitchHMM::build()
         // from.push_back(iPitch+m_nPitch);
         // to.push_back(2*m_nPitch);
         // transProb.push_back(1-m_selfTrans);
-        
+
         // TRANSITION FROM UNVOICED TO PITCH
         // from.push_back(2*m_nPitch);
         // to.push_back(iPitch+m_nPitch);
@@ -145,9 +145,9 @@ MonoPitchHMM::build()
     // from.push_back(2*m_nPitch);
     // to.push_back(2*m_nPitch);
     // transProb.push_back(m_selfTrans);
-    
+
     // for (size_t i = 0; i < from.size(); ++i) {
     //     std::cerr << "P(["<< from[i] << " --> " << to[i] << "]) = " << transProb[i] << std::endl;
     // }
-    
+
 }
index 3202676a8d8f8c82fc99afa726d1d7663c2b0a8b..ebab6df3b696e56472fa0c477b1f5928cd92583e 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
index ebfa6a2472609655c4c6bcc71c39bd6915646c61..0e34d39dca83b9d51dfa595d2532f054b9e7b00b 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -109,7 +109,7 @@ PYinVamp::getPreferredBlockSize() const
     return 2048;
 }
 
-size_t 
+size_t
 PYinVamp::getPreferredStepSize() const
 {
     return 256;
@@ -131,7 +131,7 @@ PYinVamp::ParameterList
 PYinVamp::getParameterDescriptors() const
 {
     ParameterList list;
-    
+
     ParameterDescriptor d;
 
     d.identifier = "threshdistr";
@@ -241,7 +241,7 @@ PYinVamp::getParameter(string identifier) const
 }
 
 void
-PYinVamp::setParameter(string identifier, float value) 
+PYinVamp::setParameter(string identifier, float value)
 {
     if (identifier == "threshdistr")
     {
@@ -293,7 +293,7 @@ PYinVamp::getOutputDescriptors() const
     OutputList outputs;
 
     OutputDescriptor d;
-    
+
     int outputNumber = 0;
 
     d.identifier = "f0candidates";
@@ -327,7 +327,7 @@ PYinVamp::getOutputDescriptors() const
     d.hasDuration = false;
     outputs.push_back(d);
     m_oF0Probs = outputNumber++;
-    
+
     d.identifier = "voicedprob";
     d.name = "Voiced Probability";
     d.description = "Probability that the signal is voiced according to Probabilistic Yin.";
@@ -358,7 +358,7 @@ PYinVamp::getOutputDescriptors() const
     d.hasDuration = false;
     outputs.push_back(d);
     m_oCandidateSalience = outputNumber++;
-    
+
     d.identifier = "smoothedpitchtrack";
     d.name = "Smoothed Pitch Track";
     d.description = ".";
@@ -407,7 +407,7 @@ PYinVamp::initialise(size_t channels, size_t stepSize, size_t blockSize)
     m_channels = channels;
     m_stepSize = stepSize;
     m_blockSize = blockSize;
-    
+
     reset();
 
     return true;
@@ -415,15 +415,15 @@ PYinVamp::initialise(size_t channels, size_t stepSize, size_t blockSize)
 
 void
 PYinVamp::reset()
-{    
+{
     m_yin.setThresholdDistr(m_threshDistr);
     m_yin.setFrameSize(m_blockSize);
     m_yin.setFast(!m_preciseTime);
-    
+
     m_pitchProb.clear();
     m_timestamp.clear();
     m_level.clear();
-/*    
+/*
     std::cerr << "PYinVamp::reset"
           << ", blockSize = " << m_blockSize
           << std::endl;
@@ -437,9 +437,9 @@ PYinVamp::process(const float *const *inputBuffers, RealTime timestamp)
     timestamp = timestamp + Vamp::RealTime::frame2RealTime(offset, lrintf(m_inputSampleRate));
 
     FeatureSet fs;
-    
+
     float rms = 0;
-    
+
     double *dInputBuffers = new double[m_blockSize];
     for (size_t i = 0; i < m_blockSize; ++i) {
         dInputBuffers[i] = inputBuffers[0][i];
@@ -447,15 +447,15 @@ PYinVamp::process(const float *const *inputBuffers, RealTime timestamp)
     }
     rms /= m_blockSize;
     rms = sqrt(rms);
-    
+
     bool isLowAmplitude = (rms < m_lowAmp);
-    
+
     Yin::YinOutput yo = m_yin.processProbabilisticYin(dInputBuffers);
     delete [] dInputBuffers;
 
     m_level.push_back(yo.rms);
 
-    // First, get the things out of the way that we don't want to output 
+    // 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)
@@ -483,7 +483,7 @@ PYinVamp::process(const float *const *inputBuffers, RealTime timestamp)
         f.values.push_back(yo.freqProb[i].first);
     }
     fs[m_oF0Candidates].push_back(f);
-    
+
     // VOICEDPROB
     f.values.clear();
     float voicedProb = 0;
@@ -493,7 +493,7 @@ PYinVamp::process(const float *const *inputBuffers, RealTime timestamp)
         voicedProb += yo.freqProb[i].second;
     }
     fs[m_oF0Probs].push_back(f);
-    
+
     f.values.push_back(voicedProb);
     fs[m_oVoicedProb].push_back(f);
 
@@ -517,7 +517,7 @@ PYinVamp::getRemainingFeatures()
     Feature f;
     f.hasTimestamp = true;
     f.hasDuration = false;
-    
+
     if (m_pitchProb.empty()) {
         return fs;
     }
@@ -536,10 +536,10 @@ PYinVamp::getRemainingFeatures()
         } else {
             f.values.push_back(mpOut[iFrame]);
         }
-        
+
         fs[m_oSmoothedPitchTrack].push_back(f);
     }
-    
+
     // MONO-NOTE STUFF
 //    std::cerr << "Mono Note Stuff" << std::endl;
     MonoNote mn;
@@ -555,19 +555,19 @@ PYinVamp::getRemainingFeatures()
     }
     // vector<MonoNote::FrameOutput> mnOut = mn.process(m_pitchProb);
     vector<MonoNote::FrameOutput> mnOut = mn.process(smoothedPitch);
-    
+
     // turning feature into a note feature
     f.hasTimestamp = true;
     f.hasDuration = true;
     f.values.clear();
-        
+
     int onsetFrame = 0;
     bool isVoiced = 0;
     bool oldIsVoiced = 0;
     size_t nFrame = m_pitchProb.size();
 
     float minNoteFrames = (m_inputSampleRate*m_pruneThresh) / m_stepSize;
-    
+
     std::vector<float> notePitchTrack; // collects pitches for one note at a time
     for (size_t iFrame = 0; iFrame < nFrame; ++iFrame)
     {
index 79c55012e2110939dce2cfce981f45774a64257f..cf7c1595dd35163ff0cc96247cd016f8b57f653b 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -62,7 +62,7 @@ protected:
     float m_fmin;
     float m_fmax;
     Yin m_yin;
-    
+
     mutable int m_oF0Candidates;
     mutable int m_oF0Probs;
     mutable int m_oVoicedProb;
diff --git a/libs/vamp-pyin/README b/libs/vamp-pyin/README
new file mode 100644 (file)
index 0000000..a608efa
--- /dev/null
@@ -0,0 +1,2 @@
+https://code.soundsoftware.ac.uk/projects/pyin
+https://code.soundsoftware.ac.uk/attachments/download/1458/pyin-v1.1.tar.gz
index 737bcf3d133b1a2e0a23a9777cd452310999c674..21f2e09ab7ac49a17b38ca7c32ed58feccfb2e77 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -26,9 +26,9 @@ SparseHMM::calculateObsProb(const vector<pair<double, double> > data)
     return(vector<double>());
 }
 
-const std::vector<int> 
+const std::vector<int>
 SparseHMM::decodeViterbi(std::vector<vector<double> > obsProb,
-                         vector<double> *scale) 
+                         vector<double> *scale)
 {
     if (obsProb.size() < 1) {
         return vector<int>();
@@ -36,10 +36,10 @@ SparseHMM::decodeViterbi(std::vector<vector<double> > obsProb,
 
     size_t nState = init.size();
     size_t nFrame = obsProb.size();
-    
-    // check for consistency    
+
+    // check for consistency
     size_t nTrans = transProb.size();
-    
+
     // declaring variables
     std::vector<double> delta = std::vector<double>(nState);
     std::vector<double> oldDelta = std::vector<double>(nState);
@@ -76,22 +76,22 @@ SparseHMM::decodeViterbi(std::vector<vector<double> > obsProb,
         size_t toState;
         double currentTransProb;
         double currentValue;
-        
+
         // this is the "sparse" loop
         for (size_t iTrans = 0; iTrans < nTrans; ++iTrans)
         {
             fromState = from[iTrans];
             toState = to[iTrans];
             currentTransProb = transProb[iTrans];
-            
+
             currentValue = oldDelta[fromState] * currentTransProb;
             if (currentValue > delta[toState])
             {
                 delta[toState] = currentValue; // will be multiplied by the right obs later!
                 psi[iFrame][toState] = fromState;
-            }            
+            }
         }
-        
+
         for (size_t jState = 0; jState < nState; ++jState)
         {
             delta[jState] *= obsProb[iFrame][jState];
@@ -125,7 +125,7 @@ SparseHMM::decodeViterbi(std::vector<vector<double> > obsProb,
         double currentValue = oldDelta[iState];
         if (currentValue > bestValue)
         {
-            bestValue = currentValue;            
+            bestValue = currentValue;
             path[nFrame-1] = iState;
         }
     }
@@ -135,11 +135,11 @@ SparseHMM::decodeViterbi(std::vector<vector<double> > obsProb,
     {
         path[iFrame] = psi[iFrame+1][path[iFrame+1]];
     }
-    
+
     // for (size_t iState = 0; iState < nState; ++iState)
     // {
     //     // std::cerr << psi[2][iState] << std::endl;
     // }
-    
+
     return path;
 }
index d3f02dd5a00a8cfd4b6e853f2d729e764877c6fa..0ca91b2fd204f62670797f7090a5cfe10d8912c0 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -24,7 +24,7 @@ class SparseHMM
 {
 public:
     virtual const std::vector<double> calculateObsProb(const vector<pair<double, double> >);
-    const std::vector<int> decodeViterbi(std::vector<vector<double> > obs, 
+    const std::vector<int> decodeViterbi(std::vector<vector<double> > obs,
                                    vector<double> *scale);
     vector<double> init;
     vector<size_t> from;
index 024a124c4feba85c72b2713c1ee92ec26715e685..77de237e02b1e9e101831403eff579fc907e0801 100644 (file)
@@ -3,7 +3,7 @@
 /*\r
     pYIN - A fundamental frequency estimator for monophonic audio\r
     Centre for Digital Music, Queen Mary, University of London.\r
-    \r
+\r
     This program is free software; you can redistribute it and/or\r
     modify it under the terms of the GNU General Public License as\r
     published by the Free Software Foundation; either version 2 of the\r
@@ -25,7 +25,7 @@
 \r
 using std::vector;\r
 \r
-Yin::Yin(size_t frameSize, size_t inputSampleRate, double thresh, bool fast) : \r
+Yin::Yin(size_t frameSize, size_t inputSampleRate, double thresh, bool fast) :\r
     m_frameSize(frameSize),\r
     m_inputSampleRate(inputSampleRate),\r
     m_thresh(thresh),\r
@@ -38,13 +38,13 @@ Yin::Yin(size_t frameSize, size_t inputSampleRate, double thresh, bool fast) :
     }\r
 }\r
 \r
-Yin::~Yin() \r
+Yin::~Yin()\r
 {\r
 }\r
 \r
 Yin::YinOutput\r
 Yin::process(const double *in) const {\r
-    \r
+\r
     double* yinBuffer = new double[m_yinBufferSize];\r
 \r
     // calculate aperiodicity function for all periods\r
@@ -55,11 +55,11 @@ Yin::process(const double *in) const {
 \r
     int tau = 0;\r
     tau = YinUtil::absoluteThreshold(yinBuffer, m_yinBufferSize, m_thresh);\r
-        \r
+\r
     double interpolatedTau;\r
     double aperiodicity;\r
     double f0;\r
-    \r
+\r
     if (tau!=0)\r
     {\r
         interpolatedTau = YinUtil::parabolicInterpolation(yinBuffer, abs(tau), m_yinBufferSize);\r
@@ -78,14 +78,14 @@ Yin::process(const double *in) const {
     {\r
         yo.salience.push_back(yinBuffer[iBuf] < 1 ? 1-yinBuffer[iBuf] : 0); // why are the values sometimes < 0 if I don't check?\r
     }\r
-    \r
+\r
     delete [] yinBuffer;\r
     return yo;\r
 }\r
 \r
 Yin::YinOutput\r
 Yin::processProbabilisticYin(const double *in) const {\r
-    \r
+\r
     double* yinBuffer = new double[m_yinBufferSize];\r
 \r
     // calculate aperiodicity function for all periods\r
@@ -95,7 +95,7 @@ Yin::processProbabilisticYin(const double *in) const {
     YinUtil::cumulativeDifference(yinBuffer, m_yinBufferSize);\r
 \r
     vector<double> peakProbability = YinUtil::yinProb(yinBuffer, m_threshDistr, m_yinBufferSize);\r
-    \r
+\r
     // calculate overall "probability" from peak probability\r
     double probSum = 0;\r
     for (size_t iBin = 0; iBin < m_yinBufferSize; ++iBin)\r
@@ -109,15 +109,15 @@ Yin::processProbabilisticYin(const double *in) const {
         yo.salience.push_back(peakProbability[iBuf]);\r
         if (peakProbability[iBuf] > 0)\r
         {\r
-            double currentF0 = \r
+            double currentF0 =\r
                 m_inputSampleRate * (1.0 /\r
                 YinUtil::parabolicInterpolation(yinBuffer, iBuf, m_yinBufferSize));\r
             yo.freqProb.push_back(pair<double, double>(currentF0, peakProbability[iBuf]));\r
         }\r
     }\r
-    \r
+\r
     // std::cerr << yo.freqProb.size() << std::endl;\r
-    \r
+\r
     delete [] yinBuffer;\r
     return yo;\r
 }\r
index 0fb151a6a5cfb6f523e4fb376a40158f1e146dc8..1b9f7c65bb7ba06f099eb9d5c40a3c47d5189375 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -27,7 +27,6 @@ using std::vector;
 using std::pair;
 
 
-
 class Yin
 {
 public:
@@ -40,16 +39,16 @@ public:
         double rms;
         vector<double> salience;
         vector<pair<double, double> > freqProb;
-        YinOutput() :  f0(0), periodicity(0), rms(0), 
+        YinOutput() :  f0(0), periodicity(0), rms(0),
             salience(vector<double>(0)), freqProb(vector<pair<double, double> >(0)) { }
         YinOutput(double _f, double _p, double _r) :
-            f0(_f), periodicity(_p), rms(_r), 
+            f0(_f), periodicity(_p), rms(_r),
             salience(vector<double>(0)), freqProb(vector<pair<double, double> >(0)) { }
         YinOutput(double _f, double _p, double _r, vector<double> _salience) :
-            f0(_f), periodicity(_p), rms(_r), salience(_salience), 
+            f0(_f), periodicity(_p), rms(_r), salience(_salience),
             freqProb(vector<pair<double, double> >(0)) { }
     };
-    
+
     int setThreshold(double parameter);
     int setThresholdDistr(float parameter);
     int setFrameSize(size_t frameSize);
index b93409374c853de9449c4c5e95837e7431a156d5..a74cfebd50341a972591c35fa871acbac690d9c3 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -21,8 +21,8 @@
 
 #include <boost/math/distributions.hpp>
 
-void 
-YinUtil::slowDifference(const double *in, double *yinBuffer, const size_t yinBufferSize) 
+void
+YinUtil::slowDifference(const double *in, double *yinBuffer, const size_t yinBufferSize)
 {
     yinBuffer[0] = 0;
     double delta ;
@@ -36,19 +36,19 @@ YinUtil::slowDifference(const double *in, double *yinBuffer, const size_t yinBuf
             delta = in[i+j] - in[j];
             yinBuffer[i] += delta * delta;
         }
-    }    
+    }
 }
 
-void 
-YinUtil::fastDifference(const double *in, double *yinBuffer, const size_t yinBufferSize) 
+void
+YinUtil::fastDifference(const double *in, double *yinBuffer, const size_t yinBufferSize)
 {
-    
+
     // DECLARE AND INITIALISE
     // initialisation of most of the arrays here was done in a separate function,
     // with all the arrays as members of the class... moved them back here.
-    
+
     size_t frameSize = 2 * yinBufferSize;
-    
+
     double *audioTransformedReal = new double[frameSize];
     double *audioTransformedImag = new double[frameSize];
     double *nullImag = new double[frameSize];
@@ -58,13 +58,13 @@ YinUtil::fastDifference(const double *in, double *yinBuffer, const size_t yinBuf
     double *yinStyleACFReal = new double[frameSize];
     double *yinStyleACFImag = new double[frameSize];
     double *powerTerms = new double[yinBufferSize];
-    
+
     for (size_t j = 0; j < yinBufferSize; ++j)
     {
         yinBuffer[j] = 0.; // set to zero
         powerTerms[j] = 0.; // set to zero
     }
-    
+
     for (size_t j = 0; j < frameSize; ++j)
     {
         nullImag[j] = 0.;
@@ -76,7 +76,7 @@ YinUtil::fastDifference(const double *in, double *yinBuffer, const size_t yinBuf
         yinStyleACFReal[j] = 0.;
         yinStyleACFImag[j] = 0.;
     }
-    
+
     // POWER TERM CALCULATION
     // ... for the power terms in equation (7) in the Yin paper
     powerTerms[0] = 0.0;
@@ -86,13 +86,13 @@ YinUtil::fastDifference(const double *in, double *yinBuffer, const size_t yinBuf
 
     // now iteratively calculate all others (saves a few multiplications)
     for (size_t tau = 1; tau < yinBufferSize; ++tau) {
-        powerTerms[tau] = powerTerms[tau-1] - in[tau-1] * in[tau-1] + in[tau+yinBufferSize] * in[tau+yinBufferSize];  
+        powerTerms[tau] = powerTerms[tau-1] - in[tau-1] * in[tau-1] + in[tau+yinBufferSize] * in[tau+yinBufferSize];
     }
 
     // YIN-STYLE AUTOCORRELATION via FFT
     // 1. data
     Vamp::FFT::forward(frameSize, in, nullImag, audioTransformedReal, audioTransformedImag);
-    
+
     // 2. half of the data, disguised as a convolution kernel
     for (size_t j = 0; j < yinBufferSize; ++j) {
         kernel[j] = in[yinBufferSize-1-j];
@@ -105,7 +105,7 @@ YinUtil::fastDifference(const double *in, double *yinBuffer, const size_t yinBuf
         yinStyleACFImag[j] = audioTransformedReal[j]*kernelTransformedImag[j] + audioTransformedImag[j]*kernelTransformedReal[j]; // imaginary
     }
     Vamp::FFT::inverse(frameSize, yinStyleACFReal, yinStyleACFImag, audioTransformedReal, audioTransformedImag);
-    
+
     // CALCULATION OF difference function
     // ... according to (7) in the Yin paper.
     for (size_t j = 0; j < yinBufferSize; ++j) {
@@ -123,15 +123,15 @@ YinUtil::fastDifference(const double *in, double *yinBuffer, const size_t yinBuf
     delete [] powerTerms;
 }
 
-void 
+void
 YinUtil::cumulativeDifference(double *yinBuffer, const size_t yinBufferSize)
-{    
+{
     size_t tau;
-    
+
     yinBuffer[0] = 1;
-    
+
     double runningSum = 0;
-    
+
     for (tau = 1; tau < yinBufferSize; ++tau) {
         runningSum += yinBuffer[tau];
         if (runningSum == 0)
@@ -140,16 +140,16 @@ YinUtil::cumulativeDifference(double *yinBuffer, const size_t yinBufferSize)
         } else {
             yinBuffer[tau] *= tau / runningSum;
         }
-    }    
+    }
 }
 
-int 
+int
 YinUtil::absoluteThreshold(const double *yinBuffer, const size_t yinBufferSize, const double thresh)
 {
     size_t tau;
     size_t minTau = 0;
     double minVal = 1000.;
-    
+
     // using Joren Six's "loop construct" from TarsosDSP
     tau = 2;
     while (tau < yinBufferSize)
@@ -187,7 +187,7 @@ static float single15[100] = {0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.
 static float single20[100] = {0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,1.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000,0.00000};
 
 std::vector<double>
-YinUtil::yinProb(const double *yinBuffer, const size_t prior, const size_t yinBufferSize, const size_t minTau0, const size_t maxTau0) 
+YinUtil::yinProb(const double *yinBuffer, const size_t prior, const size_t yinBufferSize, const size_t minTau0, const size_t maxTau0)
 {
     size_t minTau = 2;
     size_t maxTau = yinBufferSize;
@@ -201,10 +201,10 @@ YinUtil::yinProb(const double *yinBuffer, const size_t prior, const size_t yinBu
     std::vector<float> thresholds;
     std::vector<float> distribution;
     std::vector<double> peakProb = std::vector<double>(yinBufferSize);
-    
+
     size_t nThreshold = 100;
     int nThresholdInt = nThreshold;
-    
+
     for (int i = 0; i < nThresholdInt; ++i)
     {
         switch (prior) {
@@ -237,11 +237,10 @@ YinUtil::yinProb(const double *yinBuffer, const size_t prior, const size_t yinBu
         }
         thresholds.push_back(0.01 + i*0.01);
     }
-    
-    
+
     int currThreshInd = nThreshold-1;
     tau = minTau;
-    
+
     // double factor = 1.0 / (0.25 * (nThresholdInt+1) * (nThresholdInt + 1)); // factor to scale down triangular weight
     size_t minInd = 0;
     float minVal = 42.f;
@@ -270,7 +269,7 @@ YinUtil::yinProb(const double *yinBuffer, const size_t prior, const size_t yinBu
     // {
     //     nonPeakProb -= peakProb[i];
     // }
-    // 
+    //
     // std::cerr << tau << " " << currThreshInd << " "<< thresholds[currThreshInd] << " " << distribution[currThreshInd] << std::endl;
     float sumProb = 0;
     while (tau+1 < maxTau)
@@ -300,12 +299,12 @@ YinUtil::yinProb(const double *yinBuffer, const size_t prior, const size_t yinBu
             tau++;
         }
     }
-    
+
     if (peakProb[minInd] > 1) {
         std::cerr << "WARNING: yin has prob > 1 ??? I'm returning all zeros instead." << std::endl;
         return(std::vector<double>(yinBufferSize));
     }
-    
+
     double nonPeakProb = 1;
     if (sumProb > 0) {
         for (size_t i = minTau; i < maxTau; ++i)
@@ -316,33 +315,33 @@ YinUtil::yinProb(const double *yinBuffer, const size_t prior, const size_t yinBu
     }
     if (minInd > 0)
     {
-        // std::cerr << "min set " << minVal << " " << minInd << " " << nonPeakProb << std::endl; 
+        // std::cerr << "min set " << minVal << " " << minInd << " " << nonPeakProb << std::endl;
         peakProb[minInd] += nonPeakProb * minWeight;
     }
-    
+
     return peakProb;
 }
 
 double
-YinUtil::parabolicInterpolation(const double *yinBuffer, const size_t tau, const size_t yinBufferSize) 
+YinUtil::parabolicInterpolation(const double *yinBuffer, const size_t tau, const size_t yinBufferSize)
 {
     // this is taken almost literally from Joren Six's Java implementation
     if (tau == yinBufferSize) // not valid anyway.
     {
         return static_cast<double>(tau);
     }
-    
+
     double betterTau = 0.0;
     if (tau > 0 && tau < yinBufferSize-1) {
         float s0, s1, s2;
         s0 = yinBuffer[tau-1];
         s1 = yinBuffer[tau];
         s2 = yinBuffer[tau+1];
-        
+
         double adjustment = (s2 - s0) / (2 * (2 * s1 - s2 - s0));
-        
+
         if (abs(adjustment)>1) adjustment = 0;
-        
+
         betterTau = tau + adjustment;
     } else {
         // std::cerr << "WARNING: can't do interpolation at the edge (tau = " << tau << "), will return un-interpolated value.\n";
@@ -351,7 +350,7 @@ YinUtil::parabolicInterpolation(const double *yinBuffer, const size_t tau, const
     return betterTau;
 }
 
-double 
+double
 YinUtil::sumSquare(const double *in, const size_t start, const size_t end)
 {
     double out = 0;
index ea2d49c9fe195bed5d95bc324458854120c6c07b..83251c14f185e7e9c352388a5792c1fb677e3d48 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
index bc1e010e26c4a42ac192009693c8555cd15fd7eb..75fe5fca3a1053943baca0bc4bd778075c1ba2fc 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -99,7 +99,7 @@ YinVamp::getPreferredBlockSize() const
     return 2048;
 }
 
-size_t 
+size_t
 YinVamp::getPreferredStepSize() const
 {
     return 256;
@@ -121,7 +121,7 @@ YinVamp::ParameterList
 YinVamp::getParameterDescriptors() const
 {
     ParameterList list;
-    
+
     ParameterDescriptor d;
     d.identifier = "yinThreshold";
     d.name = "Yin threshold";
@@ -132,7 +132,7 @@ YinVamp::getParameterDescriptors() const
     d.defaultValue = 0.15f;
     d.isQuantized = true;
     d.quantizeStep = 0.025f;
-        
+
     list.push_back(d);
 
     d.identifier = "outputunvoiced";
@@ -166,7 +166,7 @@ YinVamp::getParameter(string identifier) const
 }
 
 void
-YinVamp::setParameter(string identifier, float value) 
+YinVamp::setParameter(string identifier, float value)
 {
     if (identifier == "yinThreshold")
     {
@@ -202,7 +202,7 @@ YinVamp::getOutputDescriptors() const
     OutputList outputs;
 
     OutputDescriptor d;
-    
+
     int outputNumber = 0;
 
     d.identifier = "f0";
@@ -285,7 +285,7 @@ YinVamp::initialise(size_t channels, size_t stepSize, size_t blockSize)
     m_channels = channels;
     m_stepSize = stepSize;
     m_blockSize = blockSize;
-    
+
     reset();
 
     return true;
@@ -293,10 +293,10 @@ YinVamp::initialise(size_t channels, size_t stepSize, size_t blockSize)
 
 void
 YinVamp::reset()
-{    
+{
     m_yin.setThreshold(m_yinParameter);
     m_yin.setFrameSize(m_blockSize);
-/*        
+/*
     std::cerr << "YinVamp::reset: yin threshold set to " << (m_yinParameter)
           << ", blockSize = " << m_blockSize
           << std::endl;
@@ -308,10 +308,10 @@ YinVamp::process(const float *const *inputBuffers, RealTime timestamp)
 {
     timestamp = timestamp + Vamp::RealTime::frame2RealTime(m_blockSize/2, lrintf(m_inputSampleRate));
     FeatureSet fs;
-    
+
     double *dInputBuffers = new double[m_blockSize];
     for (size_t i = 0; i < m_blockSize; ++i) dInputBuffers[i] = inputBuffers[0][i];
-    
+
     Yin::YinOutput yo = m_yin.process(dInputBuffers);
     // std::cerr << "f0 in YinVamp: " << yo.f0 << std::endl;
     Feature f;
@@ -341,19 +341,19 @@ YinVamp::process(const float *const *inputBuffers, RealTime timestamp)
     f.values.clear();
     f.values.push_back(yo.rms);
     fs[m_outNoRms].push_back(f);
-    
+
     f.values.clear();
     for (size_t iBin = 0; iBin < yo.salience.size(); ++iBin)
     {
         f.values.push_back(yo.salience[iBin]);
     }
     fs[m_outNoSalience].push_back(f);
-    
+
     f.values.clear();
     // f.values[0] = yo.periodicity;
     f.values.push_back(yo.periodicity);
     fs[m_outNoPeriodicity].push_back(f);
-    
+
     delete [] dInputBuffers;
 
     return fs;
index c82a8abc198a4b930af3e231d59dfcc655364c5d..14287ace620b7063e1bca44063ff78d8dc658c2e 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the
@@ -62,7 +62,7 @@ protected:
     float m_fmin;
     float m_fmax;
     Yin m_yin;
-    
+
     mutable int m_outNoF0;
     mutable int m_outNoPeriodicity;
     mutable int m_outNoRms;
index 350b3ba4dcf830bbbd40ad2a6665e7e8b6855654..4596aad71f0ae335d394a64c534360941b707e91 100644 (file)
@@ -3,7 +3,7 @@
 /*
     pYIN - A fundamental frequency estimator for monophonic audio
     Centre for Digital Music, Queen Mary, University of London.
-    
+
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License as
     published by the Free Software Foundation; either version 2 of the