Tidy
This commit is contained in:
@@ -674,7 +674,7 @@ R3StretcherImpl::analyseFormant()
|
|||||||
|
|
||||||
m_scaleData.at(classify)->fft.forward
|
m_scaleData.at(classify)->fft.forward
|
||||||
(f.cepstra.data(), f.envelope.data(),
|
(f.cepstra.data(), f.envelope.data(),
|
||||||
f.shifted.data()); // shifted is just a spare for this one
|
f.spare.data()); // shifted is just a spare for this one
|
||||||
|
|
||||||
v_exp(f.envelope.data(), binCount);
|
v_exp(f.envelope.data(), binCount);
|
||||||
v_square(f.envelope.data(), binCount);
|
v_square(f.envelope.data(), binCount);
|
||||||
@@ -682,24 +682,6 @@ R3StretcherImpl::analyseFormant()
|
|||||||
for (int i = 0; i < binCount; ++i) {
|
for (int i = 0; i < binCount; ++i) {
|
||||||
if (f.envelope[i] > 1.0e10) f.envelope[i] = 1.0e10;
|
if (f.envelope[i] > 1.0e10) f.envelope[i] = 1.0e10;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!!
|
|
||||||
double scale = m_pitchScale;
|
|
||||||
for (int target = 0; target < binCount; ++target) {
|
|
||||||
int source = int(round(target * scale));
|
|
||||||
if (source >= binCount) {
|
|
||||||
f.shifted[target] = 0.0;
|
|
||||||
} else {
|
|
||||||
f.shifted[target] = f.envelope[source];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// std::cout << "X:";
|
|
||||||
// for (int i = 0; i < binCount; ++i) {
|
|
||||||
// if (i > 0) std::cout << ",";
|
|
||||||
// std::cout << f.shifted[i];
|
|
||||||
// }
|
|
||||||
// std::cout << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -718,14 +700,6 @@ R3StretcherImpl::synthesiseChannel(int c, int outhop)
|
|||||||
v_copy(scale->prevMag.data(),
|
v_copy(scale->prevMag.data(),
|
||||||
scale->mag.data(),
|
scale->mag.data(),
|
||||||
bufSize);
|
bufSize);
|
||||||
|
|
||||||
// if (m_formant->enabled) {
|
|
||||||
// formant shift only the middle register
|
|
||||||
// if (it.first == m_guideConfiguration.classificationFftSize) {
|
|
||||||
// v_divide(scale->mag.data(), m_formant->envelope.data(), bufSize);
|
|
||||||
// v_multiply(scale->mag.data(), m_formant->shifted.data(), bufSize);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &band : cd->guidance.fftBands) {
|
for (const auto &band : cd->guidance.fftBands) {
|
||||||
@@ -764,13 +738,15 @@ R3StretcherImpl::synthesiseChannel(int c, int outhop)
|
|||||||
if (m_formant->enabled) {
|
if (m_formant->enabled) {
|
||||||
double targetFactor = double(m_formant->fftSize) / double(fftSize);
|
double targetFactor = double(m_formant->fftSize) / double(fftSize);
|
||||||
double sourceFactor = targetFactor * m_pitchScale;
|
double sourceFactor = targetFactor * m_pitchScale;
|
||||||
|
double maxRatio = 60.0;
|
||||||
|
double minRatio = 1.0 / maxRatio;
|
||||||
for (int i = lowBin; i < highBin && i < formantHigh; ++i) {
|
for (int i = lowBin; i < highBin && i < formantHigh; ++i) {
|
||||||
double source = m_formant->envelopeAt(i * sourceFactor);
|
double source = m_formant->envelopeAt(i * sourceFactor);
|
||||||
double target = m_formant->envelopeAt(i * targetFactor);
|
double target = m_formant->envelopeAt(i * targetFactor);
|
||||||
if (target > 0.0) {
|
if (target > 0.0) {
|
||||||
double ratio = source / target;
|
double ratio = source / target;
|
||||||
// if (ratio < 0.2) ratio = 0.2;
|
if (ratio < minRatio) ratio = minRatio;
|
||||||
// if (ratio > 5.0) ratio = 5.0;
|
if (ratio > maxRatio) ratio = maxRatio;
|
||||||
scale->mag[i] *= ratio;
|
scale->mag[i] *= ratio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,19 +226,22 @@ protected:
|
|||||||
int fftSize;
|
int fftSize;
|
||||||
FixedVector<double> cepstra;
|
FixedVector<double> cepstra;
|
||||||
FixedVector<double> envelope;
|
FixedVector<double> envelope;
|
||||||
FixedVector<double> shifted;
|
FixedVector<double> spare;
|
||||||
|
|
||||||
FormantData(int _fftSize) :
|
FormantData(int _fftSize) :
|
||||||
enabled(false),
|
enabled(false),
|
||||||
fftSize(_fftSize),
|
fftSize(_fftSize),
|
||||||
cepstra(_fftSize, 0.0),
|
cepstra(_fftSize, 0.0),
|
||||||
envelope(_fftSize, 0.0),
|
envelope(_fftSize/2 + 1, 0.0),
|
||||||
shifted(_fftSize, 0.0) { }
|
spare(_fftSize/2 + 1, 0.0) { }
|
||||||
|
|
||||||
double envelopeAt(double bin) const {
|
double envelopeAt(double bin) const {
|
||||||
int b0 = int(floor(bin)), b1 = int(ceil(bin));
|
int b0 = int(floor(bin)), b1 = int(ceil(bin));
|
||||||
if (b1 == b0) return envelope.at(b0);
|
if (b0 < 0 || b0 > fftSize/2) {
|
||||||
else {
|
return 0.0;
|
||||||
|
} else if (b1 == b0 || b1 > fftSize/2) {
|
||||||
|
return envelope.at(b0);
|
||||||
|
} else {
|
||||||
double diff = bin - double(b0);
|
double diff = bin - double(b0);
|
||||||
return envelope.at(b0) * (1.0 - diff) + envelope.at(b1) * diff;
|
return envelope.at(b0) * (1.0 - diff) + envelope.at(b1) * diff;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user