* Add OptionPitchHighConsistency
This commit is contained in:
@@ -182,6 +182,13 @@ public:
|
||||
* \li \c OptionPitchHighQuality - Use the highest quality
|
||||
* method for pitch shifting. This method has a CPU cost
|
||||
* approximately proportional to the required frequency shift.
|
||||
|
||||
* \li \c OptionPitchHighConsistency - Use the method that gives
|
||||
* greatest consistency when used to create small variations in
|
||||
* pitch around the 1.0-ratio level. Unlike the previous two
|
||||
* options, this avoids discontinuities when moving across the
|
||||
* 1.0 pitch scale in real-time; it also consumes more CPU than
|
||||
* the others in the case where the pitch scale is exactly 1.0.
|
||||
*/
|
||||
|
||||
enum Option {
|
||||
@@ -212,7 +219,8 @@ public:
|
||||
OptionFormantPreserved = 0x01000000,
|
||||
|
||||
OptionPitchHighSpeed = 0x00000000,
|
||||
OptionPitchHighQuality = 0x02000000
|
||||
OptionPitchHighQuality = 0x02000000,
|
||||
OptionPitchHighConsistency = 0x04000000
|
||||
};
|
||||
|
||||
typedef int Options;
|
||||
|
||||
@@ -60,7 +60,8 @@ enum RubberBandOption {
|
||||
RubberBandOptionFormantPreserved = 0x01000000,
|
||||
|
||||
RubberBandOptionPitchHighQuality = 0x00000000,
|
||||
RubberBandOptionPitchHighSpeed = 0x02000000
|
||||
RubberBandOptionPitchHighSpeed = 0x02000000,
|
||||
RubberBandOptionPitchHighConsistency = 0x04000000
|
||||
};
|
||||
|
||||
typedef int RubberBandOptions;
|
||||
|
||||
@@ -524,7 +524,9 @@ RubberBandStretcher::Impl::configure()
|
||||
m_studyFFT->initFloat();
|
||||
}
|
||||
|
||||
if (m_pitchScale != 1.0 || m_realtime) {
|
||||
if (m_pitchScale != 1.0 ||
|
||||
(m_options & OptionPitchHighConsistency) ||
|
||||
m_realtime) {
|
||||
|
||||
for (size_t c = 0; c < m_channels; ++c) {
|
||||
|
||||
@@ -708,7 +710,9 @@ RubberBandStretcher::Impl::setPitchOption(Options options)
|
||||
|
||||
Options prior = m_options;
|
||||
|
||||
int mask = (OptionPitchHighQuality | OptionPitchHighSpeed);
|
||||
int mask = (OptionPitchHighQuality |
|
||||
OptionPitchHighSpeed |
|
||||
OptionPitchHighConsistency);
|
||||
m_options &= ~mask;
|
||||
options &= mask;
|
||||
m_options |= options;
|
||||
@@ -989,8 +993,6 @@ RubberBandStretcher::Impl::process(const float *const *input, size_t samples, bo
|
||||
|
||||
while (!allConsumed) {
|
||||
|
||||
// cerr << "process looping" << endl;
|
||||
|
||||
//#ifndef NO_THREADING
|
||||
// if (m_threaded) {
|
||||
// pthread_mutex_lock(&m_inputProcessedMutex);
|
||||
@@ -1052,6 +1054,9 @@ RubberBandStretcher::Impl::process(const float *const *input, size_t samples, bo
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (!allConsumed) cerr << "process looping" << endl;
|
||||
|
||||
}
|
||||
|
||||
// cerr << "process returning" << endl;
|
||||
|
||||
@@ -110,6 +110,8 @@ RubberBandStretcher::Impl::resampleBeforeStretching() const
|
||||
|
||||
if (m_options & OptionPitchHighQuality) {
|
||||
return (m_pitchScale < 1.0); // better sound
|
||||
} else if (m_options & OptionPitchHighConsistency) {
|
||||
return false;
|
||||
} else {
|
||||
return (m_pitchScale > 1.0); // better performance
|
||||
}
|
||||
@@ -145,6 +147,8 @@ RubberBandStretcher::Impl::consumeChannel(size_t c, const float *input,
|
||||
}
|
||||
|
||||
|
||||
// std::cerr << "resampling on INPUT" << std::endl;
|
||||
|
||||
toWrite = cd.resampler->resample(&input,
|
||||
&cd.resamplebuf,
|
||||
samples,
|
||||
@@ -1009,7 +1013,9 @@ RubberBandStretcher::Impl::writeChunk(size_t channel, size_t shiftIncrement, boo
|
||||
|
||||
bool resampledAlready = resampleBeforeStretching();
|
||||
|
||||
if (!resampledAlready && m_pitchScale != 1.0 && cd.resampler) {
|
||||
if (!resampledAlready &&
|
||||
(m_pitchScale != 1.0 || m_options & OptionPitchHighConsistency) &&
|
||||
cd.resampler) {
|
||||
|
||||
size_t reqSize = int(ceil(si / m_pitchScale));
|
||||
if (reqSize > cd.resamplebufSize) {
|
||||
@@ -1024,6 +1030,8 @@ RubberBandStretcher::Impl::writeChunk(size_t channel, size_t shiftIncrement, boo
|
||||
}
|
||||
|
||||
|
||||
// std::cerr << "resampling on OUTPUT" << std::endl;
|
||||
|
||||
size_t outframes = cd.resampler->resample(&cd.accumulator,
|
||||
&cd.resamplebuf,
|
||||
si,
|
||||
|
||||
Reference in New Issue
Block a user