Time stretching and pitch shifting.
More...
#include "SuperpoweredTimeStretching.h"
Time stretching and pitch shifting.
One instance allocates around 220 kb memory.
◆ TimeStretching() [1/2]
Superpowered::TimeStretching::TimeStretching |
( |
unsigned int |
samplerate, |
|
|
float |
minimumRate = 0.01f , |
|
|
unsigned char |
sound = 1 |
|
) |
| |
Constructor.
- Parameters
-
samplerate | The initial sample rate in Hz. |
minimumRate | The minimum value of rate. For example: if the rate will never go below 0.5, minimumRate = 0.5 will save significant computing power and memory. Minimum value of this: 0.01. |
sound | Valid values are: 0 (best to save CPU with slightly lower audio quality), 1 (best for DJ apps, modern and "complete" music), 2 (best for instrumental loops and single instruments). |
◆ ~TimeStretching()
Superpowered::TimeStretching::~TimeStretching |
( |
| ) |
|
◆ TimeStretching() [2/2]
Superpowered::TimeStretching::TimeStretching |
( |
const TimeStretching & |
| ) |
|
|
private |
◆ addInput()
void Superpowered::TimeStretching::addInput |
( |
float * |
input, |
|
|
int |
numberOfFrames |
|
) |
| |
Processes audio.
It's never blocking for real-time usage. You can change all properties on any thread, concurrently with process(). Use it in the same thread with the other real-time methods of this class.
- Parameters
-
input | Pointer to floating point numbers. 32-bit interleaved stereo input. |
numberOfFrames | Number of frames to process. |
◆ advancedProcess()
Processes audio.
For advanced uses to:
- Save memory bandwidth (uses no memory copy) for maximum performance.
- Support up to 8 audio channels.
- Provide sub-sample precise positioning. It's never blocking for real-time usage. You can change all properties on any thread, concurrently with process(). Use it in the same thread with the other real-time methods of this class. Do not use this method with addInput() or getOutput().
- Parameters
-
input | The input buffer. It will take ownership on the input. |
◆ getNumberOfInputFramesNeeded()
unsigned int Superpowered::TimeStretching::getNumberOfInputFramesNeeded |
( |
| ) |
|
- Returns
- Returns with how many frames of input should be provided to the time stretcher to produce some output. It's never blocking for real-time usage. Use it in the same thread with the other real-time methods of this class. The result can be 0 if rate is 1 and pitch shift is 0, because in that case the time stretcher is fully "transparent" and any number of input frames will produce some output.
◆ getOutput()
bool Superpowered::TimeStretching::getOutput |
( |
float * |
output, |
|
|
int |
numberOfFrames |
|
) |
| |
Gets the audio output into a buffer.
It's never blocking for real-time usage. You can change all properties on any thread, concurrently with process(). Use it in the same thread with the other real-time methods of this class.
- Returns
- True if it has enough output frames stored and output is successfully written, false otherwise.
- Parameters
-
output | Pointer to floating point numbers. 32-bit interleaved stereo output. |
numberOfFrames | Number of frames to return with. |
◆ getOutputLengthFrames()
unsigned int Superpowered::TimeStretching::getOutputLengthFrames |
( |
| ) |
|
- Returns
- Returns with how many frames of output is available. It's never blocking for real-time usage. Use it in the same thread with the other real-time methods of this class.
◆ operator=()
◆ removeFramesFromInputBuffersEnd()
void Superpowered::TimeStretching::removeFramesFromInputBuffersEnd |
( |
unsigned int |
numberOfFrames | ) |
|
Removes audio from the end of the input buffer.
Can be useful for some looping use-cases for example. It's never blocking for real-time usage. Use it in the same thread with the other real-time methods of this class.
- Parameters
-
numberOfFrames | The number of frames to remove. |
◆ reset()
void Superpowered::TimeStretching::reset |
( |
| ) |
|
Reset all internals, sets the instance as good as new.
Don't call this concurrently with process() and in a real-time thread.
◆ setStereoPairs()
void Superpowered::TimeStretching::setStereoPairs |
( |
unsigned int |
numStereoPairs | ) |
|
This class can handle one stereo audio channel pair by default (left+right).
Maybe you need more if you load some music with 4 channels, then less if you load a regular stereo track. Don't call this concurrently with process() and in a real-time thread.
- Parameters
-
numStereoPairs | The number of stereo audio channel pairs. Valid values: one (stereo) to four (8 channels). |
◆ internals
stretchInternals* Superpowered::TimeStretching::internals |
|
private |
◆ outputList
◆ pitchShiftCents
int Superpowered::TimeStretching::pitchShiftCents |
Pitch shift cents, limited from -2400 (two octaves down) to 2400 (two octaves up).
Examples: 0 (no pitch shift), -100 (one note down), 300 (3 notes up). When the value if a multiply of 100 and is >= -1200 and <= 1200, changing the pitch shift needs only a few CPU clock cycles. Any change in pitchShiftCents involves significant momentary CPU load otherwise.
◆ rate
float Superpowered::TimeStretching::rate |
Time stretching rate (tempo). 1 means no time stretching. Maximum: 4. Values above 2 or below 0.5 are not recommended on mobile devices with low latency audio due high CPU load and risk of audio dropouts.
◆ samplerate
unsigned int Superpowered::TimeStretching::samplerate |
The documentation for this class was generated from the following file:
- latest/Superpowered/SuperpoweredTimeStretching.h