From f7f1e2298bb115e25882231a8b1a15a281541532 Mon Sep 17 00:00:00 2001 From: oparviai Date: Sun, 3 Aug 2008 18:19:40 +0000 Subject: [PATCH] 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. --- source/SoundTouch/TDStretch.cpp | 16 ++++++---------- source/SoundTouch/TDStretch.h | 8 ++++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/source/SoundTouch/TDStretch.cpp b/source/SoundTouch/TDStretch.cpp index ddfd2f7..f6bb0b5 100644 --- a/source/SoundTouch/TDStretch.cpp +++ b/source/SoundTouch/TDStretch.cpp @@ -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; diff --git a/source/SoundTouch/TDStretch.h b/source/SoundTouch/TDStretch.h index 09e0c5d..af29ac6 100644 --- a/source/SoundTouch/TDStretch.h +++ b/source/SoundTouch/TDStretch.h @@ -192,10 +192,10 @@ public: /// 'seekwindowMS' = seeking window length for scanning the best overlapping /// 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) + void setParameters(int sampleRate, ///< Samplerate of sound being processed (Hz) + 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.