|
tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications
« « « Anklang Documentation |
Wraps a TimeStretcher but keeps a larger internal input and output buffer and uses a background thread to try and process frames, reducing CPU cost on real-time threads. More...
#include "tracktion_ReadAheadTimeStretcher.h"
Public Member Functions | |
| ReadAheadTimeStretcher (int numBlocksToReadAhead) | |
| Creates a ReadAheadTimeStretcher that will attempt to process the desired number of blocks on a background thread. | |
| ~ReadAheadTimeStretcher () | |
| Destructor. | |
| void | initialise (double sourceSampleRate, int samplesPerBlock, int numChannels, TimeStretcher::Mode, TimeStretcher::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 | getFramesRecomended () const |
| Returns the number of frames that should be pushed to ensure the background thread has ample to work with. | |
| bool | requiresMoreFrames () const |
| Returns true if more frames are required to be pushed in order for a pop operation to succeed. | |
| int | getFreeSpace () const |
| Returns the number of samples that can be pushed to the input, ready to be processed. | |
| int | pushData (const float *const *inChannels, int numSamples) |
| Pushes a number of samples to the instance ready to be time-stretched. | |
| int | getNumReady () const |
| Returns the number of samples ready in the output buffer which can be retrieved without processing the time-stretch. | |
| int | popData (float *const *outChannels, int numSamples) |
| Retrieves some samples from the output buffer. | |
| int | flush (float *const *outChannels) |
| Flushes the end of the stream when input data is exhausted but there is still output data available. | |
Wraps a TimeStretcher but keeps a larger internal input and output buffer and uses a background thread to try and process frames, reducing CPU cost on real-time threads.
Definition at line 21 of file tracktion_ReadAheadTimeStretcher.h.
| engine::ReadAheadTimeStretcher::ReadAheadTimeStretcher | ( | int | numBlocksToReadAhead | ) |
Creates a ReadAheadTimeStretcher that will attempt to process the desired number of blocks on a background thread.
The number of blocks is a multiple of that passed to the initalise call.
Definition at line 98 of file tracktion_ReadAheadTimeStretcher.cpp.
| engine::ReadAheadTimeStretcher::~ReadAheadTimeStretcher | ( | ) |
Destructor.
Definition at line 103 of file tracktion_ReadAheadTimeStretcher.cpp.
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. |
Definition at line 224 of file tracktion_ReadAheadTimeStretcher.cpp.
| int engine::ReadAheadTimeStretcher::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 passed to pushData.
Definition at line 165 of file tracktion_ReadAheadTimeStretcher.cpp.
| int engine::ReadAheadTimeStretcher::getFramesRecomended | ( | ) | const |
Returns the number of frames that should be pushed to ensure the background thread has ample to work with.
This also prioritises a fast startup where possible after a reset()
Definition at line 171 of file tracktion_ReadAheadTimeStretcher.cpp.
| int engine::ReadAheadTimeStretcher::getFreeSpace | ( | ) | const |
Returns the number of samples that can be pushed to the input, ready to be processed.
Definition at line 188 of file tracktion_ReadAheadTimeStretcher.cpp.
| int engine::ReadAheadTimeStretcher::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 159 of file tracktion_ReadAheadTimeStretcher.cpp.
| int engine::ReadAheadTimeStretcher::getNumReady | ( | ) | const |
Returns the number of samples ready in the output buffer which can be retrieved without processing the time-stretch.
Definition at line 203 of file tracktion_ReadAheadTimeStretcher.cpp.
| void engine::ReadAheadTimeStretcher::initialise | ( | double | sourceSampleRate, |
| int | samplesPerBlock, | ||
| int | numChannels, | ||
| TimeStretcher::Mode | mode, | ||
| TimeStretcher::ElastiqueProOptions | proOpts, | ||
| 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 |
Definition at line 108 of file tracktion_ReadAheadTimeStretcher.cpp.
| bool engine::ReadAheadTimeStretcher::isInitialised | ( | ) | const |
Returns true if this has been fully initialised.
Definition at line 129 of file tracktion_ReadAheadTimeStretcher.cpp.
Retrieves some samples from the output buffer.
N.B. If there aren't enough samples already processed this will do the processing so its cost can vary.
Definition at line 208 of file tracktion_ReadAheadTimeStretcher.cpp.
Pushes a number of samples to the instance ready to be time-stretched.
N.B. This doesn't actually do any processing so should be quick.
Definition at line 193 of file tracktion_ReadAheadTimeStretcher.cpp.
| bool engine::ReadAheadTimeStretcher::requiresMoreFrames | ( | ) | const |
Returns true if more frames are required to be pushed in order for a pop operation to succeed.
Definition at line 183 of file tracktion_ReadAheadTimeStretcher.cpp.
| void engine::ReadAheadTimeStretcher::reset | ( | ) |
Resets the TimeStretcher ready for a new set of audio data, maintains mode, speed and pitch ratios.
Definition at line 134 of file tracktion_ReadAheadTimeStretcher.cpp.
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. |
Definition at line 148 of file tracktion_ReadAheadTimeStretcher.cpp.