Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refs #1104. SoundTouch resync.
Syncs to 1.31.

I didn't take the MMX changes because our MMX code is faster and more versatile.
I also didn't take the SSE & the windows specific changes, we don't use the floating point sample code, and don't have a functioning windows port to test the changes with.



git-svn-id: http://svn.mythtv.org/svn/trunk@9996 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
daniel-kristjansson committed May 23, 2006
1 parent 0738eb9 commit 14a7fbf
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 53 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmythsoundtouch/AAFilter.cpp
Expand Up @@ -7,8 +7,8 @@
/// transposing the sample rate with interpolation.
///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai @ iki.fi
/// SoundTouch WWW: http://www.iki.fi/oparviai/soundtouch
/// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch
///
////////////////////////////////////////////////////////////////////////////////
//
Expand Down
10 changes: 4 additions & 6 deletions mythtv/libs/libmythsoundtouch/BPMDetect.h
Expand Up @@ -21,8 +21,8 @@
/// function, calculates it's precise location and converts this reading to bpm's.
///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai @ iki.fi
/// SoundTouch WWW: http://www.iki.fi/oparviai/soundtouch
/// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch
///
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -58,6 +58,7 @@
#define _BPMDetect_H_

#include "STTypes.h"
#include "FIFOSampleBuffer.h"

/// Minimum allowed BPM rate. Used to restrict accepted result above a reasonable limit.
#define MIN_BPM 45
Expand All @@ -66,9 +67,6 @@
#define MAX_BPM 230


/// Internal class prototype
class FIFOSampleBuffer;

