Handle non-ideal sample rates in R3; document sample rate parameter
This commit is contained in:
@@ -122,8 +122,14 @@ public:
|
||||
m_log.log(1, "Guide: rate and single-window mode",
|
||||
rate, m_parameters.singleWindowMode);
|
||||
|
||||
int classificationFftSize =
|
||||
roundUp(int(ceil(parameters.sampleRate / 32.0)));
|
||||
int classificationFftSize = roundUpDiv(parameters.sampleRate, 32);
|
||||
|
||||
int minClassificationFftSize = 1024;
|
||||
if (classificationFftSize < minClassificationFftSize) {
|
||||
m_log.log(1, "Guide: sample rate is too low to work well");
|
||||
m_log.log(1, "Guide: rounding up classification FFT size from and to", classificationFftSize, minClassificationFftSize);
|
||||
classificationFftSize = minClassificationFftSize;
|
||||
}
|
||||
|
||||
m_configuration.classificationFftSize = classificationFftSize;
|
||||
|
||||
@@ -247,6 +253,15 @@ public:
|
||||
if (outhop > 256) {
|
||||
guidance.phaseLockBands[2].p = 4;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (guidance.phaseLockBands[i].f0 > nyquist) {
|
||||
guidance.phaseLockBands[i].f0 = nyquist;
|
||||
}
|
||||
if (guidance.phaseLockBands[i].f1 > nyquist) {
|
||||
guidance.phaseLockBands[i].f1 = nyquist;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -461,16 +476,6 @@ protected:
|
||||
double m_maxLower;
|
||||
double m_maxHigher;
|
||||
|
||||
// near-dupe with R2 RubberBandStretcher::Impl
|
||||
int roundUp(int value) const {
|
||||
if (value < 1) return 1;
|
||||
if (!(value & (value - 1))) return value;
|
||||
size_t bits = 0;
|
||||
while (value) { ++bits; value >>= 1; }
|
||||
value = size_t(1) << bits;
|
||||
return value;
|
||||
}
|
||||
|
||||
void updateForSilence(Guidance &guidance) const {
|
||||
// std::cout << "phase reset on silence" << std::endl;
|
||||
double nyquist = m_parameters.sampleRate / 2.0;
|
||||
@@ -575,6 +580,7 @@ protected:
|
||||
int b = binForFrequency(f, m_configuration.classificationFftSize,
|
||||
m_parameters.sampleRate);
|
||||
int n = m_configuration.classificationFftSize/2;
|
||||
if (b > n) b = n;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (b < n && magnitudes[b+1] < magnitudes[b]) {
|
||||
++b;
|
||||
|
||||
Reference in New Issue
Block a user