From 55aa6f15e96d95659ee3761068f2f6a5dd43193d Mon Sep 17 00:00:00 2001 From: oparviai Date: Fri, 14 Jun 2013 17:34:33 +0000 Subject: [PATCH] Bugfix and cleanups --- source/SoundStretch/main.cpp | 4 ++-- source/SoundTouch/RateTransposer.cpp | 12 ++++++------ source/SoundTouch/TDStretch.cpp | 6 +----- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/source/SoundStretch/main.cpp b/source/SoundStretch/main.cpp index c34db33..daff86c 100644 --- a/source/SoundStretch/main.cpp +++ b/source/SoundStretch/main.cpp @@ -48,8 +48,8 @@ using namespace soundtouch; using namespace std; -// Processing chunk size -#define BUFF_SIZE 2048 +// Processing chunk size (size chosen to be divisible by 2, 4, 6, 8, 10, 12, 14, 16 channels ...) +#define BUFF_SIZE 6720 #if _WIN32 #include diff --git a/source/SoundTouch/RateTransposer.cpp b/source/SoundTouch/RateTransposer.cpp index 6913972..3fb1e46 100644 --- a/source/SoundTouch/RateTransposer.cpp +++ b/source/SoundTouch/RateTransposer.cpp @@ -394,9 +394,9 @@ RateTransposerInteger::~RateTransposerInteger() void RateTransposerInteger::resetRegisters() { iSlopeCount = 0; - if (sPrevSample) delete[] sPrevSample; + delete[] sPrevSample; sPrevSample = new SAMPLETYPE[numChannels]; - memset(sPrevSample, 0, numChannels*sizeof(*sPrevSample)); + memset(sPrevSample, 0, numChannels * sizeof(SAMPLETYPE)); } @@ -579,7 +579,7 @@ RateTransposerFloat::RateTransposerFloat() : RateTransposer() { // Notice: use local function calling syntax for sake of clarity, // to indicate the fact that C++ constructor can't call virtual functions. - sPrevSample=0; + sPrevSample = NULL; RateTransposerFloat::resetRegisters(); RateTransposerFloat::setRate(1.0f); } @@ -587,16 +587,16 @@ RateTransposerFloat::RateTransposerFloat() : RateTransposer() RateTransposerFloat::~RateTransposerFloat() { - if (sPrevSample) delete[] sPrevSample; + delete[] sPrevSample; } void RateTransposerFloat::resetRegisters() { fSlopeCount = 0; - if (sPrevSample) delete[] sPrevSample; + delete[] sPrevSample; sPrevSample = new SAMPLETYPE[numChannels]; - memset(sPrevSample, 0, numChannels*sizeof(*sPrevSample)); + memset(sPrevSample, 0, numChannels * sizeof(SAMPLETYPE)); } diff --git a/source/SoundTouch/TDStretch.cpp b/source/SoundTouch/TDStretch.cpp index f2060bc..3f215dc 100644 --- a/source/SoundTouch/TDStretch.cpp +++ b/source/SoundTouch/TDStretch.cpp @@ -51,8 +51,6 @@ #include "cpu_detect.h" #include "TDStretch.h" -#include - using namespace soundtouch; #define max(x, y) (((x) > (y)) ? (x) : (y)) @@ -159,7 +157,6 @@ void TDStretch::setParameters(int aSampleRate, int aSequenceMS, // set tempo to recalculate 'sampleReq' setTempo(tempo); - } @@ -511,7 +508,6 @@ void TDStretch::processNominalTempo() } */ -#include // Processes as many processing frames of the samples 'inputBuffer', store // the result into 'outputBuffer' @@ -601,7 +597,7 @@ void TDStretch::acceptNewOverlapLength(int newOverlapLength) { delete[] pMidBufferUnaligned; - pMidBufferUnaligned = new SAMPLETYPE[overlapLength * 2 + 16 / sizeof(SAMPLETYPE)]; + pMidBufferUnaligned = new SAMPLETYPE[overlapLength * channels + 16 / sizeof(SAMPLETYPE)]; // ensure that 'pMidBuffer' is aligned to 16 byte boundary for efficiency pMidBuffer = (SAMPLETYPE *)SOUNDTOUCH_ALIGN_POINTER_16(pMidBufferUnaligned);