MythTV  0.26-pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
soundtouch::TDStretch Class Reference

Class that does the time-stretch (tempo change) effect for the processed sound. More...

#include <TDStretch.h>

Inheritance diagram for soundtouch::TDStretch:
FIFOProcessor FIFOSamplePipe soundtouch::TDStretchMMX soundtouch::TDStretchSSE2 soundtouch::TDStretchSSE3

List of all members.

Public Member Functions

 TDStretch ()
virtual ~TDStretch ()
voidoperator new (size_t s)
 Operator 'new' is overloaded so that it automatically creates a suitable instance depending on if we've a MMX/SSE/etc-capable CPU available or not.
FIFOSamplePipegetOutput ()
 Returns the output buffer object.
FIFOSamplePipegetInput ()
 Returns the input buffer object.
void setTempo (float newTempo)
 Sets new target tempo.
virtual void clear ()
 Returns nonzero if there aren't any samples available for outputting.
void clearInput ()
 Clears the input buffer.
void setChannels (uint numChannels)
 Sets the number of channels, 1 = mono, 2 = stereo.
void enableQuickSeek (BOOL enable)
 Enables/disables the quick position seeking algorithm.
BOOL isQuickSeekEnabled () const
 Returns nonzero if the quick seeking algorithm is enabled.
void setParameters (uint sampleRate, uint sequenceMS=DEFAULT_SEQUENCE_MS, uint seekwindowMS=DEFAULT_SEEKWINDOW_MS, uint overlapMS=DEFAULT_OVERLAP_MS)
 Sets routine control parameters.
void getParameters (uint *pSampleRate, uint *pSequenceMs, uint *pSeekWindowMs, uint *pOverlapMs)
 Get routine control parameters, see setParameters() function.
virtual void putSamples (const SAMPLETYPE *samples, uint numSamples)
 Adds 'numsamples' pcs of samples from the 'samples' memory position into the input of the object.

Static Public Member Functions

static TDStretchnewInstance ()
 Use this function instead of "new" operator to create a new instance of this class.

Protected Member Functions

void acceptNewOverlapLength (uint newOverlapLength)
 Set new overlap length parameter & reallocate RefMidBuffer if necessary.
virtual void clearCrossCorrState ()
 clear cross correlation routine state if necessary
void calculateOverlapLength (uint overlapMs)
 Calculates overlap period length in samples.
virtual LONG_SAMPLETYPE calcCrossCorrMulti (const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare) const
virtual LONG_SAMPLETYPE calcCrossCorrStereo (const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare) const
virtual LONG_SAMPLETYPE calcCrossCorrMono (const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare) const
virtual uint seekBestOverlapPositionMulti (const SAMPLETYPE *refPos)
virtual uint seekBestOverlapPositionMultiQuick (const SAMPLETYPE *refPos)
virtual uint seekBestOverlapPositionStereo (const SAMPLETYPE *refPos)
virtual uint seekBestOverlapPositionStereoQuick (const SAMPLETYPE *refPos)
virtual uint seekBestOverlapPositionMono (const SAMPLETYPE *refPos)
virtual uint seekBestOverlapPositionMonoQuick (const SAMPLETYPE *refPos)
uint seekBestOverlapPosition (const SAMPLETYPE *refPos)
virtual void overlapMulti (SAMPLETYPE *output, const SAMPLETYPE *input) const
virtual void overlapStereo (SAMPLETYPE *output, const SAMPLETYPE *input) const
virtual void overlapMono (SAMPLETYPE *output, const SAMPLETYPE *input) const
void clearMidBuffer ()
void overlap (SAMPLETYPE *output, const SAMPLETYPE *input, uint ovlPos) const
void precalcCorrReference ()
void precalcCorrReferenceMono ()
void precalcCorrReferenceStereo ()
void processNominalTempo ()
void processSamples ()
 Changes the tempo of the given sound samples.

Protected Attributes

uint channels
uint sampleReq
float tempo
SAMPLETYPEpMidBuffer
SAMPLETYPEpRefMidBuffer
SAMPLETYPEpRefMidBufferUnaligned
uint midBufferLength
uint overlapLength
uint overlapDividerBits
uint slopingDivider
uint seekLength
uint seekWindowLength
uint maxOffset
float nominalSkip
float skipFract
FIFOSampleBuffer outputBuffer
FIFOSampleBuffer inputBuffer
BOOL bQuickseek
BOOL bMidBufferDirty
uint sampleRate
uint sequenceMs
uint seekWindowMs
uint overlapMs

Detailed Description

Class that does the time-stretch (tempo change) effect for the processed sound.

Definition at line 97 of file TDStretch.h.


Constructor & Destructor Documentation

Definition at line 91 of file TDStretch.cpp.

Referenced by newInstance().

TDStretch::~TDStretch ( ) [virtual]

Definition at line 110 of file TDStretch.cpp.


Member Function Documentation

void TDStretch::acceptNewOverlapLength ( uint  newOverlapLength) [protected]

Set new overlap length parameter & reallocate RefMidBuffer if necessary.

