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

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_TimeStretch.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
23{
24public:
25 //==============================================================================
28
31
32 //==============================================================================
34 enum Mode
35 {
52 #if TRACKTION_ENABLE_TIMESTRETCH_ELASTIQUE
54 #elif TRACKTION_ENABLE_TIMESTRETCH_RUBBERBAND
56 #elif TRACKTION_ENABLE_TIMESTRETCH_SOUNDTOUCH
58 #else
60 #endif
61 };
62
63 //==============================================================================
68 {
72 ElastiqueProOptions (const juce::String& string);
73
75 juce::String toString() const;
76
78 bool operator== (const ElastiqueProOptions&) const;
80 bool operator!= (const ElastiqueProOptions&) const;
81
82 bool midSideStereo = false;
83 bool syncTimeStrPitchShft = false;
84 bool preserveFormants = false;
85 int envelopeOrder = 64;
86 };
87
88 //==============================================================================
91
93 static juce::StringArray getPossibleModes (Engine&, bool excludeMelodyne);
94
96 static Mode getModeFromName (Engine&, const juce::String& name);
97
100
102 static bool isMelodyne (Mode);
103
105 static bool canProcessFor (Mode);
106
107 //==============================================================================
117 void initialise (double sourceSampleRate, int samplesPerBlock,
118 int numChannels, Mode, ElastiqueProOptions, bool realtime);
119
121 bool isInitialised() const;
122
124 void reset();
125
130 bool setSpeedAndPitch (float speedRatio, float semitones);
131
135 int getMaxFramesNeeded() const;
136
140 int getFramesNeeded() const;
141
151 int processData (const float* const* inChannels, int numSamples, float* const* outChannels);
152
159 int processData (AudioFifo& inFifo, int numSamples, AudioFifo& outFifo);
160
169 int flush (float* const* outChannels);
170
172 struct Stretcher;
173
174private:
176 int samplesPerBlockRequested = 0;
177
179};
180
181}} // namespace tracktion { inline namespace engine
182
183namespace juce
184{
185 template <>
186 struct VariantConverter<tracktion::engine::TimeStretcher::Mode>
187 {
188 static tracktion::engine::TimeStretcher::Mode fromVar (const var& v) { return (tracktion::engine::TimeStretcher::Mode) static_cast<int> (v); }
189 static var toVar (tracktion::engine::TimeStretcher::Mode v) { return static_cast<int> (v); }
190 };
191
192 template <>
193 struct VariantConverter<tracktion::engine::TimeStretcher::ElastiqueProOptions>
194 {
196 static var toVar (const tracktion::engine::TimeStretcher::ElastiqueProOptions& v) { return v.toString(); }
197 };
198}
const String & toString() const noexcept
The Engine is the central class for all tracktion sessions.
Handles time/pitch stretching using various supported libraries.
void initialise(double sourceSampleRate, int samplesPerBlock, int numChannels, Mode, ElastiqueProOptions, bool realtime)
Initialises the TimeStretcher ready to perform timestretching.
int getFramesNeeded() const
Returns the expected number of frames required to generate some output.
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.
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.
static juce::String getNameOfMode(Mode)
Returns the name of a given Mode for display purposes.
int getMaxFramesNeeded() const
Returns the maximum number of frames that will ever be returned by getFramesNeeded.
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...
static Mode getModeFromName(Engine &, const juce::String &name)
Returns the Mode for a given name.
int flush(float *const *outChannels)
Flushes the end of the stream when input data is exhausted but there is still output data available.
TimeStretcher()
Creates an TimeStretcher using the default mode.
static Mode checkModeIsAvailable(Mode)
Checks if the given mode is available for use.
bool setSpeedAndPitch(float speedRatio, float semitones)
Sets the timestretch speed ratio and semitones pitch shift.
Mode
Holds the various algorithms to which can be used (if enabled).
@ elastiqueDirectPro
Elastique Direct Pro good all round (.
@ rubberbandMelodic
RubberBand tailored to melodic sounds prioritising pitch accuracy.
@ soundtouchNormal
SoundTouch normal quality, lower CPU use.
@ elastiquePro
Elastique Pro good all round (.
@ elastiqueMonophonic
Elastique which can sound better for monophonic sounds.
@ elastiqueDirectEfficient
Elastique Direct lower quality and lower CPU usage.
@ elastiqueDirectMobile
Elastique Direct lower quality and lower CPU usage, optimised for mobile.
@ rubberbandPercussive
RubberBand tailored to percussive sounds prioritising transient accuracy.
@ melodyne
Melodyne, only used for clip timestretching.
@ elastiqueEfficient
Elastique lower quality and lower CPU usage.
@ elastiqueMobile
Elastique lower quality and lower CPU usage, optimised for mobile.
@ soundtouchBetter
SoundTouch better quality, higher CPU use.
static juce::StringArray getPossibleModes(Engine &, bool excludeMelodyne)
Returns the names of the availabel Modes.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
A set of options that can be used in conjunction with the elastiquePro Mode to fine tune the algorith...
int envelopeOrder
Sets a spectral envelope shift factor.
bool operator!=(const ElastiqueProOptions &) const
Compare these options with another set.
juce::String toString() const
Save the current options as a string.
bool midSideStereo
Optomise algorthim for mid/side channel layouts.
bool operator==(const ElastiqueProOptions &) const
Compare these options with another set.
bool syncTimeStrPitchShft
Synchronises timestretch and pitchshifting.
ElastiqueProOptions()=default
Create a default set of options.