Provide option to shift formant independently of pitch
This commit is contained in:
@@ -35,6 +35,7 @@ R3StretcherImpl::R3StretcherImpl(Parameters parameters,
|
||||
m_parameters(parameters),
|
||||
m_timeRatio(initialTimeRatio),
|
||||
m_pitchScale(initialPitchScale),
|
||||
m_formantScale(0.0),
|
||||
m_guide(Guide::Parameters(m_parameters.sampleRate, parameters.logger)),
|
||||
m_guideConfiguration(m_guide.getConfiguration()),
|
||||
m_channelAssembly(m_parameters.channels),
|
||||
@@ -173,6 +174,12 @@ R3StretcherImpl::setPitchScale(double scale)
|
||||
calculateHop();
|
||||
}
|
||||
|
||||
void
|
||||
R3StretcherImpl::setFormantScale(double scale)
|
||||
{
|
||||
m_formantScale = scale;
|
||||
}
|
||||
|
||||
void
|
||||
R3StretcherImpl::setFormantOption(RubberBandStretcher::Options options)
|
||||
{
|
||||
@@ -233,6 +240,12 @@ R3StretcherImpl::getPitchScale() const
|
||||
return m_pitchScale;
|
||||
}
|
||||
|
||||
double
|
||||
R3StretcherImpl::getFormantScale() const
|
||||
{
|
||||
return m_formantScale;
|
||||
}
|
||||
|
||||
size_t
|
||||
R3StretcherImpl::getLatency() const
|
||||
{
|
||||
@@ -777,7 +790,9 @@ R3StretcherImpl::adjustFormant(int c)
|
||||
|
||||
int highBin = int(floor(fftSize * 10000.0 / m_parameters.sampleRate));
|
||||
double targetFactor = double(cd->formant->fftSize) / double(fftSize);
|
||||
double sourceFactor = targetFactor * m_pitchScale;
|
||||
double formantScale = m_formantScale;
|
||||
if (formantScale == 0.0) formantScale = 1.0 / m_pitchScale;
|
||||
double sourceFactor = targetFactor / formantScale;
|
||||
double maxRatio = 60.0;
|
||||
double minRatio = 1.0 / maxRatio;
|
||||
|
||||
|
||||
@@ -69,9 +69,11 @@ public:
|
||||
|
||||
void setTimeRatio(double ratio);
|
||||
void setPitchScale(double scale);
|
||||
void setFormantScale(double scale);
|
||||
|
||||
double getTimeRatio() const;
|
||||
double getPitchScale() const;
|
||||
double getFormantScale() const;
|
||||
|
||||
void setFormantOption(RubberBandStretcher::Options);
|
||||
void setPitchOption(RubberBandStretcher::Options);
|
||||
@@ -265,6 +267,7 @@ protected:
|
||||
|
||||
std::atomic<double> m_timeRatio;
|
||||
std::atomic<double> m_pitchScale;
|
||||
std::atomic<double> m_formantScale;
|
||||
|
||||
std::vector<std::shared_ptr<ChannelData>> m_channelData;
|
||||
std::map<int, std::shared_ptr<ScaleData>> m_scaleData;
|
||||
|
||||
Reference in New Issue
Block a user