mirror of
https://github.com/azahar-emu/soundtouch
synced 2025-11-07 07:30:02 +01:00
Removed commented code, style cleanup
This commit is contained in:
parent
cca9271e98
commit
c38f0506da
@ -14,7 +14,7 @@
|
|||||||
<body class="normal">
|
<body class="normal">
|
||||||
<hr>
|
<hr>
|
||||||
<h1>SoundTouch audio processing library v2.1pre</h1>
|
<h1>SoundTouch audio processing library v2.1pre</h1>
|
||||||
<p class="normal">SoundTouch library Copyright © Olli Parviainen 2001-2018</p>
|
<p class="normal">SoundTouch library Copyright <EFBFBD> Olli Parviainen 2001-2018</p>
|
||||||
<hr>
|
<hr>
|
||||||
<h2>1. Introduction </h2>
|
<h2>1. Introduction </h2>
|
||||||
<p>SoundTouch is an open-source audio processing library that allows
|
<p>SoundTouch is an open-source audio processing library that allows
|
||||||
@ -581,10 +581,11 @@ this corresponds to lowering the pitch by -0.318 semitones:</p>
|
|||||||
filter cause slight click if the rate change crosses zero during
|
filter cause slight click if the rate change crosses zero during
|
||||||
processing</li>
|
processing</li>
|
||||||
<li>Added script for building SoundTouchDll dynamic-link-library for GNU platforms</li>
|
<li>Added script for building SoundTouchDll dynamic-link-library for GNU platforms</li>
|
||||||
<li>Rewrote Beats-per-Minute analysis algorithm for more reliable BPM
|
<li>Rewrote Beats-per-Minute analysis algorithm for more reliable BPM detection</li>
|
||||||
detection</li>
|
|
||||||
<li>Added BPM functions to SoundTouchDll API</li>
|
<li>Added BPM functions to SoundTouchDll API</li>
|
||||||
<li>Migrated Visual Studio project files to MSVC 201x format</li>
|
<li>Migrated Visual Studio project files to MSVC 201x format</li>
|
||||||
|
<li>Replaced function parameter value asserts with runtime exceptions</li>
|
||||||
|
<li>Code maintenance & style cleanup</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><b>2.0:</b></p>
|
<p><b>2.0:</b></p>
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@ -66,82 +66,8 @@ namespace soundtouch
|
|||||||
/// Maximum allowed BPM rate range. Used to restrict accepted result below a reasonable limit.
|
/// Maximum allowed BPM rate range. Used to restrict accepted result below a reasonable limit.
|
||||||
#define MAX_BPM_VALID 190
|
#define MAX_BPM_VALID 190
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
|
||||||
class BeatCollection
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
int size;
|
|
||||||
|
|
||||||
// Ensure there's enough capacity in arrays
|
|
||||||
void EnsureCapacity(int newCapacity)
|
|
||||||
{
|
|
||||||
if (newCapacity > size)
|
|
||||||
{
|
|
||||||
// enlarge arrays
|
|
||||||
int oldSize = size;
|
|
||||||
float *beatPosOld = beatPos;
|
|
||||||
float *beatValuesOld = beatValues;
|
|
||||||
while (size < newCapacity) size *= 2;
|
|
||||||
printf("Alloc more %d\n", size);
|
|
||||||
beatPos = new float[size];
|
|
||||||
beatValues = new float[size];
|
|
||||||
if ((beatPos == NULL) || (beatValues == NULL))
|
|
||||||
{
|
|
||||||
ST_THROW_RT_ERROR("can't allocate memory");
|
|
||||||
}
|
|
||||||
// copy old arrays to new arrays
|
|
||||||
memcpy(beatPos, beatPosOld, sizeof(float)*oldSize);
|
|
||||||
memcpy(beatValues, beatValuesOld, sizeof(float)*oldSize);
|
|
||||||
// free old arrays
|
|
||||||
delete[] beatPosOld;
|
|
||||||
delete[] beatValuesOld;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
// beat position array
|
|
||||||
float *beatPos;
|
|
||||||
|
|
||||||
// beat values array
|
|
||||||
float *beatValues;
|
|
||||||
|
|
||||||
// number of beats in arrays
|
|
||||||
int numBeats;
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
BeatCollection()
|
|
||||||
{
|
|
||||||
numBeats = 0;
|
|
||||||
size = 1024;
|
|
||||||
beatPos = new float[size];
|
|
||||||
beatValues = new float[size];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// destructor
|
|
||||||
~BeatCollection()
|
|
||||||
{
|
|
||||||
delete[] beatPos;
|
|
||||||
delete[] beatValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// add new beat position into array
|
|
||||||
void Add(float pos, float value)
|
|
||||||
{
|
|
||||||
EnsureCapacity(numBeats + 1);
|
|
||||||
beatPos[numBeats] = pos;
|
|
||||||
beatValues[numBeats] = value;
|
|
||||||
numBeats++;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float pos;
|
float pos;
|
||||||
@ -257,7 +183,6 @@ public:
|
|||||||
int numSamples ///< Number of samples in buffer
|
int numSamples ///< Number of samples in buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/// Analyzes the results and returns the BPM rate. Use this function to read result
|
/// Analyzes the results and returns the BPM rate. Use this function to read result
|
||||||
/// after whole song data has been input to the class by consecutive calls of
|
/// after whole song data has been input to the class by consecutive calls of
|
||||||
/// 'inputSamples' function.
|
/// 'inputSamples' function.
|
||||||
@ -265,7 +190,6 @@ public:
|
|||||||
/// \return Beats-per-minute rate, or zero if detection failed.
|
/// \return Beats-per-minute rate, or zero if detection failed.
|
||||||
float getBpm();
|
float getBpm();
|
||||||
|
|
||||||
|
|
||||||
/// Get beat position arrays. Note: The array includes also really low beat detection values
|
/// Get beat position arrays. Note: The array includes also really low beat detection values
|
||||||
/// in absence of clear strong beats. Consumer may wish to filter low values away.
|
/// in absence of clear strong beats. Consumer may wish to filter low values away.
|
||||||
/// - "pos" receive array of beat positions
|
/// - "pos" receive array of beat positions
|
||||||
|
|||||||
@ -127,7 +127,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Base-class for sound processing routines working in FIFO principle. With this base
|
/// Base-class for sound processing routines working in FIFO principle. With this base
|
||||||
/// class it's easy to implement sound processing stages that can be chained together,
|
/// class it's easy to implement sound processing stages that can be chained together,
|
||||||
/// so that samples that are fed into beginning of the pipe automatically go through
|
/// so that samples that are fed into beginning of the pipe automatically go through
|
||||||
@ -150,7 +149,6 @@ protected:
|
|||||||
output = pOutput;
|
output = pOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Constructor. Doesn't define output pipe; it has to be set be
|
/// Constructor. Doesn't define output pipe; it has to be set be
|
||||||
/// 'setOutPipe' function.
|
/// 'setOutPipe' function.
|
||||||
FIFOProcessor()
|
FIFOProcessor()
|
||||||
@ -158,7 +156,6 @@ protected:
|
|||||||
output = NULL;
|
output = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Constructor. Configures output pipe.
|
/// Constructor. Configures output pipe.
|
||||||
FIFOProcessor(FIFOSamplePipe *pOutput ///< Output pipe.
|
FIFOProcessor(FIFOSamplePipe *pOutput ///< Output pipe.
|
||||||
)
|
)
|
||||||
@ -166,13 +163,11 @@ protected:
|
|||||||
output = pOutput;
|
output = pOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~FIFOProcessor()
|
virtual ~FIFOProcessor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Returns a pointer to the beginning of the output samples.
|
/// Returns a pointer to the beginning of the output samples.
|
||||||
/// This function is provided for accessing the output samples directly.
|
/// This function is provided for accessing the output samples directly.
|
||||||
/// Please be careful for not to corrupt the book-keeping!
|
/// Please be careful for not to corrupt the book-keeping!
|
||||||
@ -199,7 +194,6 @@ public:
|
|||||||
return output->receiveSamples(outBuffer, maxSamples);
|
return output->receiveSamples(outBuffer, maxSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Adjusts book-keeping so that given number of samples are removed from beginning of the
|
/// Adjusts book-keeping so that given number of samples are removed from beginning of the
|
||||||
/// sample buffer without copying them anywhere.
|
/// sample buffer without copying them anywhere.
|
||||||
///
|
///
|
||||||
@ -211,14 +205,12 @@ public:
|
|||||||
return output->receiveSamples(maxSamples);
|
return output->receiveSamples(maxSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Returns number of samples currently available.
|
/// Returns number of samples currently available.
|
||||||
virtual uint numSamples() const
|
virtual uint numSamples() const
|
||||||
{
|
{
|
||||||
return output->numSamples();
|
return output->numSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Returns nonzero if there aren't any samples available for outputting.
|
/// Returns nonzero if there aren't any samples available for outputting.
|
||||||
virtual int isEmpty() const
|
virtual int isEmpty() const
|
||||||
{
|
{
|
||||||
@ -231,7 +223,6 @@ public:
|
|||||||
{
|
{
|
||||||
return output->adjustAmountOfSamples(numSamples);
|
return output->adjustAmountOfSamples(numSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -151,7 +151,6 @@ RunParameters::RunParameters(const int nParams, const char * const paramStr[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Checks parameter limits
|
// Checks parameter limits
|
||||||
void RunParameters::checkLimits()
|
void RunParameters::checkLimits()
|
||||||
{
|
{
|
||||||
@ -184,7 +183,6 @@ void RunParameters::checkLimits()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Unknown switch parameter -- throws an exception with an error message
|
// Unknown switch parameter -- throws an exception with an error message
|
||||||
void RunParameters::throwIllegalParamExp(const string &str) const
|
void RunParameters::throwIllegalParamExp(const string &str) const
|
||||||
{
|
{
|
||||||
@ -196,7 +194,6 @@ void RunParameters::throwIllegalParamExp(const string &str) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void RunParameters::throwLicense() const
|
void RunParameters::throwLicense() const
|
||||||
{
|
{
|
||||||
ST_THROW_RT_ERROR(licenseText);
|
ST_THROW_RT_ERROR(licenseText);
|
||||||
|
|||||||
@ -56,7 +56,6 @@ static const char fmtStr[] = "fmt ";
|
|||||||
static const char factStr[] = "fact";
|
static const char factStr[] = "fact";
|
||||||
static const char dataStr[] = "data";
|
static const char dataStr[] = "data";
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Helper functions for swapping byte order to correctly read/write WAV files
|
// Helper functions for swapping byte order to correctly read/write WAV files
|
||||||
@ -228,19 +227,10 @@ void WavInFile::init()
|
|||||||
ST_THROW_RT_ERROR("Error: Illegal wav file header format parameters.");
|
ST_THROW_RT_ERROR("Error: Illegal wav file header format parameters.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore 'fixed' field value as 32bit signed linear data can have other value than 1.
|
|
||||||
if (header.format.fixed != 1)
|
|
||||||
{
|
|
||||||
string msg = "Input file uses unsupported encoding.";
|
|
||||||
ST_THROW_RT_ERROR(msg.c_str());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
dataRead = 0;
|
dataRead = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WavInFile::~WavInFile()
|
WavInFile::~WavInFile()
|
||||||
{
|
{
|
||||||
if (fptr) fclose(fptr);
|
if (fptr) fclose(fptr);
|
||||||
@ -248,7 +238,6 @@ WavInFile::~WavInFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WavInFile::rewind()
|
void WavInFile::rewind()
|
||||||
{
|
{
|
||||||
int hdrsOk;
|
int hdrsOk;
|
||||||
@ -465,7 +454,6 @@ int WavInFile::eof() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// test if character code is between a white space ' ' and little 'z'
|
// test if character code is between a white space ' ' and little 'z'
|
||||||
static int isAlpha(char c)
|
static int isAlpha(char c)
|
||||||
{
|
{
|
||||||
@ -506,8 +494,6 @@ int WavInFile::readRIFFBlock()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int WavInFile::readHeaderBlock()
|
int WavInFile::readHeaderBlock()
|
||||||
{
|
{
|
||||||
char label[5];
|
char label[5];
|
||||||
@ -679,7 +665,6 @@ uint WavInFile::getSampleRate() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint WavInFile::getDataSizeInBytes() const
|
uint WavInFile::getDataSizeInBytes() const
|
||||||
{
|
{
|
||||||
return header.data.data_len;
|
return header.data.data_len;
|
||||||
@ -713,7 +698,6 @@ uint WavInFile::getElapsedMS() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Class WavOutFile
|
// Class WavOutFile
|
||||||
@ -752,7 +736,6 @@ WavOutFile::WavOutFile(FILE *file, int sampleRate, int bits, int channels)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WavOutFile::~WavOutFile()
|
WavOutFile::~WavOutFile()
|
||||||
{
|
{
|
||||||
finishHeader();
|
finishHeader();
|
||||||
@ -761,7 +744,6 @@ WavOutFile::~WavOutFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WavOutFile::fillInHeader(uint sampleRate, uint bits, uint channels)
|
void WavOutFile::fillInHeader(uint sampleRate, uint bits, uint channels)
|
||||||
{
|
{
|
||||||
// fill in the 'riff' part..
|
// fill in the 'riff' part..
|
||||||
@ -812,7 +794,6 @@ void WavOutFile::finishHeader()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WavOutFile::writeHeader()
|
void WavOutFile::writeHeader()
|
||||||
{
|
{
|
||||||
WavHeader hdrTemp;
|
WavHeader hdrTemp;
|
||||||
@ -845,7 +826,6 @@ void WavOutFile::writeHeader()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WavOutFile::write(const unsigned char *buffer, int numElems)
|
void WavOutFile::write(const unsigned char *buffer, int numElems)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
@ -866,7 +846,6 @@ void WavOutFile::write(const unsigned char *buffer, int numElems)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WavOutFile::write(const short *buffer, int numElems)
|
void WavOutFile::write(const short *buffer, int numElems)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|||||||
@ -218,7 +218,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Class for writing WAV audio files.
|
/// Class for writing WAV audio files.
|
||||||
class WavOutFile : protected WavFileBase
|
class WavOutFile : protected WavFileBase
|
||||||
{
|
{
|
||||||
|
|||||||
@ -108,7 +108,6 @@ static void openFiles(WavInFile **inFile, WavOutFile **outFile, const RunParamet
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets the 'SoundTouch' object up according to input file sound format &
|
// Sets the 'SoundTouch' object up according to input file sound format &
|
||||||
// command line parameters
|
// command line parameters
|
||||||
static void setup(SoundTouch *pSoundTouch, const WavInFile *inFile, const RunParameters *params)
|
static void setup(SoundTouch *pSoundTouch, const WavInFile *inFile, const RunParameters *params)
|
||||||
@ -165,7 +164,6 @@ static void setup(SoundTouch *pSoundTouch, const WavInFile *inFile, const RunPar
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Processes the sound
|
// Processes the sound
|
||||||
static void process(SoundTouch *pSoundTouch, WavInFile *inFile, WavOutFile *outFile)
|
static void process(SoundTouch *pSoundTouch, WavInFile *inFile, WavOutFile *outFile)
|
||||||
{
|
{
|
||||||
@ -218,7 +216,6 @@ static void process(SoundTouch *pSoundTouch, WavInFile *inFile, WavOutFile *outF
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Detect BPM rate of inFile and adjust tempo setting accordingly if necessary
|
// Detect BPM rate of inFile and adjust tempo setting accordingly if necessary
|
||||||
static void detectBPM(WavInFile *inFile, RunParameters *params)
|
static void detectBPM(WavInFile *inFile, RunParameters *params)
|
||||||
{
|
{
|
||||||
@ -274,7 +271,6 @@ static void detectBPM(WavInFile *inFile, RunParameters *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(const int nParams, const char * const paramStr[])
|
int main(const int nParams, const char * const paramStr[])
|
||||||
{
|
{
|
||||||
WavInFile *inFile;
|
WavInFile *inFile;
|
||||||
|
|||||||
@ -68,7 +68,6 @@ using namespace soundtouch;
|
|||||||
#define _DEBUG_SAVE_AAFIR_COEFFS(x, y)
|
#define _DEBUG_SAVE_AAFIR_COEFFS(x, y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
* Implementation of the class 'AAFilter'
|
* Implementation of the class 'AAFilter'
|
||||||
@ -83,14 +82,12 @@ AAFilter::AAFilter(uint len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AAFilter::~AAFilter()
|
AAFilter::~AAFilter()
|
||||||
{
|
{
|
||||||
delete pFIR;
|
delete pFIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets new anti-alias filter cut-off edge frequency, scaled to
|
// Sets new anti-alias filter cut-off edge frequency, scaled to
|
||||||
// sampling frequency (nyquist frequency = 0.5).
|
// sampling frequency (nyquist frequency = 0.5).
|
||||||
// The filter will cut frequencies higher than the given frequency.
|
// The filter will cut frequencies higher than the given frequency.
|
||||||
@ -101,7 +98,6 @@ void AAFilter::setCutoffFreq(double newCutoffFreq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets number of FIR filter taps
|
// Sets number of FIR filter taps
|
||||||
void AAFilter::setLength(uint newLength)
|
void AAFilter::setLength(uint newLength)
|
||||||
{
|
{
|
||||||
@ -110,7 +106,6 @@ void AAFilter::setLength(uint newLength)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Calculates coefficients for a low-pass FIR filter using Hamming window
|
// Calculates coefficients for a low-pass FIR filter using Hamming window
|
||||||
void AAFilter::calculateCoeffs()
|
void AAFilter::calculateCoeffs()
|
||||||
{
|
{
|
||||||
@ -170,12 +165,10 @@ void AAFilter::calculateCoeffs()
|
|||||||
for (i = 0; i < length; i ++)
|
for (i = 0; i < length; i ++)
|
||||||
{
|
{
|
||||||
temp = work[i] * scaleCoeff;
|
temp = work[i] * scaleCoeff;
|
||||||
//#if SOUNDTOUCH_INTEGER_SAMPLES
|
|
||||||
// scale & round to nearest integer
|
// scale & round to nearest integer
|
||||||
temp += (temp >= 0) ? 0.5 : -0.5;
|
temp += (temp >= 0) ? 0.5 : -0.5;
|
||||||
// ensure no overfloods
|
// ensure no overfloods
|
||||||
assert(temp >= -32768 && temp <= 32767);
|
assert(temp >= -32768 && temp <= 32767);
|
||||||
//#endif
|
|
||||||
coeffs[i] = (SAMPLETYPE)temp;
|
coeffs[i] = (SAMPLETYPE)temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -265,4 +265,3 @@ uint FIFOSampleBuffer::adjustAmountOfSamples(uint numSamples)
|
|||||||
}
|
}
|
||||||
return samplesInBuffer;
|
return samplesInBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,6 +68,7 @@ FIRFilter::~FIRFilter()
|
|||||||
delete[] filterCoeffs;
|
delete[] filterCoeffs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Usual C-version of the filter routine for stereo sound
|
// Usual C-version of the filter routine for stereo sound
|
||||||
uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
|
uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
|
||||||
{
|
{
|
||||||
@ -126,8 +127,6 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Usual C-version of the filter routine for mono sound
|
// Usual C-version of the filter routine for mono sound
|
||||||
uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
|
uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
|
||||||
{
|
{
|
||||||
@ -253,7 +252,6 @@ uint FIRFilter::getLength() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Applies the filter to the given sequence of samples.
|
// Applies the filter to the given sequence of samples.
|
||||||
//
|
//
|
||||||
// Note : The amount of outputted samples is by value of 'filter_length'
|
// Note : The amount of outputted samples is by value of 'filter_length'
|
||||||
@ -283,7 +281,6 @@ uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSample
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Operator 'new' is overloaded so that it automatically creates a suitable instance
|
// Operator 'new' is overloaded so that it automatically creates a suitable instance
|
||||||
// depending on if we've a MMX-capable CPU available or not.
|
// depending on if we've a MMX-capable CPU available or not.
|
||||||
void * FIRFilter::operator new(size_t s)
|
void * FIRFilter::operator new(size_t s)
|
||||||
|
|||||||
@ -57,7 +57,7 @@ int PeakFinder::findTop(const float *data, int peakpos) const
|
|||||||
|
|
||||||
refvalue = data[peakpos];
|
refvalue = data[peakpos];
|
||||||
|
|
||||||
// seek within ±10 points
|
// seek within <EFBFBD>10 points
|
||||||
start = peakpos - 10;
|
start = peakpos - 10;
|
||||||
if (start < minPos) start = minPos;
|
if (start < minPos) start = minPos;
|
||||||
end = peakpos + 10;
|
end = peakpos + 10;
|
||||||
@ -171,7 +171,6 @@ double PeakFinder::calcMassCenter(const float *data, int firstPos, int lastPos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// get exact center of peak near given position by calculating local mass of center
|
/// get exact center of peak near given position by calculating local mass of center
|
||||||
double PeakFinder::getPeakCenter(const float *data, int peakpos) const
|
double PeakFinder::getPeakCenter(const float *data, int peakpos) const
|
||||||
{
|
{
|
||||||
@ -211,7 +210,6 @@ double PeakFinder::getPeakCenter(const float *data, int peakpos) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double PeakFinder::detectPeak(const float *data, int aminPos, int amaxPos)
|
double PeakFinder::detectPeak(const float *data, int aminPos, int amaxPos)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -258,7 +256,7 @@ double PeakFinder::detectPeak(const float *data, int aminPos, int amaxPos)
|
|||||||
|
|
||||||
// accept harmonic peak if
|
// accept harmonic peak if
|
||||||
// (a) it is found
|
// (a) it is found
|
||||||
// (b) is within ±4% of the expected harmonic interval
|
// (b) is within <EFBFBD>4% of the expected harmonic interval
|
||||||
// (c) has at least half x-corr value of the max. peak
|
// (c) has at least half x-corr value of the max. peak
|
||||||
|
|
||||||
double diff = harmonic * peaktmp / highPeak;
|
double diff = harmonic * peaktmp / highPeak;
|
||||||
|
|||||||
@ -64,7 +64,6 @@ RateTransposer::RateTransposer() : FIFOProcessor(&outputBuffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RateTransposer::~RateTransposer()
|
RateTransposer::~RateTransposer()
|
||||||
{
|
{
|
||||||
delete pAAFilter;
|
delete pAAFilter;
|
||||||
@ -72,7 +71,6 @@ RateTransposer::~RateTransposer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
|
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
|
||||||
void RateTransposer::enableAAFilter(bool newMode)
|
void RateTransposer::enableAAFilter(bool newMode)
|
||||||
{
|
{
|
||||||
@ -96,7 +94,6 @@ AAFilter *RateTransposer::getAAFilter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
|
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
|
||||||
// iRate, larger faster iRates.
|
// iRate, larger faster iRates.
|
||||||
void RateTransposer::setRate(double newRate)
|
void RateTransposer::setRate(double newRate)
|
||||||
|
|||||||
@ -125,21 +125,9 @@ public:
|
|||||||
RateTransposer();
|
RateTransposer();
|
||||||
virtual ~RateTransposer();
|
virtual ~RateTransposer();
|
||||||
|
|
||||||
/// Operator 'new' is overloaded so that it automatically creates a suitable instance
|
|
||||||
/// depending on if we're to use integer or floating point arithmetic.
|
|
||||||
// static void *operator new(size_t s);
|
|
||||||
|
|
||||||
/// Use this function instead of "new" operator to create a new instance of this class.
|
|
||||||
/// This function automatically chooses a correct implementation, depending on if
|
|
||||||
/// integer or floating point arithmetic are to be used.
|
|
||||||
// static RateTransposer *newInstance();
|
|
||||||
|
|
||||||
/// Returns the output buffer object
|
/// Returns the output buffer object
|
||||||
FIFOSamplePipe *getOutput() { return &outputBuffer; };
|
FIFOSamplePipe *getOutput() { return &outputBuffer; };
|
||||||
|
|
||||||
/// Returns the store buffer object
|
|
||||||
// FIFOSamplePipe *getStore() { return &storeBuffer; };
|
|
||||||
|
|
||||||
/// Return anti-alias filter object
|
/// Return anti-alias filter object
|
||||||
AAFilter *getAAFilter();
|
AAFilter *getAAFilter();
|
||||||
|
|
||||||
|
|||||||
@ -111,7 +111,6 @@ SoundTouch::SoundTouch()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SoundTouch::~SoundTouch()
|
SoundTouch::~SoundTouch()
|
||||||
{
|
{
|
||||||
delete pRateTransposer;
|
delete pRateTransposer;
|
||||||
@ -119,7 +118,6 @@ SoundTouch::~SoundTouch()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Get SoundTouch library version string
|
/// Get SoundTouch library version string
|
||||||
const char *SoundTouch::getVersionString()
|
const char *SoundTouch::getVersionString()
|
||||||
{
|
{
|
||||||
@ -156,7 +154,6 @@ void SoundTouch::setRate(double newRate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets new rate control value as a difference in percents compared
|
// Sets new rate control value as a difference in percents compared
|
||||||
// to the original rate (-50 .. +100 %)
|
// to the original rate (-50 .. +100 %)
|
||||||
void SoundTouch::setRateChange(double newRate)
|
void SoundTouch::setRateChange(double newRate)
|
||||||
@ -166,7 +163,6 @@ void SoundTouch::setRateChange(double newRate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets new tempo control value. Normal tempo = 1.0, smaller values
|
// Sets new tempo control value. Normal tempo = 1.0, smaller values
|
||||||
// represent slower tempo, larger faster tempo.
|
// represent slower tempo, larger faster tempo.
|
||||||
void SoundTouch::setTempo(double newTempo)
|
void SoundTouch::setTempo(double newTempo)
|
||||||
@ -176,7 +172,6 @@ void SoundTouch::setTempo(double newTempo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets new tempo control value as a difference in percents compared
|
// Sets new tempo control value as a difference in percents compared
|
||||||
// to the original tempo (-50 .. +100 %)
|
// to the original tempo (-50 .. +100 %)
|
||||||
void SoundTouch::setTempoChange(double newTempo)
|
void SoundTouch::setTempoChange(double newTempo)
|
||||||
@ -186,7 +181,6 @@ void SoundTouch::setTempoChange(double newTempo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets new pitch control value. Original pitch = 1.0, smaller values
|
// Sets new pitch control value. Original pitch = 1.0, smaller values
|
||||||
// represent lower pitches, larger values higher pitch.
|
// represent lower pitches, larger values higher pitch.
|
||||||
void SoundTouch::setPitch(double newPitch)
|
void SoundTouch::setPitch(double newPitch)
|
||||||
@ -196,7 +190,6 @@ void SoundTouch::setPitch(double newPitch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets pitch change in octaves compared to the original pitch
|
// Sets pitch change in octaves compared to the original pitch
|
||||||
// (-1.00 .. +1.00)
|
// (-1.00 .. +1.00)
|
||||||
void SoundTouch::setPitchOctaves(double newPitch)
|
void SoundTouch::setPitchOctaves(double newPitch)
|
||||||
@ -206,7 +199,6 @@ void SoundTouch::setPitchOctaves(double newPitch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets pitch change in semi-tones compared to the original pitch
|
// Sets pitch change in semi-tones compared to the original pitch
|
||||||
// (-12 .. +12)
|
// (-12 .. +12)
|
||||||
void SoundTouch::setPitchSemiTones(int newPitch)
|
void SoundTouch::setPitchSemiTones(int newPitch)
|
||||||
@ -215,7 +207,6 @@ void SoundTouch::setPitchSemiTones(int newPitch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SoundTouch::setPitchSemiTones(double newPitch)
|
void SoundTouch::setPitchSemiTones(double newPitch)
|
||||||
{
|
{
|
||||||
setPitchOctaves(newPitch / 12.0);
|
setPitchOctaves(newPitch / 12.0);
|
||||||
@ -294,22 +285,6 @@ void SoundTouch::putSamples(const SAMPLETYPE *samples, uint nSamples)
|
|||||||
ST_THROW_RT_ERROR("SoundTouch : Number of channels not defined");
|
ST_THROW_RT_ERROR("SoundTouch : Number of channels not defined");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transpose the rate of the new samples if necessary
|
|
||||||
/* Bypass the nominal setting - can introduce a click in sound when tempo/pitch control crosses the nominal value...
|
|
||||||
if (rate == 1.0f)
|
|
||||||
{
|
|
||||||
// The rate value is same as the original, simply evaluate the tempo changer.
|
|
||||||
assert(output == pTDStretch);
|
|
||||||
if (pRateTransposer->isEmpty() == 0)
|
|
||||||
{
|
|
||||||
// yet flush the last samples in the pitch transposer buffer
|
|
||||||
// (may happen if 'rate' changes from a non-zero value to zero)
|
|
||||||
pTDStretch->moveSamples(*pRateTransposer);
|
|
||||||
}
|
|
||||||
pTDStretch->putSamples(samples, nSamples);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// accumulate how many samples are expected out from processing, given the current
|
// accumulate how many samples are expected out from processing, given the current
|
||||||
// processing setting
|
// processing setting
|
||||||
samplesExpectedOut += (double)nSamples / ((double)rate * (double)tempo);
|
samplesExpectedOut += (double)nSamples / ((double)rate * (double)tempo);
|
||||||
@ -365,7 +340,6 @@ void SoundTouch::flush()
|
|||||||
delete[] buff;
|
delete[] buff;
|
||||||
|
|
||||||
// Clear input buffers
|
// Clear input buffers
|
||||||
// pRateTransposer->clearInput();
|
|
||||||
pTDStretch->clearInput();
|
pTDStretch->clearInput();
|
||||||
// yet leave the output intouched as that's where the
|
// yet leave the output intouched as that's where the
|
||||||
// flushed samples are!
|
// flushed samples are!
|
||||||
@ -502,7 +476,6 @@ int SoundTouch::getSetting(int settingId) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Clears all the samples in the object's output and internal processing
|
// Clears all the samples in the object's output and internal processing
|
||||||
// buffers.
|
// buffers.
|
||||||
void SoundTouch::clear()
|
void SoundTouch::clear()
|
||||||
@ -514,7 +487,6 @@ void SoundTouch::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Returns number of samples currently unprocessed.
|
/// Returns number of samples currently unprocessed.
|
||||||
uint SoundTouch::numUnprocessedSamples() const
|
uint SoundTouch::numUnprocessedSamples() const
|
||||||
{
|
{
|
||||||
@ -531,7 +503,6 @@ uint SoundTouch::numUnprocessedSamples() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Output samples from beginning of the sample buffer. Copies requested samples to
|
/// Output samples from beginning of the sample buffer. Copies requested samples to
|
||||||
/// output buffer and removes them from the sample buffer. If there are less than
|
/// output buffer and removes them from the sample buffer. If there are less than
|
||||||
/// 'numsample' samples in the buffer, returns all that available.
|
/// 'numsample' samples in the buffer, returns all that available.
|
||||||
|
|||||||
@ -157,7 +157,6 @@ protected:
|
|||||||
void calcSeqParameters();
|
void calcSeqParameters();
|
||||||
void adaptNormalizer();
|
void adaptNormalizer();
|
||||||
|
|
||||||
|
|
||||||
/// Changes the tempo of the given sound samples.
|
/// Changes the tempo of the given sound samples.
|
||||||
/// Returns amount of samples returned in the "output" buffer.
|
/// Returns amount of samples returned in the "output" buffer.
|
||||||
/// The maximum amount of samples that can be returned at a time is set by
|
/// The maximum amount of samples that can be returned at a time is set by
|
||||||
@ -242,7 +241,6 @@ public:
|
|||||||
return seekWindowLength - overlapLength;
|
return seekWindowLength - overlapLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// return approximate initial input-output latency
|
/// return approximate initial input-output latency
|
||||||
int getLatency() const
|
int getLatency() const
|
||||||
{
|
{
|
||||||
@ -251,7 +249,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Implementation-specific class declarations:
|
// Implementation-specific class declarations:
|
||||||
|
|
||||||
#ifdef SOUNDTOUCH_ALLOW_MMX
|
#ifdef SOUNDTOUCH_ALLOW_MMX
|
||||||
|
|||||||
@ -68,7 +68,6 @@ void disableExtensions(uint dwDisableMask)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Checks which instruction set extensions are supported by the CPU.
|
/// Checks which instruction set extensions are supported by the CPU.
|
||||||
uint detectCPUextensions(void)
|
uint detectCPUextensions(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -217,7 +217,6 @@ void TDStretchMMX::clearCrossCorrState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// MMX-optimized version of the function overlapStereo
|
// MMX-optimized version of the function overlapStereo
|
||||||
void TDStretchMMX::overlapStereo(short *output, const short *input) const
|
void TDStretchMMX::overlapStereo(short *output, const short *input) const
|
||||||
{
|
{
|
||||||
@ -333,7 +332,6 @@ void FIRFilterMMX::setCoefficients(const short *coeffs, uint newLength, uint uRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// mmx-optimized version of the filter routine for stereo sound
|
// mmx-optimized version of the filter routine for stereo sound
|
||||||
uint FIRFilterMMX::evaluateFilterStereo(short *dest, const short *src, uint numSamples) const
|
uint FIRFilterMMX::evaluateFilterStereo(short *dest, const short *src, uint numSamples) const
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user