Bugfix and cleanups

This commit is contained in:
oparviai 2013-06-14 17:34:33 +00:00
parent 8c65661b91
commit 55aa6f15e9
3 changed files with 9 additions and 13 deletions

View File

@ -48,8 +48,8 @@
using namespace soundtouch; using namespace soundtouch;
using namespace std; using namespace std;
// Processing chunk size // Processing chunk size (size chosen to be divisible by 2, 4, 6, 8, 10, 12, 14, 16 channels ...)
#define BUFF_SIZE 2048 #define BUFF_SIZE 6720
#if _WIN32 #if _WIN32
#include <io.h> #include <io.h>

View File

@ -394,9 +394,9 @@ RateTransposerInteger::~RateTransposerInteger()
void RateTransposerInteger::resetRegisters() void RateTransposerInteger::resetRegisters()
{ {
iSlopeCount = 0; iSlopeCount = 0;
if (sPrevSample) delete[] sPrevSample; delete[] sPrevSample;
sPrevSample = new SAMPLETYPE[numChannels]; 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, // Notice: use local function calling syntax for sake of clarity,
// to indicate the fact that C++ constructor can't call virtual functions. // to indicate the fact that C++ constructor can't call virtual functions.
sPrevSample=0; sPrevSample = NULL;
RateTransposerFloat::resetRegisters(); RateTransposerFloat::resetRegisters();
RateTransposerFloat::setRate(1.0f); RateTransposerFloat::setRate(1.0f);
} }
@ -587,16 +587,16 @@ RateTransposerFloat::RateTransposerFloat() : RateTransposer()
RateTransposerFloat::~RateTransposerFloat() RateTransposerFloat::~RateTransposerFloat()
{ {
if (sPrevSample) delete[] sPrevSample; delete[] sPrevSample;
} }
void RateTransposerFloat::resetRegisters() void RateTransposerFloat::resetRegisters()
{ {
fSlopeCount = 0; fSlopeCount = 0;
if (sPrevSample) delete[] sPrevSample; delete[] sPrevSample;
sPrevSample = new SAMPLETYPE[numChannels]; sPrevSample = new SAMPLETYPE[numChannels];
memset(sPrevSample, 0, numChannels*sizeof(*sPrevSample)); memset(sPrevSample, 0, numChannels * sizeof(SAMPLETYPE));
} }

View File

@ -51,8 +51,6 @@
#include "cpu_detect.h" #include "cpu_detect.h"
#include "TDStretch.h" #include "TDStretch.h"
#include <stdio.h>
using namespace soundtouch; using namespace soundtouch;
#define max(x, y) (((x) > (y)) ? (x) : (y)) #define max(x, y) (((x) > (y)) ? (x) : (y))
@ -159,7 +157,6 @@ void TDStretch::setParameters(int aSampleRate, int aSequenceMS,
// set tempo to recalculate 'sampleReq' // set tempo to recalculate 'sampleReq'
setTempo(tempo); setTempo(tempo);
} }
@ -511,7 +508,6 @@ void TDStretch::processNominalTempo()
} }
*/ */
#include <stdio.h>
// Processes as many processing frames of the samples 'inputBuffer', store // Processes as many processing frames of the samples 'inputBuffer', store
// the result into 'outputBuffer' // the result into 'outputBuffer'
@ -601,7 +597,7 @@ void TDStretch::acceptNewOverlapLength(int newOverlapLength)
{ {
delete[] pMidBufferUnaligned; 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 // ensure that 'pMidBuffer' is aligned to 16 byte boundary for efficiency
pMidBuffer = (SAMPLETYPE *)SOUNDTOUCH_ALIGN_POINTER_16(pMidBufferUnaligned); pMidBuffer = (SAMPLETYPE *)SOUNDTOUCH_ALIGN_POINTER_16(pMidBufferUnaligned);