/// Class for calculating BPM rate for audio data.
class BPMDetect
{
Expand Down Expand Up @@ -105,7 +103,7 @@ class BPMDetect
int windowStart;

/// FIFO-buffer for decimated processing samples.
FIFOSampleBuffer *buffer;
soundtouch::FIFOSampleBuffer *buffer;

/// Initialize the class for processing.
void init(int numChannels, int sampleRate);
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythsoundtouch/FIFOSampleBuffer.cpp
Expand Up @@ -10,8 +10,8 @@
/// whenever necessary.
///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai @ iki.fi
/// SoundTouch WWW: http://www.iki.fi/oparviai/soundtouch
/// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch
///
////////////////////////////////////////////////////////////////////////////////
//
Expand Down
23 changes: 14 additions & 9 deletions mythtv/libs/libmythsoundtouch/FIFOSampleBuffer.h
Expand Up @@ -10,8 +10,8 @@
/// whenever necessary.
///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai @ iki.fi
/// SoundTouch WWW: http://www.iki.fi/oparviai/soundtouch
/// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch
///
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -48,6 +48,9 @@

#include "FIFOSamplePipe.h"

namespace soundtouch
{

/// Sample buffer working in FIFO (first-in-first-out) principle. The class takes
/// care of storage size adjustment and data moving during input/output operations.
///
Expand All @@ -57,11 +60,11 @@ class FIFOSampleBuffer : public FIFOSamplePipe
{
private:
/// Sample buffer.
soundtouch::SAMPLETYPE *buffer;
SAMPLETYPE *buffer;

// Raw unaligned buffer memory. 'buffer' is made aligned by pointing it to first
// 16-byte aligned location of this buffer
soundtouch::SAMPLETYPE *bufferUnaligned;
SAMPLETYPE *bufferUnaligned;

/// Sample buffer size in bytes
uint sizeInBytes;
Expand Down Expand Up @@ -95,7 +98,7 @@ class FIFOSampleBuffer : public FIFOSamplePipe
);

/// destructor
virtual ~FIFOSampleBuffer();
~FIFOSampleBuffer();

/// Returns a pointer to the beginning of the output samples.
/// This function is provided for accessing the output samples directly.
Expand All @@ -104,7 +107,7 @@ class FIFOSampleBuffer : public FIFOSamplePipe
/// When using this function to output samples, also remember to 'remove' the
/// output samples from the buffer by calling the
/// 'receiveSamples(numSamples)' function
virtual soundtouch::SAMPLETYPE *ptrBegin() const;
virtual SAMPLETYPE *ptrBegin() const;

/// Returns a pointer to the end of the used part of the sample buffer (i.e.
/// where the new samples are to be inserted). This function may be used for
Expand All @@ -114,7 +117,7 @@ class FIFOSampleBuffer : public FIFOSamplePipe
/// When using this function as means for inserting new samples, also remember
/// to increase the sample count afterwards, by calling the
/// 'putSamples(numSamples)' function.
soundtouch::SAMPLETYPE *ptrEnd(
SAMPLETYPE *ptrEnd(
uint slackCapacity ///< How much free capacity (in samples) there _at least_
///< should be so that the caller can succesfully insert the
///< desired samples to the buffer. If necessary, the function
Expand All @@ -123,7 +126,7 @@ class FIFOSampleBuffer : public FIFOSamplePipe

/// Adds 'numSamples' pcs of samples from the 'samples' memory position to
/// the sample buffer.
virtual void putSamples(const soundtouch::SAMPLETYPE *samples, ///< Pointer to samples.
virtual void putSamples(const SAMPLETYPE *samples, ///< Pointer to samples.
uint numSamples ///< Number of samples to insert.
);

Expand All @@ -141,7 +144,7 @@ class FIFOSampleBuffer : public FIFOSamplePipe
/// 'numsample' samples in the buffer, returns all that available.
///
/// \return Number of samples returned.
virtual uint receiveSamples(soundtouch::SAMPLETYPE *output, ///< Buffer where to copy output samples.
virtual uint receiveSamples(SAMPLETYPE *output, ///< Buffer where to copy output samples.
uint maxSamples ///< How many samples to receive at max.
);

Expand All @@ -166,4 +169,6 @@ class FIFOSampleBuffer : public FIFOSamplePipe
virtual void clear();
};

}

#endif
25 changes: 12 additions & 13 deletions mythtv/libs/libmythsoundtouch/RateTransposer.cpp
Expand Up @@ -5,8 +5,8 @@
/// alias filtering should be quite adequate for this application)
///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai @ iki.fi
/// SoundTouch WWW: http://www.iki.fi/oparviai/soundtouch
/// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch
///
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -49,23 +49,22 @@
using namespace soundtouch;



/// A linear samplerate transposer class that uses integer arithmetics.
/// for the transposing.
class RateTransposerInteger : public RateTransposer
{
protected:
int iSlopeCount;
uint uRate;
soundtouch::SAMPLETYPE sPrevSampleL, sPrevSampleR;
SAMPLETYPE sPrevSampleL, sPrevSampleR;

virtual void resetRegisters();

virtual uint transposeStereo(soundtouch::SAMPLETYPE *dest,
const soundtouch::SAMPLETYPE *src,
virtual uint transposeStereo(SAMPLETYPE *dest,
const SAMPLETYPE *src,
uint numSamples);
virtual uint transposeMono(soundtouch::SAMPLETYPE *dest,
const soundtouch::SAMPLETYPE *src,
virtual uint transposeMono(SAMPLETYPE *dest,
const SAMPLETYPE *src,
uint numSamples);

public:
Expand All @@ -86,15 +85,15 @@ class RateTransposerFloat : public RateTransposer
protected:
float fSlopeCount;
float fRateStep;
soundtouch::SAMPLETYPE sPrevSampleL, sPrevSampleR;
SAMPLETYPE sPrevSampleL, sPrevSampleR;

virtual void resetRegisters();

virtual uint transposeStereo(soundtouch::SAMPLETYPE *dest,
const soundtouch::SAMPLETYPE *src,
virtual uint transposeStereo(SAMPLETYPE *dest,
const SAMPLETYPE *src,
uint numSamples);
virtual uint transposeMono(soundtouch::SAMPLETYPE *dest,
const soundtouch::SAMPLETYPE *src,
virtual uint transposeMono(SAMPLETYPE *dest,
const SAMPLETYPE *src,
uint numSamples);

public:
Expand Down
50 changes: 39 additions & 11 deletions mythtv/libs/libmythsoundtouch/STTypes.h
Expand Up @@ -3,8 +3,8 @@
/// Common type definitions for SoundTouch audio processing library.
///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai @ iki.fi
/// SoundTouch WWW: http://www.iki.fi/oparviai/soundtouch
/// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch
///
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -45,7 +45,7 @@ typedef unsigned long ulong;
#ifndef _WINDEF_
// if these aren't defined already by Windows headers, define now

typedef unsigned int BOOL;
typedef int BOOL;

#define FALSE 0
#define TRUE 1
Expand All @@ -55,12 +55,31 @@ typedef unsigned long ulong;

namespace soundtouch
{
/// Enable one of the following defines to choose either 16bit integer or
/// 32bit float sample type. If you don't have opinion, using integer samples
/// is generally faster.
#define INTEGER_SAMPLES //< 16bit integer samples
//#define FLOAT_SAMPLES //< 32bit float samples

/// Activate these undef's to overrule the possible sampletype
/// setting inherited from some other header file:
//#undef INTEGER_SAMPLES
//#undef FLOAT_SAMPLES

#if !(INTEGER_SAMPLES || FLOAT_SAMPLES)

/// Choose either 32bit floating point or 16bit integer sampletype
/// by choosing one of the following defines, unless this selection
/// has already been done in some other file.
////
/// Notes:
/// - In Windows environment, choose the sample format with the
/// following defines.
/// - In GNU environment, the floating point samples are used by
/// default, but integer samples can be chosen by giving the
/// following switch to the configure script:
/// ./configure --enable-integer-samples
/// However, if you still prefer to select the sample format here
/// also in GNU environment, then please #undef the INTEGER_SAMPLE
/// and FLOAT_SAMPLE defines first as in comments above.
#define INTEGER_SAMPLES 1 //< 16bit integer samples
//#define FLOAT_SAMPLES 1 //< 32bit float samples

#endif

/// Define this to allow CPU-specific assembler optimizations. Notice that
/// having this enabled on non-x86 platforms doesn't matter; the compiler can
Expand All @@ -71,6 +90,12 @@ namespace soundtouch
#define ALLOW_OPTIMIZATIONS 1


// If defined, allows the SIMD-optimized routines to take minor shortcuts
// for improved performance. Undefine to require faithfully similar SIMD
// calculations as in normal C implementation.
#define ALLOW_NONEXACT_SIMD_OPTIMIZATION 1


#ifdef INTEGER_SAMPLES
// 16bit integer sample type
typedef short SAMPLETYPE;
Expand All @@ -97,11 +122,14 @@ namespace soundtouch
typedef double LONG_SAMPLETYPE;

#ifdef ALLOW_OPTIMIZATIONS
#ifdef WIN32
// Allow 3DNow! and SSE optimizations
#if WIN32
#define ALLOW_3DNOW 1
#endif

#if WIN32 || __MMX__ || MMX
#define ALLOW_SSE 1
#endif // WIN32
#endif
#endif

#endif // INTEGER_SAMPLES
Expand Down
8 changes: 5 additions & 3 deletions mythtv/libs/libmythsoundtouch/SoundTouch.cpp
Expand Up @@ -36,8 +36,8 @@
/// combining the two other controls.
///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai @ iki.fi
/// SoundTouch WWW: http://www.iki.fi/oparviai/soundtouch
/// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch
///
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -298,6 +298,7 @@ void SoundTouch::putSamples(const SAMPLETYPE *samples, uint numSamples)
}

// 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.
Expand All @@ -310,7 +311,8 @@ void SoundTouch::putSamples(const SAMPLETYPE *samples, uint numSamples)
}
pTDStretch->putSamples(samples, numSamples);
}
else if (rate < 1.0f)
*/
else if (rate <= 1.0f)
{
// transpose the rate down, output the transposed sound to tempo changer buffer
assert(output == pTDStretch);
Expand Down
10 changes: 5 additions & 5 deletions mythtv/libs/libmythsoundtouch/SoundTouch.h
Expand Up @@ -36,8 +36,8 @@
/// combining the two other controls.
///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai @ iki.fi
/// SoundTouch WWW: http://www.iki.fi/oparviai/soundtouch
/// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch
///
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -79,10 +79,10 @@ namespace soundtouch
{

/// Soundtouch library version string
#define SOUNDTOUCH_VERSION "1.3.0"
#define SOUNDTOUCH_VERSION "1.3.1"

/// SoundTouch library version id
#define SOUNDTOUCH_VERSION_ID 010300
#define SOUNDTOUCH_VERSION_ID 010301

//
// Available setting IDs for the 'setSetting' & 'get_setting' functions:
Expand Down Expand Up @@ -209,7 +209,7 @@ protected :
/// the input of the object. Notice that sample rate _has_to_ be set before
/// calling this function, otherwise throws a runtime_error exception.
virtual void putSamples(
const soundtouch::SAMPLETYPE *samples, ///< Pointer to sample buffer.
const SAMPLETYPE *samples, ///< Pointer to sample buffer.
uint numSamples ///< Number of samples in buffer. Notice
///< that in case of stereo-sound a single sample
///< contains data for both channels.
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythsoundtouch/cpu_detect_x86_gcc.cpp
Expand Up @@ -7,8 +7,8 @@
/// of this file.
///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai @ iki.fi
/// SoundTouch WWW: http://www.iki.fi/oparviai/soundtouch
/// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch
///
////////////////////////////////////////////////////////////////////////////////
//
Expand Down

0 comments on commit 14a7fbf

Please sign in to comment.