Wire up formant option; some tidying
This commit is contained in:
@@ -96,6 +96,8 @@ RubberBandStretcher::getLatency() const
|
|||||||
else return m_r3d->getLatency();
|
else return m_r3d->getLatency();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//!!! review all these
|
||||||
|
|
||||||
void
|
void
|
||||||
RubberBandStretcher::setTransientsOption(Options options)
|
RubberBandStretcher::setTransientsOption(Options options)
|
||||||
{
|
{
|
||||||
@@ -118,12 +120,14 @@ void
|
|||||||
RubberBandStretcher::setFormantOption(Options options)
|
RubberBandStretcher::setFormantOption(Options options)
|
||||||
{
|
{
|
||||||
if (m_d) m_d->setFormantOption(options);
|
if (m_d) m_d->setFormantOption(options);
|
||||||
|
else if (m_r3d) m_r3d->setFormantOption(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RubberBandStretcher::setPitchOption(Options options)
|
RubberBandStretcher::setPitchOption(Options options)
|
||||||
{
|
{
|
||||||
if (m_d) m_d->setPitchOption(options);
|
if (m_d) m_d->setPitchOption(options);
|
||||||
|
else if (m_r3d) m_r3d->setPitchOption(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ R3StretcherImpl::calculateHop()
|
|||||||
|
|
||||||
m_inhop = int(round(inhop));
|
m_inhop = int(round(inhop));
|
||||||
|
|
||||||
std::cout << "R3StretcherImpl::calculateHop: inhop = " << m_inhop << ", proposed outhop = " << proposedOuthop << ", mean outhop = " << m_inhop * ratio << std::endl;
|
// std::cout << "R3StretcherImpl::calculateHop: inhop = " << m_inhop << ", proposed outhop = " << proposedOuthop << ", mean outhop = " << m_inhop * ratio << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
@@ -346,7 +346,7 @@ R3StretcherImpl::consume()
|
|||||||
// advanced the input and output since the previous frame, not the
|
// advanced the input and output since the previous frame, not the
|
||||||
// distances we are about to advance them, so they use the m_prev
|
// distances we are about to advance them, so they use the m_prev
|
||||||
// values.
|
// values.
|
||||||
|
/*
|
||||||
if (inhop != m_prevInhop) {
|
if (inhop != m_prevInhop) {
|
||||||
std::cout << "Note: inhop has changed from " << m_prevInhop
|
std::cout << "Note: inhop has changed from " << m_prevInhop
|
||||||
<< " to " << inhop << std::endl;
|
<< " to " << inhop << std::endl;
|
||||||
@@ -355,7 +355,7 @@ R3StretcherImpl::consume()
|
|||||||
std::cout << "Note: outhop has changed from " << m_prevOuthop
|
std::cout << "Note: outhop has changed from " << m_prevOuthop
|
||||||
<< " to " << outhop << std::endl;
|
<< " to " << outhop << std::endl;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
while (m_channelData.at(0)->outbuf->getWriteSpace() >= outhop) {
|
while (m_channelData.at(0)->outbuf->getWriteSpace() >= outhop) {
|
||||||
|
|
||||||
// NB our ChannelData, ScaleData, and ChannelScaleData maps
|
// NB our ChannelData, ScaleData, and ChannelScaleData maps
|
||||||
@@ -382,7 +382,10 @@ R3StretcherImpl::consume()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_parameters.options & RubberBandStretcher::OptionFormantPreserved) {
|
if (m_parameters.options & RubberBandStretcher::OptionFormantPreserved) {
|
||||||
|
m_formant->enabled = true;
|
||||||
analyseFormant();
|
analyseFormant();
|
||||||
|
} else {
|
||||||
|
m_formant->enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phase update. This is synchronised across all channels
|
// Phase update. This is synchronised across all channels
|
||||||
@@ -687,12 +690,12 @@ R3StretcherImpl::analyseFormant()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "X:";
|
// std::cout << "X:";
|
||||||
for (int i = 0; i < binCount; ++i) {
|
// for (int i = 0; i < binCount; ++i) {
|
||||||
if (i > 0) std::cout << ",";
|
// if (i > 0) std::cout << ",";
|
||||||
std::cout << f.shifted[i];
|
// std::cout << f.shifted[i];
|
||||||
}
|
// }
|
||||||
std::cout << std::endl;
|
// std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -712,8 +715,8 @@ R3StretcherImpl::synthesiseChannel(int c, int outhop)
|
|||||||
scale->mag.data(),
|
scale->mag.data(),
|
||||||
bufSize);
|
bufSize);
|
||||||
|
|
||||||
// formant shift only the middle register
|
if (m_formant->enabled) {
|
||||||
if (m_parameters.options & RubberBandStretcher::OptionFormantPreserved) {
|
// formant shift only the middle register
|
||||||
if (it.first == m_guideConfiguration.classificationFftSize) {
|
if (it.first == m_guideConfiguration.classificationFftSize) {
|
||||||
v_divide(scale->mag.data(), m_formant->envelope.data(), bufSize);
|
v_divide(scale->mag.data(), m_formant->envelope.data(), bufSize);
|
||||||
v_multiply(scale->mag.data(), m_formant->shifted.data(), bufSize);
|
v_multiply(scale->mag.data(), m_formant->shifted.data(), bufSize);
|
||||||
|
|||||||
@@ -221,11 +221,13 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct FormantData {
|
struct FormantData {
|
||||||
|
bool enabled;
|
||||||
FixedVector<double> cepstra;
|
FixedVector<double> cepstra;
|
||||||
FixedVector<double> envelope;
|
FixedVector<double> envelope;
|
||||||
FixedVector<double> shifted;
|
FixedVector<double> shifted;
|
||||||
|
|
||||||
FormantData(int _fftSize) :
|
FormantData(int _fftSize) :
|
||||||
|
enabled(false),
|
||||||
cepstra(_fftSize, 0.0),
|
cepstra(_fftSize, 0.0),
|
||||||
envelope(_fftSize, 0.0),
|
envelope(_fftSize, 0.0),
|
||||||
shifted(_fftSize, 0.0) { }
|
shifted(_fftSize, 0.0) { }
|
||||||
|
|||||||
Reference in New Issue
Block a user