tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
tracktion::engine::TimeStretcher Class Reference

Handles time/pitch stretching using various supported libraries. More...

#include "tracktion_TimeStretch.h"

Classes

struct  ElastiqueProOptions
 A set of options that can be used in conjunction with the elastiquePro Mode to fine tune the algorithm. More...
 
struct  Stretcher
 

Public Types

enum  Mode {
  disabled , elastiqueTransient , elastiqueTonal , soundtouchNormal ,
  soundtouchBetter , melodyne , elastiquePro , elastiqueEfficient ,
  elastiqueMobile , elastiqueMonophonic , rubberbandMelodic , rubberbandPercussive ,
  elastiqueDirectPro , elastiqueDirectEfficient , elastiqueDirectMobile , defaultMode
}
 Holds the various algorithms to which can be used (if enabled). More...
 

Public Member Functions

 TimeStretcher ()
 Creates an TimeStretcher using the default mode.
 
 ~TimeStretcher ()
 Destructor.
 
void initialise (double sourceSampleRate, int samplesPerBlock, int numChannels, Mode, ElastiqueProOptions, bool realtime)
 Initialises the TimeStretcher ready to perform timestretching.
 
bool isInitialised () const
 Returns true if this has been fully initialised.
 
void reset ()
 Resets the TimeStretcher ready for a new set of audio data, maintains mode, speed and pitch ratios.
 
bool setSpeedAndPitch (float speedRatio, float semitones)
 Sets the timestretch speed ratio and semitones pitch shift.
 
int getMaxFramesNeeded () const
 Returns the maximum number of frames that will ever be returned by getFramesNeeded.
 
int getFramesNeeded () const
 Returns the expected number of frames required to generate some output.
 
int processData (const float *const *inChannels, int numSamples, float *const *outChannels)
 Processes some input frames and fills some output frames with the applied speed ratio and pitch shift.
 
int processData (AudioFifo &inFifo, int numSamples, AudioFifo &outFifo)
 Processes some input frames and fills some output frames from a pair of AudioFifos, useful for real-time use.
 
int flush (float *const *outChannels)
 Flushes the end of the stream when input data is exhausted but there is still output data available.
 

Static Public Member Functions

static Mode checkModeIsAvailable (Mode)
 Checks if the given mode is available for use.
 
static juce::StringArray getPossibleModes (Engine &, bool excludeMelodyne)
 Returns the names of the availabel Modes.
 
static Mode getModeFromName (Engine &, const juce::String &name)
 Returns the Mode for a given name.
 
static juce::String getNameOfMode (Mode)
 Returns the name of a given Mode for display purposes.
 
static bool isMelodyne (Mode)
 Returns true if the given Mode is a Melodyne mode.
 
static bool canProcessFor (Mode)
 Checks that the given Mode is a valid mode and not disabled.
 

Detailed Description

Handles time/pitch stretching using various supported libraries.

Currently supported libraries are SoundTouch, RubberBand and Elastique. These libraries may require additional module config options to enable and fall under their own licence terms so make sure to check those before distributing any code.

Definition at line 22 of file tracktion_TimeStretch.h.

Member Enumeration Documentation

◆ Mode

Holds the various algorithms to which can be used (if enabled).

Enumerator
disabled 

No algorithm enabled.

elastiqueTransient 

Defunct, don't use.

elastiqueTonal 

Defunct, don't use.

soundtouchNormal 

SoundTouch normal quality, lower CPU use.

soundtouchBetter 

SoundTouch better quality, higher CPU use.

melodyne 

Melodyne, only used for clip timestretching.

elastiquePro 

Elastique Pro good all round (.

See also
ElastiqueProOptions).
elastiqueEfficient 

Elastique lower quality and lower CPU usage.

elastiqueMobile 

Elastique lower quality and lower CPU usage, optimised for mobile.

elastiqueMonophonic 

Elastique which can sound better for monophonic sounds.

rubberbandMelodic 

RubberBand tailored to melodic sounds prioritising pitch accuracy.

rubberbandPercussive 

RubberBand tailored to percussive sounds prioritising transient accuracy.

elastiqueDirectPro 

Elastique Direct Pro good all round (.

See also
ElastiqueProOptions).
elastiqueDirectEfficient 

Elastique Direct lower quality and lower CPU usage.

elastiqueDirectMobile 

Elastique Direct lower quality and lower CPU usage, optimised for mobile.

defaultMode 

Default mode.

Definition at line 34 of file tracktion_TimeStretch.h.

Constructor & Destructor Documentation

◆ TimeStretcher()

tracktion::engine::TimeStretcher::TimeStretcher ( )

Creates an TimeStretcher using the default mode.

Definition at line 807 of file tracktion_TimeStretch.cpp.

◆ ~TimeStretcher()

tracktion::engine::TimeStretcher::~TimeStretcher ( )

Destructor.

Definition at line 808 of file tracktion_TimeStretch.cpp.

Member Function Documentation

◆ canProcessFor()

bool tracktion::engine::TimeStretcher::canProcessFor ( Mode  mode)
static

Checks that the given Mode is a valid mode and not disabled.

Definition at line 1057 of file tracktion_TimeStretch.cpp.

◆ checkModeIsAvailable()

TimeStretcher::Mode tracktion::engine::TimeStretcher::checkModeIsAvailable ( Mode  m)
static

Checks if the given mode is available for use.

