Fix in "setParameters": Negative function parameters values now mean "use the previous value". Earlier the function declaration used hardcoded default values for default parameters, and for this reason customized algorithm settings didn't work correctly.

This commit is contained in:
oparviai 2008-08-03 18:19:40 +00:00
parent d3d8ceb45d
commit f7f1e2298b
2 changed files with 10 additions and 14 deletions

View File

@ -123,15 +123,11 @@ TDStretch::~TDStretch()
void TDStretch::setParameters(int aSampleRate, int aSequenceMS,
int aSeekWindowMS, int aOverlapMS)
{
assert(aSampleRate >= 0);
assert(aSequenceMS >= 0);
assert(aSeekWindowMS >= 0);
assert(aOverlapMS >= 0);
this->sampleRate = aSampleRate;
this->sequenceMs = aSequenceMS;
this->seekWindowMs = aSeekWindowMS;
this->overlapMs = aOverlapMS;
// accept only positive parameter values - if negative, use old values instead
if (aSampleRate >= 0) this->sampleRate = aSampleRate;
if (aSequenceMS >= 0) this->sequenceMs = aSequenceMS;
if (aSeekWindowMS >= 0) this->seekWindowMs = aSeekWindowMS;
if (aOverlapMS >= 0) this->overlapMs = aOverlapMS;
seekLength = (sampleRate * seekWindowMs) / 1000;
seekWindowLength = (sampleRate * sequenceMs) / 1000;
@ -867,7 +863,7 @@ void TDStretch::precalcCorrReferenceMono()
}
// SSE-optimized version of the function overlapStereo
// Overlaps samples in 'midBuffer' with the samples in 'pInput'
void TDStretch::overlapStereo(float *pOutput, const float *pInput) const
{
int i;

View File

@ -193,9 +193,9 @@ public:
/// position
/// 'overlapMS' = overlapping length
void setParameters(int sampleRate, ///< Samplerate of sound being processed (Hz)
int sequenceMS = DEFAULT_SEQUENCE_MS, ///< Single processing sequence length (ms)
int seekwindowMS = DEFAULT_SEEKWINDOW_MS, ///< Offset seeking window length (ms)
int overlapMS = DEFAULT_OVERLAP_MS ///< Sequence overlapping length (ms)
int sequenceMS = -1, ///< Single processing sequence length (ms)
int seekwindowMS = -1, ///< Offset seeking window length (ms)
int overlapMS = -1 ///< Sequence overlapping length (ms)
);
/// Get routine control parameters, see setParameters() function.