Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pYin patch for detecting low frequencies
commit 6ed838b60173dc354fcb432e27bccb3a7a1e5769
Author: Xavier Riley <xavriley@hotmail.com>
Date: Mon Jun 28 12:47:19 2021 +0100
Reduce min frequency detectable from 61Hz to 22Hz
diff --git a/LocalCandidatePYIN.cpp b/LocalCandidatePYIN.cpp
index fc69308..4f04fbc 100644
--- a/LocalCandidatePYIN.cpp
+++ b/LocalCandidatePYIN.cpp
@@ -308,8 +308,8 @@ LocalCandidatePYIN::process(const float *const *inputBuffers, RealTime timestamp
m_yinUtil->cumulativeDifference(yinBuffer);
- float minFrequency = 60;
- float maxFrequency = 900;
+ float minFrequency = 22;
+ float maxFrequency = 440;
vector<double> peakProbability = m_yinUtil->yinProb(yinBuffer,
m_threshDistr,
m_inputSampleRate/maxFrequency,
diff --git a/MonoNoteParameters.cpp b/MonoNoteParameters.cpp
index 8d9c950..7c5165e 100644
--- a/MonoNoteParameters.cpp
+++ b/MonoNoteParameters.cpp
@@ -14,7 +14,7 @@
#include "MonoNoteParameters.h"
MonoNoteParameters::MonoNoteParameters() :
- minPitch(35),
+ minPitch(21),
nPPS(3),
nS(69),
nSPP(3), // states per pitch
diff --git a/MonoPitchHMM.cpp b/MonoPitchHMM.cpp
index 82384f1..e162106 100644
--- a/MonoPitchHMM.cpp
+++ b/MonoPitchHMM.cpp
@@ -24,7 +24,7 @@ using std::pair;
MonoPitchHMM::MonoPitchHMM(int fixedLag) :
SparseHMM(fixedLag),
- m_minFreq(61.735),
+ m_minFreq(27.500),
m_nBPS(5),
m_nPitch(0),
m_transitionWidth(0),
diff --git a/PYinVamp.cpp b/PYinVamp.cpp
index a012e03..56958ac 100644
--- a/PYinVamp.cpp
+++ b/PYinVamp.cpp
@@ -32,8 +32,8 @@ PYinVamp::PYinVamp(float inputSampleRate) :
m_channels(0),
m_stepSize(256),
m_blockSize(2048),
- m_fmin(40),
- m_fmax(1600),
+ m_fmin(22),
+ m_fmax(440),
m_yin(2048, inputSampleRate, 0.0),
m_oF0Candidates(0),
m_oF0Probs(0),
diff --git a/Yin.cpp b/Yin.cpp
index d9e95c3..2c1e0dc 100644
--- a/Yin.cpp
+++ b/Yin.cpp
@@ -96,7 +96,13 @@ Yin::processProbabilisticYin(const double *in) const {
m_yinUtil->cumulativeDifference(yinBuffer);
- vector<double> peakProbability = m_yinUtil->yinProb(yinBuffer, m_threshDistr);
+ // vector<double> peakProbability = m_yinUtil->yinProb(yinBuffer, m_threshDistr);
+ float minFrequency = 22;
+ float maxFrequency = 440;
+ vector<double> peakProbability = m_yinUtil->yinProb(yinBuffer,
+ m_threshDistr,
+ m_inputSampleRate/maxFrequency,
+ m_inputSampleRate/minFrequency);
// calculate overall "probability" from peak probability
double probSum = 0;
diff --git a/YinUtil.cpp b/YinUtil.cpp
index 94b6ff1..1ea1e22 100644
--- a/YinUtil.cpp
+++ b/YinUtil.cpp
@@ -241,7 +241,7 @@ YinUtil::yinProb(const double *yinBuffer, int prior, int minTau0, int maxTau0)
// double factor = 1.0 / (0.25 * (nThresholdInt+1) * (nThresholdInt + 1)); // factor to scale down triangular weight
int minInd = 0;
- float minVal = 42.f;
+ float minVal = 20.f;
// while (currThreshInd != -1 && tau < maxTau)
// {
// if (yinBuffer[tau] < thresholds[currThreshInd])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment