Short-circuit slightly (in output, not so much in efficiency) when ratio is 1

This commit is contained in:
Chris Cannam
2022-05-27 11:45:28 +01:00
parent 9379908982
commit 4d4bc7b4c3
2 changed files with 37 additions and 9 deletions

View File

@@ -126,7 +126,7 @@ public:
bandFftSize = roundUp(int(ceil(rate/32.0))); bandFftSize = roundUp(int(ceil(rate/32.0)));
m_configuration.fftBandLimits[1] = m_configuration.fftBandLimits[1] =
BandLimits(bandFftSize, rate, m_minLower, m_maxHigher); BandLimits(bandFftSize, rate, 0.0, m_maxHigher);
bandFftSize = roundUp(int(ceil(rate/64.0))); bandFftSize = roundUp(int(ceil(rate/64.0)));
m_configuration.fftBandLimits[2] = m_configuration.fftBandLimits[2] =
@@ -146,13 +146,36 @@ public:
const BinSegmenter::Segmentation &nextSegmentation, const BinSegmenter::Segmentation &nextSegmentation,
Guidance &guidance) const { Guidance &guidance) const {
bool potentialKick = checkPotentialKick(magnitudes, prevMagnitudes);
guidance.kick.present = false; guidance.kick.present = false;
guidance.lowPercussive.present = false; guidance.lowPercussive.present = false;
guidance.highPercussive.present = false; guidance.highPercussive.present = false;
guidance.phaseReset.present = false; guidance.phaseReset.present = false;
double nyquist = m_parameters.sampleRate / 2.0;
guidance.fftBands[0].fftSize = roundUp(int(ceil(nyquist/8.0)));
guidance.fftBands[1].fftSize = roundUp(int(ceil(nyquist/16.0)));
guidance.fftBands[2].fftSize = roundUp(int(ceil(nyquist/32.0)));
if (fabs(ratio - 1.0) < 1.0e-6) {
guidance.fftBands[0].f0 = 0.0;
guidance.fftBands[0].f1 = 0.0;
guidance.fftBands[1].f0 = 0.0;
guidance.fftBands[1].f1 = m_minHigher;
guidance.fftBands[2].f0 = m_minHigher;
guidance.fftBands[2].f1 = nyquist;
for (int i = 0; i < 5; ++i) {
guidance.phaseLockBands[i].p = 0;
guidance.phaseLockBands[i].beta = 1.0;
guidance.phaseLockBands[i].f0 = nyquist;
guidance.phaseLockBands[i].f1 = nyquist;
}
guidance.phaseLockBands[0].f0 = 0.0;
guidance.phaseLockBands[0].f1 = nyquist;
guidance.channelLock.present = false;
return;
}
guidance.channelLock.present = true; guidance.channelLock.present = true;
guidance.channelLock.f0 = 0.0; guidance.channelLock.f0 = 0.0;
guidance.channelLock.f1 = 600.0; guidance.channelLock.f1 = 600.0;
@@ -163,6 +186,8 @@ public:
guidance.lowPercussive.f1 = segmentation.percussiveBelow; guidance.lowPercussive.f1 = segmentation.percussiveBelow;
} }
bool potentialKick = checkPotentialKick(magnitudes, prevMagnitudes);
if (potentialKick && prevSegmentation.percussiveBelow < 40.0) { if (potentialKick && prevSegmentation.percussiveBelow < 40.0) {
guidance.kick = guidance.lowPercussive; guidance.kick = guidance.lowPercussive;
} }
@@ -195,17 +220,12 @@ public:
double lower = snapToTrough(m_defaultLower, troughs); double lower = snapToTrough(m_defaultLower, troughs);
if (lower > m_maxLower) lower = m_maxLower; if (lower > m_maxLower) lower = m_maxLower;
double nyquist = m_parameters.sampleRate / 2.0;
guidance.fftBands[0].fftSize = roundUp(int(ceil(nyquist/8.0)));
guidance.fftBands[0].f0 = 0.0; guidance.fftBands[0].f0 = 0.0;
guidance.fftBands[0].f1 = lower; guidance.fftBands[0].f1 = lower;
guidance.fftBands[1].fftSize = roundUp(int(ceil(nyquist/16.0)));
guidance.fftBands[1].f0 = lower; guidance.fftBands[1].f0 = lower;
guidance.fftBands[1].f1 = higher; guidance.fftBands[1].f1 = higher;
guidance.fftBands[2].fftSize = roundUp(int(ceil(nyquist/32.0)));
guidance.fftBands[2].f0 = higher; guidance.fftBands[2].f0 = higher;
guidance.fftBands[2].f1 = nyquist; guidance.fftBands[2].f1 = nyquist;
@@ -231,6 +251,12 @@ public:
guidance.phaseLockBands[3].f0 = higher; guidance.phaseLockBands[3].f0 = higher;
guidance.phaseLockBands[3].f1 = nyquist; guidance.phaseLockBands[3].f1 = nyquist;
// Currently unused
guidance.phaseLockBands[4].p = 0;
guidance.phaseLockBands[4].beta = 1.0;
guidance.phaseLockBands[4].f0 = nyquist;
guidance.phaseLockBands[4].f1 = nyquist;
/* /*
std::ostringstream str; std::ostringstream str;
str << "Guidance: FFT bands: [" str << "Guidance: FFT bands: ["

View File

@@ -183,7 +183,9 @@ public:
++phaseLockBand; ++phaseLockBand;
} }
double ph = 0.0; double ph = 0.0;
if (inRange(f, g->phaseReset) || inRange(f, g->kick)) { if (inhop == outhop) {
ph = m_unlocked[c][i];
} else if (inRange(f, g->phaseReset) || inRange(f, g->kick)) {
ph = phase[c][i]; ph = phase[c][i];
} else if (inRange (f, g->highPercussive)) { } else if (inRange (f, g->highPercussive)) {
ph = m_unlocked[c][i]; ph = m_unlocked[c][i];