Definition at line 823 of file tracktion_TimeStretch.cpp.

◆ flush()

int tracktion::engine::TimeStretcher::flush ( float *const *  outChannels)

Flushes the end of the stream when input data is exhausted but there is still output data available.

Once you have called this, you can no longer call processData.

Parameters
outChannelsThe destination for non-interleaved output samples. This should be as big as samplesPerBlock passed to the constructor but it may not fill the whole buffer. In cases where less than samplesPerBlock is returned, you should query getFramesNeeded and call this method again, incrementing destination buffers as required.
Returns
The number of frames read and hence written to outChannels

Definition at line 1119 of file tracktion_TimeStretch.cpp.

◆ getFramesNeeded()

int tracktion::engine::TimeStretcher::getFramesNeeded ( ) const

Returns the expected number of frames required to generate some output.

This should be queried each block and the returned number of frames be passes to processData.

Definition at line 1076 of file tracktion_TimeStretch.cpp.

◆ getMaxFramesNeeded()

int tracktion::engine::TimeStretcher::getMaxFramesNeeded ( ) const

Returns the maximum number of frames that will ever be returned by getFramesNeeded.

This can be used to size FIFOs for real-time use accordingly.

Definition at line 1084 of file tracktion_TimeStretch.cpp.

◆ getModeFromName()

TimeStretcher::Mode tracktion::engine::TimeStretcher::getModeFromName ( Engine e,
const juce::String name 
)
static

Returns the Mode for a given name.

See also
getPossibleModes.

Definition at line 908 of file tracktion_TimeStretch.cpp.

◆ getNameOfMode()

juce::String tracktion::engine::TimeStretcher::getNameOfMode ( Mode  mode)
static

Returns the name of a given Mode for display purposes.

Definition at line 938 of file tracktion_TimeStretch.cpp.

◆ getPossibleModes()

juce::StringArray tracktion::engine::TimeStretcher::getPossibleModes ( Engine e,
bool  excludeMelodyne 
)
static

Returns the names of the availabel Modes.

Definition at line 874 of file tracktion_TimeStretch.cpp.

◆ initialise()

void tracktion::engine::TimeStretcher::initialise ( double  sourceSampleRate,
int  samplesPerBlock,
int  numChannels,
Mode  mode,
ElastiqueProOptions  options,
bool  realtime 
)

Initialises the TimeStretcher ready to perform timestretching.

This must be called at least once before calling the processData methods.

Parameters
sourceSampleRateThe sample rate this will be processed at
samplesPerBlockThe expected number of samples per process block
numChannelsThe number of channels to process
ModeThe Mode to enable
ElastiqueProOptionsThe Elastique options to use, ignored in non-ElastiquePro modes
realtimeIndicates this is for real-time or offline use

Definition at line 978 of file tracktion_TimeStretch.cpp.

◆ isInitialised()

bool tracktion::engine::TimeStretcher::isInitialised ( ) const

Returns true if this has been fully initialised.

Definition at line 973 of file tracktion_TimeStretch.cpp.

◆ isMelodyne()

bool tracktion::engine::TimeStretcher::isMelodyne ( Mode  mode)
static

Returns true if the given Mode is a Melodyne mode.

Definition at line 963 of file tracktion_TimeStretch.cpp.

◆ processData() [1/2]

int tracktion::engine::TimeStretcher::processData ( AudioFifo inFifo,
int  numSamples,
AudioFifo outFifo 
)

Processes some input frames and fills some output frames from a pair of AudioFifos, useful for real-time use.

Parameters
inFifoThe input sample data to read from
numSamplesThe number of input frames to read from inFifo. In inFifo must have this number of frames ready
outFifoThe destination for output samples. This should have at lest samplesPerBlock free.
Returns
The number of frames read and hence written to outFifo

Definition at line 1100 of file tracktion_TimeStretch.cpp.

◆ processData() [2/2]

int tracktion::engine::TimeStretcher::processData ( const float *const *  inChannels,
int  numSamples,
float *const *  outChannels 
)

Processes some input frames and fills some output frames with the applied speed ratio and pitch shift.

Parameters
inChannelsThe input sample data in non-interleaved format
numSamplesThe number of input frames to read from inChannels
outChannelsThe destination for non-interleaved output samples. This should be as big as samplesPerBlock passed to the constructor but it may not fill the whole buffer. In cases where less than samplesPerBlock is returned, you should query getFramesNeeded and call this method again, incrementing destination buffers as required.
Returns
The number of frames read and hence written to outChannels

Definition at line 1092 of file tracktion_TimeStretch.cpp.

◆ reset()

void tracktion::engine::TimeStretcher::reset ( )

Resets the TimeStretcher ready for a new set of audio data, maintains mode, speed and pitch ratios.

Definition at line 1062 of file tracktion_TimeStretch.cpp.

◆ setSpeedAndPitch()

bool tracktion::engine::TimeStretcher::setSpeedAndPitch ( float  speedRatio,
float  semitones 
)

Sets the timestretch speed ratio and semitones pitch shift.

Parameters
speedRatioThe ratio for timestretched speed. 1 = no stretching, 2 = half as fast, 0.5 = twice as fast etc.
semitonesThe number of semitones to adjust the pitch by 0 = not shift, 12 = up one oct, -12 = down one oct etc.

Definition at line 1068 of file tracktion_TimeStretch.cpp.


The documentation for this class was generated from the following files: