diff --git a/README.html b/README.html
index 677319d..6dc3d71 100644
--- a/README.html
+++ b/README.html
@@ -14,7 +14,7 @@
SoundTouch audio processing library v2.1pre
-SoundTouch library Copyright © Olli Parviainen 2001-2018
+SoundTouch library Copyright � Olli Parviainen 2001-2018
1. Introduction
SoundTouch is an open-source audio processing library that allows
@@ -575,16 +575,17 @@ this corresponds to lowering the pitch by -0.318 semitones:
5.1. SoundTouch library Change History
2.1pre:
- - Refactored C# interface example
- - Disable anti-alias filter when switch
- SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER defined because anti-alias
- filter cause slight click if the rate change crosses zero during
- processing
- - Added script for building SoundTouchDll dynamic-link-library for GNU platforms
- - Rewrote Beats-per-Minute analysis algorithm for more reliable BPM
- detection
- - Added BPM functions to SoundTouchDll API
- - Migrated Visual Studio project files to MSVC 201x format
+ - Refactored C# interface example
+ - Disable anti-alias filter when switch
+ SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER defined because anti-alias
+ filter cause slight click if the rate change crosses zero during
+ processing
+ - Added script for building SoundTouchDll dynamic-link-library for GNU platforms
+ - Rewrote Beats-per-Minute analysis algorithm for more reliable BPM detection
+ - Added BPM functions to SoundTouchDll API
+ - Migrated Visual Studio project files to MSVC 201x format
+ - Replaced function parameter value asserts with runtime exceptions
+ - Code maintenance & style cleanup
2.0:
diff --git a/include/BPMDetect.h b/include/BPMDetect.h
index 8bd776e..8ece784 100644
--- a/include/BPMDetect.h
+++ b/include/BPMDetect.h
@@ -66,82 +66,8 @@ namespace soundtouch
/// Maximum allowed BPM rate range. Used to restrict accepted result below a reasonable limit.
#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
{
float pos;
@@ -257,7 +183,6 @@ public:
int numSamples ///< Number of samples in buffer
);
-
/// 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
/// 'inputSamples' function.
@@ -265,7 +190,6 @@ public:
/// \return Beats-per-minute rate, or zero if detection failed.
float getBpm();
-
/// 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.
/// - "pos" receive array of beat positions
diff --git a/include/FIFOSamplePipe.h b/include/FIFOSamplePipe.h
index b08f836..38ef31a 100644
--- a/include/FIFOSamplePipe.h
+++ b/include/FIFOSamplePipe.h
@@ -127,7 +127,6 @@ public:
};
-
/// 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,
/// so that samples that are fed into beginning of the pipe automatically go through
@@ -150,7 +149,6 @@ protected:
output = pOutput;
}
-
/// Constructor. Doesn't define output pipe; it has to be set be
/// 'setOutPipe' function.
FIFOProcessor()
@@ -158,7 +156,6 @@ protected:
output = NULL;
}
-
/// Constructor. Configures output pipe.
FIFOProcessor(FIFOSamplePipe *pOutput ///< Output pipe.
)
@@ -166,13 +163,11 @@ protected:
output = pOutput;
}
-
/// Destructor.
virtual ~FIFOProcessor()
{
}
-
/// Returns a pointer to the beginning of the output samples.
/// This function is provided for accessing the output samples directly.
/// Please be careful for not to corrupt the book-keeping!
@@ -199,7 +194,6 @@ public:
return output->receiveSamples(outBuffer, maxSamples);
}
-
/// Adjusts book-keeping so that given number of samples are removed from beginning of the
/// sample buffer without copying them anywhere.
///
@@ -211,14 +205,12 @@ public:
return output->receiveSamples(maxSamples);
}
-
/// Returns number of samples currently available.
virtual uint numSamples() const
{
return output->numSamples();
}
-
/// Returns nonzero if there aren't any samples available for outputting.
virtual int isEmpty() const
{
@@ -231,7 +223,6 @@ public:
{
return output->adjustAmountOfSamples(numSamples);
}
-
};
}
diff --git a/source/SoundStretch/RunParameters.cpp b/source/SoundStretch/RunParameters.cpp
index 33f726b..1960a35 100644
--- a/source/SoundStretch/RunParameters.cpp
+++ b/source/SoundStretch/RunParameters.cpp
@@ -151,7 +151,6 @@ RunParameters::RunParameters(const int nParams, const char * const paramStr[])
}
-
// Checks parameter limits
void RunParameters::checkLimits()
{
@@ -184,7 +183,6 @@ void RunParameters::checkLimits()
}
-
// Unknown switch parameter -- throws an exception with an error message
void RunParameters::throwIllegalParamExp(const string &str) const
{
@@ -196,7 +194,6 @@ void RunParameters::throwIllegalParamExp(const string &str) const
}
-
void RunParameters::throwLicense() const
{
ST_THROW_RT_ERROR(licenseText);
diff --git a/source/SoundStretch/WavFile.cpp b/source/SoundStretch/WavFile.cpp
index 68818c9..4af7a4c 100644
--- a/source/SoundStretch/WavFile.cpp
+++ b/source/SoundStretch/WavFile.cpp
@@ -56,7 +56,6 @@ static const char fmtStr[] = "fmt ";
static const char factStr[] = "fact";
static const char dataStr[] = "data";
-
//////////////////////////////////////////////////////////////////////////////
//
// 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.");
}
- /* 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;
}
-
WavInFile::~WavInFile()
{
if (fptr) fclose(fptr);
@@ -248,7 +238,6 @@ WavInFile::~WavInFile()
}
-
void WavInFile::rewind()
{
int hdrsOk;
@@ -465,7 +454,6 @@ int WavInFile::eof() const
}
-
// test if character code is between a white space ' ' and little 'z'
static int isAlpha(char c)
{
@@ -506,8 +494,6 @@ int WavInFile::readRIFFBlock()
}
-
-
int WavInFile::readHeaderBlock()
{
char label[5];
@@ -679,7 +665,6 @@ uint WavInFile::getSampleRate() const
}
-
uint WavInFile::getDataSizeInBytes() const
{
return header.data.data_len;
@@ -713,7 +698,6 @@ uint WavInFile::getElapsedMS() const
}
-
//////////////////////////////////////////////////////////////////////////////
//
// Class WavOutFile
@@ -752,7 +736,6 @@ WavOutFile::WavOutFile(FILE *file, int sampleRate, int bits, int channels)
}
-
WavOutFile::~WavOutFile()
{
finishHeader();
@@ -761,7 +744,6 @@ WavOutFile::~WavOutFile()
}
-
void WavOutFile::fillInHeader(uint sampleRate, uint bits, uint channels)
{
// fill in the 'riff' part..
@@ -812,7 +794,6 @@ void WavOutFile::finishHeader()
}
-
void WavOutFile::writeHeader()
{
WavHeader hdrTemp;
@@ -845,7 +826,6 @@ void WavOutFile::writeHeader()
}
-
void WavOutFile::write(const unsigned char *buffer, int numElems)
{
int res;
@@ -866,7 +846,6 @@ void WavOutFile::write(const unsigned char *buffer, int numElems)
}
-
void WavOutFile::write(const short *buffer, int numElems)
{
int res;
diff --git a/source/SoundStretch/WavFile.h b/source/SoundStretch/WavFile.h
index c6a2eb3..b0f4d96 100644
--- a/source/SoundStretch/WavFile.h
+++ b/source/SoundStretch/WavFile.h
@@ -218,7 +218,6 @@ public:
};
-
/// Class for writing WAV audio files.
class WavOutFile : protected WavFileBase
{
diff --git a/source/SoundStretch/main.cpp b/source/SoundStretch/main.cpp
index 88eb003..360ae8c 100644
--- a/source/SoundStretch/main.cpp
+++ b/source/SoundStretch/main.cpp
@@ -108,7 +108,6 @@ static void openFiles(WavInFile **inFile, WavOutFile **outFile, const RunParamet
}
-
// Sets the 'SoundTouch' object up according to input file sound format &
// command line parameters
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
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
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[])
{
WavInFile *inFile;
diff --git a/source/SoundTouch/AAFilter.cpp b/source/SoundTouch/AAFilter.cpp
index c7af576..76a3da6 100644
--- a/source/SoundTouch/AAFilter.cpp
+++ b/source/SoundTouch/AAFilter.cpp
@@ -68,7 +68,6 @@ using namespace soundtouch;
#define _DEBUG_SAVE_AAFIR_COEFFS(x, y)
#endif
-
/*****************************************************************************
*
* Implementation of the class 'AAFilter'
@@ -83,14 +82,12 @@ AAFilter::AAFilter(uint len)
}
-
AAFilter::~AAFilter()
{
delete pFIR;
}
-
// Sets new anti-alias filter cut-off edge frequency, scaled to
// sampling frequency (nyquist frequency = 0.5).
// 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
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
void AAFilter::calculateCoeffs()
{
@@ -170,12 +165,10 @@ void AAFilter::calculateCoeffs()
for (i = 0; i < length; i ++)
{
temp = work[i] * scaleCoeff;
-//#if SOUNDTOUCH_INTEGER_SAMPLES
// scale & round to nearest integer
temp += (temp >= 0) ? 0.5 : -0.5;
// ensure no overfloods
assert(temp >= -32768 && temp <= 32767);
-//#endif
coeffs[i] = (SAMPLETYPE)temp;
}
diff --git a/source/SoundTouch/FIFOSampleBuffer.cpp b/source/SoundTouch/FIFOSampleBuffer.cpp
index 706e869..8341163 100644
--- a/source/SoundTouch/FIFOSampleBuffer.cpp
+++ b/source/SoundTouch/FIFOSampleBuffer.cpp
@@ -265,4 +265,3 @@ uint FIFOSampleBuffer::adjustAmountOfSamples(uint numSamples)
}
return samplesInBuffer;
}
-
diff --git a/source/SoundTouch/FIRFilter.cpp b/source/SoundTouch/FIRFilter.cpp
index e41cce9..218e50e 100644
--- a/source/SoundTouch/FIRFilter.cpp
+++ b/source/SoundTouch/FIRFilter.cpp
@@ -68,6 +68,7 @@ FIRFilter::~FIRFilter()
delete[] filterCoeffs;
}
+
// Usual C-version of the filter routine for stereo sound
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
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.
//
// 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
// depending on if we've a MMX-capable CPU available or not.
void * FIRFilter::operator new(size_t s)
diff --git a/source/SoundTouch/PeakFinder.cpp b/source/SoundTouch/PeakFinder.cpp
index 8896b14..258571a 100644
--- a/source/SoundTouch/PeakFinder.cpp
+++ b/source/SoundTouch/PeakFinder.cpp
@@ -57,7 +57,7 @@ int PeakFinder::findTop(const float *data, int peakpos) const
refvalue = data[peakpos];
- // seek within ±10 points
+ // seek within �10 points
start = peakpos - 10;
if (start < minPos) start = minPos;
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
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)
{
@@ -258,7 +256,7 @@ double PeakFinder::detectPeak(const float *data, int aminPos, int amaxPos)
// accept harmonic peak if
// (a) it is found
- // (b) is within ±4% of the expected harmonic interval
+ // (b) is within �4% of the expected harmonic interval
// (c) has at least half x-corr value of the max. peak
double diff = harmonic * peaktmp / highPeak;
diff --git a/source/SoundTouch/RateTransposer.cpp b/source/SoundTouch/RateTransposer.cpp
index 3cf5e1d..2efaf04 100644
--- a/source/SoundTouch/RateTransposer.cpp
+++ b/source/SoundTouch/RateTransposer.cpp
@@ -64,7 +64,6 @@ RateTransposer::RateTransposer() : FIFOProcessor(&outputBuffer)
}
-
RateTransposer::~RateTransposer()
{
delete pAAFilter;
@@ -72,7 +71,6 @@ RateTransposer::~RateTransposer()
}
-
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
void RateTransposer::enableAAFilter(bool newMode)
{
@@ -96,7 +94,6 @@ AAFilter *RateTransposer::getAAFilter()
}
-
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
// iRate, larger faster iRates.
void RateTransposer::setRate(double newRate)
diff --git a/source/SoundTouch/RateTransposer.h b/source/SoundTouch/RateTransposer.h
index cee4a58..52b7441 100644
--- a/source/SoundTouch/RateTransposer.h
+++ b/source/SoundTouch/RateTransposer.h
@@ -125,21 +125,9 @@ public:
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
FIFOSamplePipe *getOutput() { return &outputBuffer; };
- /// Returns the store buffer object
-// FIFOSamplePipe *getStore() { return &storeBuffer; };
-
/// Return anti-alias filter object
AAFilter *getAAFilter();
diff --git a/source/SoundTouch/SoundTouch.cpp b/source/SoundTouch/SoundTouch.cpp
index 06bdd56..1618884 100644
--- a/source/SoundTouch/SoundTouch.cpp
+++ b/source/SoundTouch/SoundTouch.cpp
@@ -111,7 +111,6 @@ SoundTouch::SoundTouch()
}
-
SoundTouch::~SoundTouch()
{
delete pRateTransposer;
@@ -119,7 +118,6 @@ SoundTouch::~SoundTouch()
}
-
/// Get SoundTouch library version string
const char *SoundTouch::getVersionString()
{
@@ -156,7 +154,6 @@ void SoundTouch::setRate(double newRate)
}
-
// Sets new rate control value as a difference in percents compared
// to the original rate (-50 .. +100 %)
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
// represent slower tempo, larger faster tempo.
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
// to the original tempo (-50 .. +100 %)
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
// represent lower pitches, larger values higher pitch.
void SoundTouch::setPitch(double newPitch)
@@ -196,7 +190,6 @@ void SoundTouch::setPitch(double newPitch)
}
-
// Sets pitch change in octaves compared to the original pitch
// (-1.00 .. +1.00)
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
// (-12 .. +12)
void SoundTouch::setPitchSemiTones(int newPitch)
@@ -215,7 +207,6 @@ void SoundTouch::setPitchSemiTones(int newPitch)
}
-
void SoundTouch::setPitchSemiTones(double newPitch)
{
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");
}
- // 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
// processing setting
samplesExpectedOut += (double)nSamples / ((double)rate * (double)tempo);
@@ -365,7 +340,6 @@ void SoundTouch::flush()
delete[] buff;
// Clear input buffers
- // pRateTransposer->clearInput();
pTDStretch->clearInput();
// yet leave the output intouched as that's where the
// 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
// buffers.
void SoundTouch::clear()
@@ -514,7 +487,6 @@ void SoundTouch::clear()
}
-
/// Returns number of samples currently unprocessed.
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 buffer and removes them from the sample buffer. If there are less than
/// 'numsample' samples in the buffer, returns all that available.
diff --git a/source/SoundTouch/TDStretch.h b/source/SoundTouch/TDStretch.h
index 44fe8bc..4118f9f 100644
--- a/source/SoundTouch/TDStretch.h
+++ b/source/SoundTouch/TDStretch.h
@@ -157,7 +157,6 @@ protected:
void calcSeqParameters();
void adaptNormalizer();
-
/// Changes the tempo of the given sound samples.
/// Returns amount of samples returned in the "output" buffer.
/// The maximum amount of samples that can be returned at a time is set by
@@ -242,7 +241,6 @@ public:
return seekWindowLength - overlapLength;
}
-
/// return approximate initial input-output latency
int getLatency() const
{
@@ -251,7 +249,6 @@ public:
};
-
// Implementation-specific class declarations:
#ifdef SOUNDTOUCH_ALLOW_MMX
diff --git a/source/SoundTouch/cpu_detect_x86.cpp b/source/SoundTouch/cpu_detect_x86.cpp
index 84df0cf..b128610 100644
--- a/source/SoundTouch/cpu_detect_x86.cpp
+++ b/source/SoundTouch/cpu_detect_x86.cpp
@@ -68,7 +68,6 @@ void disableExtensions(uint dwDisableMask)
}
-
/// Checks which instruction set extensions are supported by the CPU.
uint detectCPUextensions(void)
{
diff --git a/source/SoundTouch/mmx_optimized.cpp b/source/SoundTouch/mmx_optimized.cpp
index 2947b3d..741ba4f 100644
--- a/source/SoundTouch/mmx_optimized.cpp
+++ b/source/SoundTouch/mmx_optimized.cpp
@@ -217,7 +217,6 @@ void TDStretchMMX::clearCrossCorrState()
}
-
// MMX-optimized version of the function overlapStereo
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
uint FIRFilterMMX::evaluateFilterStereo(short *dest, const short *src, uint numSamples) const
{