Go back to running formants only within the necessary range
This commit is contained in:
@@ -682,12 +682,13 @@ R3StretcherImpl::adjustFormant(int c)
|
|||||||
int fftSize = it.first;
|
int fftSize = it.first;
|
||||||
auto &scale = it.second;
|
auto &scale = it.second;
|
||||||
|
|
||||||
|
int formantHigh = int(floor(fftSize * 10000.0 / m_parameters.sampleRate));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int lowBin = int(floor(fftSize * band.f0 / m_parameters.sampleRate));
|
int lowBin = int(floor(fftSize * band.f0 / m_parameters.sampleRate));
|
||||||
int highBin = int(floor(fftSize * band.f1 / m_parameters.sampleRate));
|
int highBin = int(floor(fftSize * band.f1 / m_parameters.sampleRate));
|
||||||
if (highBin % 2 == 1) --highBin;
|
if (highBin % 2 == 1) --highBin;
|
||||||
|
|
||||||
int formantHigh = int(floor(fftSize * 10000.0 / m_parameters.sampleRate));
|
|
||||||
for (int i = 0; i < lowBin; ++i) {
|
for (int i = 0; i < lowBin; ++i) {
|
||||||
scale->mag[i] = 0.0;
|
scale->mag[i] = 0.0;
|
||||||
}
|
}
|
||||||
@@ -695,17 +696,22 @@ R3StretcherImpl::adjustFormant(int c)
|
|||||||
|
|
||||||
double targetFactor = double(cd->formant->fftSize) / double(fftSize);
|
double targetFactor = double(cd->formant->fftSize) / double(fftSize);
|
||||||
double sourceFactor = targetFactor * m_pitchScale;
|
double sourceFactor = targetFactor * m_pitchScale;
|
||||||
|
|
||||||
|
for (const auto &b : m_guideConfiguration.fftBandLimits) {
|
||||||
|
if (b.fftSize == fftSize) {
|
||||||
// double maxRatio = 60.0;
|
// double maxRatio = 60.0;
|
||||||
// double minRatio = 1.0 / maxRatio;
|
// double minRatio = 1.0 / maxRatio;
|
||||||
// for (int i = lowBin; i < highBin && i < formantHigh; ++i) {
|
// for (int i = lowBin; i < highBin && i < formantHigh; ++i) {
|
||||||
for (int i = 0; i < scale->bufSize; ++i) {
|
for (int i = b.b0min; i < b.b1max && i < formantHigh; ++i) {
|
||||||
double source = cd->formant->envelopeAt(i * sourceFactor);
|
double source = cd->formant->envelopeAt(i * sourceFactor);
|
||||||
double target = cd->formant->envelopeAt(i * targetFactor);
|
double target = cd->formant->envelopeAt(i * targetFactor);
|
||||||
if (target > 0.0) {
|
if (target > 0.0) {
|
||||||
double ratio = source / target;
|
double ratio = source / target;
|
||||||
// if (ratio < minRatio) ratio = minRatio;
|
// if (ratio < minRatio) ratio = minRatio;
|
||||||
// if (ratio > maxRatio) ratio = maxRatio;
|
// if (ratio > maxRatio) ratio = maxRatio;
|
||||||
scale->mag[i] *= ratio;
|
scale->mag[i] *= ratio;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user