TracktionEngine
|
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... | |
Public Types | |
enum | Mode { disabled = 0 , elastiqueTransient = 1 , elastiqueTonal = 2 , soundtouchNormal = 3 , soundtouchBetter = 4 , melodyne = 5 , elastiquePro = 6 , elastiqueEfficient = 7 , elastiqueMobile = 8 , elastiqueMonophonic = 9 , rubberbandMelodic = 10 , rubberbandPercussive = 11 , elastiqueDirectPro = 12 , elastiqueDirectEfficient = 13 , elastiqueDirectMobile = 14 , defaultMode = disabled } |
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. | |
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.
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 (.
|
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 (.
|
elastiqueDirectEfficient | Elastique Direct lower quality and lower CPU usage. |
elastiqueDirectMobile | Elastique Direct lower quality and lower CPU usage, optimised for mobile. |
defaultMode | Default mode. |
tracktion::engine::TimeStretcher::TimeStretcher | ( | ) |
Creates an TimeStretcher using the default mode.
tracktion::engine::TimeStretcher::~TimeStretcher | ( | ) |
Destructor.
Checks if the given mode is available for use.
|
static |
Returns the names of the availabel Modes.
|
static |
Returns the Mode for a given name.
|
static |
Returns the name of a given Mode for display purposes.
|
static |
Returns true if the given Mode is a Melodyne mode.
|
static |
Checks that the given Mode is a valid mode and not disabled.
void tracktion::engine::TimeStretcher::initialise | ( | double | sourceSampleRate, |
int | samplesPerBlock, | ||
int | numChannels, | ||
Mode | , | ||
ElastiqueProOptions | , | ||
bool | realtime | ||
) |
Initialises the TimeStretcher ready to perform timestretching.
This must be called at least once before calling the processData methods.
sourceSampleRate | The sample rate this will be processed at |
samplesPerBlock | The expected number of samples per process block |
numChannels | The number of channels to process |
Mode | The Mode to enable |
ElastiqueProOptions | The Elastique options to use, ignored in non-ElastiquePro modes |
realtime | Indicates this is for real-time or offline use |
bool tracktion::engine::TimeStretcher::isInitialised | ( | ) | const |
Returns true if this has been fully initialised.
void tracktion::engine::TimeStretcher::reset | ( | ) |
Resets the TimeStretcher ready for a new set of audio data, maintains mode, speed and pitch ratios.
bool tracktion::engine::TimeStretcher::setSpeedAndPitch | ( | float | speedRatio, |
float | semitones | ||
) |
Sets the timestretch speed ratio and semitones pitch shift.
speedRatio | The ratio for timestretched speed. 1 = no stretching, 2 = half as fast, 0.5 = twice as fast etc. |
semitones | The number of semitones to adjust the pitch by 0 = not shift, 12 = up one oct, -12 = down one oct etc. |
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.
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.
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.
inChannels | The input sample data in non-interleaved format |
numSamples | The number of input frames to read from inChannels |
outChannels | The 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. |
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.
inFifo | The input sample data to read from |
numSamples | The number of input frames to read from inFifo. In inFifo must have this number of frames ready |
outFifo | The destination for output samples. This should have at lest samplesPerBlock free. |
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.
outChannels | The 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. |