Definition at line 764 of file TDStretch.cpp.

Referenced by calculateOverlapLength().

void TDStretch::clearCrossCorrState ( ) [protected, virtual]
void TDStretch::calculateOverlapLength ( uint  overlapMs) [protected]

Calculates overlap period length in samples.

Integer version rounds overlap length to closest power of 2 for a divide scaling operation.

Definition at line 939 of file TDStretch.cpp.

Referenced by setParameters().

double TDStretch::calcCrossCorrMulti ( const SAMPLETYPE mixingPos,
const SAMPLETYPE compare 
) const [protected, virtual]

Reimplemented in soundtouch::TDStretchMMX.

Definition at line 988 of file TDStretch.cpp.

Referenced by seekBestOverlapPositionMulti(), and seekBestOverlapPositionMultiQuick().

double TDStretch::calcCrossCorrStereo ( const SAMPLETYPE mixingPos,
const SAMPLETYPE compare 
) const [protected, virtual]

Reimplemented in soundtouch::TDStretchMMX.

Definition at line 972 of file TDStretch.cpp.

Referenced by seekBestOverlapPositionStereo(), and seekBestOverlapPositionStereoQuick().

double TDStretch::calcCrossCorrMono ( const SAMPLETYPE mixingPos,
const SAMPLETYPE compare 
) const [protected, virtual]

Definition at line 957 of file TDStretch.cpp.

Referenced by seekBestOverlapPositionMono(), and seekBestOverlapPositionMonoQuick().

uint TDStretch::seekBestOverlapPositionMulti ( const SAMPLETYPE refPos) [protected, virtual]

Definition at line 322 of file TDStretch.cpp.

Referenced by seekBestOverlapPosition().

uint TDStretch::seekBestOverlapPositionMultiQuick ( const SAMPLETYPE refPos) [protected, virtual]

Definition at line 362 of file TDStretch.cpp.

Referenced by seekBestOverlapPosition().

uint TDStretch::seekBestOverlapPositionStereo ( const SAMPLETYPE refPos) [protected, virtual]

Definition at line 418 of file TDStretch.cpp.

Referenced by seekBestOverlapPosition().

uint TDStretch::seekBestOverlapPositionStereoQuick ( const SAMPLETYPE refPos) [protected, virtual]

Definition at line 458 of file TDStretch.cpp.

Referenced by seekBestOverlapPosition().

uint TDStretch::seekBestOverlapPositionMono ( const SAMPLETYPE refPos) [protected, virtual]

Definition at line 515 of file TDStretch.cpp.

Referenced by seekBestOverlapPosition().

uint TDStretch::seekBestOverlapPositionMonoQuick ( const SAMPLETYPE refPos) [protected, virtual]

Definition at line 558 of file TDStretch.cpp.

Referenced by seekBestOverlapPosition().

uint TDStretch::seekBestOverlapPosition ( const SAMPLETYPE refPos) [protected]

Definition at line 245 of file TDStretch.cpp.

Referenced by processSamples().

void TDStretch::overlapMulti ( SAMPLETYPE output,
const SAMPLETYPE input 
) const [protected, virtual]

Definition at line 917 of file TDStretch.cpp.

Referenced by overlap().

void TDStretch::overlapStereo ( SAMPLETYPE output,
const SAMPLETYPE input 
) const [protected, virtual]

Reimplemented in soundtouch::TDStretchMMX.

Definition at line 899 of file TDStretch.cpp.

Referenced by overlap().

void TDStretch::overlapMono ( SAMPLETYPE output,
const SAMPLETYPE input 
) const [protected, virtual]

Definition at line 189 of file TDStretch.cpp.

Referenced by overlap().

Definition at line 202 of file TDStretch.cpp.

Referenced by acceptNewOverlapLength(), clear(), clearInput(), and processNominalTempo().

void TDStretch::overlap ( SAMPLETYPE output,
const SAMPLETYPE input,
uint  ovlPos 
) const [inline, protected]

Definition at line 293 of file TDStretch.cpp.

Referenced by processNominalTempo(), and processSamples().

Definition at line 882 of file TDStretch.cpp.

Referenced by seekBestOverlapPositionMono(), and seekBestOverlapPositionMonoQuick().

Definition at line 653 of file TDStretch.cpp.

Referenced by processSamples().

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 the 'set_returnBuffer_size' function.

Definition at line 684 of file TDStretch.cpp.

Referenced by putSamples().

void * TDStretch::operator new ( size_t  s)

Operator 'new' is overloaded so that it automatically creates a suitable instance depending on if we've a MMX/SSE/etc-capable CPU available or not.

Definition at line 791 of file TDStretch.cpp.

Use this function instead of "new" operator to create a new instance of this class.

This function automatically chooses a correct feature set depending on if the CPU supports MMX/SSE/etc extensions.

Definition at line 799 of file TDStretch.cpp.

Referenced by soundtouch::SoundTouch::SoundTouch().

Returns the output buffer object.

Definition at line 184 of file TDStretch.h.

Referenced by soundtouch::SoundTouch::calcEffectiveRateAndTempo().

Returns the input buffer object.

Definition at line 187 of file TDStretch.h.

Referenced by soundtouch::SoundTouch::calcEffectiveRateAndTempo(), and soundtouch::SoundTouch::numUnprocessedSamples().

void TDStretch::setTempo ( float  newTempo)

Sets new target tempo.

Normal tempo = 'SCALE', smaller values represent slower tempo, larger faster tempo.

Definition at line 617 of file TDStretch.cpp.

Referenced by soundtouch::SoundTouch::calcEffectiveRateAndTempo(), setParameters(), and TDStretch().

void TDStretch::clear ( void  ) [virtual]

Returns nonzero if there aren't any samples available for outputting.

Implements FIFOSamplePipe.

Definition at line 220 of file TDStretch.cpp.

Referenced by soundtouch::SoundTouch::clear().

Clears the input buffer.

Definition at line 212 of file TDStretch.cpp.

Referenced by soundtouch::SoundTouch::flush().

void TDStretch::setChannels ( uint  numChannels)

Sets the number of channels, 1 = mono, 2 = stereo.

Definition at line 636 of file TDStretch.cpp.

Referenced by soundtouch::SoundTouch::setChannels().

Enables/disables the quick position seeking algorithm.

Zero to disable, nonzero to enable

Definition at line 231 of file TDStretch.cpp.

Referenced by soundtouch::SoundTouch::setSetting().

Returns nonzero if the quick seeking algorithm is enabled.

Definition at line 238 of file TDStretch.cpp.

Referenced by soundtouch::SoundTouch::getSetting().

void TDStretch::setParameters ( uint  sampleRate,
uint  sequenceMS = DEFAULT_SEQUENCE_MS,
uint  seekwindowMS = DEFAULT_SEEKWINDOW_MS,
uint  overlapMS = DEFAULT_OVERLAP_MS 
)

Sets routine control parameters.

These control are certain time constants defining how the sound is stretched to the desired duration. 'sampleRate' = sample rate of the sound 'sequenceMS' = one processing sequence length in milliseconds 'seekwindowMS' = seeking window length for scanning the best overlapping position 'overlapMS' = overlapping length

Parameters:
sampleRateSamplerate of sound being processed (Hz)
sequenceMSSingle processing sequence length (ms)
seekwindowMSOffset seeking window length (ms)
overlapMSSequence overlapping length (ms)

Definition at line 139 of file TDStretch.cpp.

Referenced by soundtouch::SoundTouch::setSampleRate(), soundtouch::SoundTouch::setSetting(), and TDStretch().

void TDStretch::getParameters ( uint pSampleRate,
uint pSequenceMs,
uint pSeekWindowMs,
uint pOverlapMs 
)

Get routine control parameters, see setParameters() function.

Any of the parameters to this function can be NULL, in such case corresponding parameter value isn't returned.

Definition at line 164 of file TDStretch.cpp.

Referenced by soundtouch::SoundTouch::getSetting(), and soundtouch::SoundTouch::setSetting().

void TDStretch::putSamples ( const SAMPLETYPE samples,
uint  numSamples 
) [virtual]

Adds 'numsamples' pcs of samples from the 'samples' memory position into the input of the object.

Parameters:
samplesInput sample data
numSamplesNumber of samples in 'samples' so that one sample contains both channels if stereo

Implements FIFOSamplePipe.

Definition at line 753 of file TDStretch.cpp.

Referenced by soundtouch::SoundTouch::putSamples().


Member Data Documentation

Definition at line 101 of file TDStretch.h.

Referenced by processSamples(), and setTempo().

float soundtouch::TDStretch::tempo [protected]

Definition at line 102 of file TDStretch.h.

Referenced by processNominalTempo(), processSamples(), setParameters(), and setTempo().

Definition at line 106 of file TDStretch.h.

Referenced by acceptNewOverlapLength(), TDStretch(), and ~TDStretch().

Definition at line 107 of file TDStretch.h.

Referenced by acceptNewOverlapLength(), clearMidBuffer(), TDStretch(), and ~TDStretch().

Definition at line 112 of file TDStretch.h.

Referenced by processSamples(), setParameters(), and setTempo().

Definition at line 113 of file TDStretch.h.

Referenced by setParameters(), and setTempo().

Definition at line 114 of file TDStretch.h.

Referenced by processSamples(), and setTempo().

Definition at line 115 of file TDStretch.h.

Referenced by processSamples(), and setTempo().

Definition at line 116 of file TDStretch.h.

Referenced by clear(), getOutput(), processNominalTempo(), processSamples(), and setChannels().

Definition at line 121 of file TDStretch.h.

Referenced by calculateOverlapLength(), getParameters(), and setParameters().

Definition at line 122 of file TDStretch.h.

Referenced by getParameters(), and setParameters().

Definition at line 123 of file TDStretch.h.

Referenced by getParameters(), and setParameters().

Definition at line 124 of file TDStretch.h.

Referenced by getParameters(), and setParameters().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends