Add initial bits for Qt6 support
[carla.git] / source / includes / vst3sdk / pluginterfaces / vst / ivstaudioprocessor.h
blobf2dd5e7d641962b6c829d06165fd22e75590bd33
1 //------------------------------------------------------------------------
2 // Project : VST SDK
3 //
4 // Category : Interfaces
5 // Filename : pluginterfaces/vst/ivstaudioprocessor.h
6 // Created by : Steinberg, 10/2005
7 // Description : VST Audio Processing Interfaces
8 //
9 //-----------------------------------------------------------------------------
10 // This file is part of a Steinberg SDK. It is subject to the license terms
11 // in the LICENSE file found in the top-level directory of this distribution
12 // and at www.steinberg.net/sdklicenses.
13 // No part of the SDK, including this file, may be copied, modified, propagated,
14 // or distributed except according to the terms contained in the LICENSE file.
15 //-----------------------------------------------------------------------------
17 #pragma once
19 #include "ivstcomponent.h"
20 #include "vstspeaker.h"
22 //------------------------------------------------------------------------
23 #include "pluginterfaces/base/falignpush.h"
24 //------------------------------------------------------------------------
26 //------------------------------------------------------------------------
27 /** Class Category Name for Audio Processor Component */
28 //------------------------------------------------------------------------
29 #ifndef kVstAudioEffectClass
30 #define kVstAudioEffectClass "Audio Module Class"
31 #endif
33 //------------------------------------------------------------------------
34 namespace Steinberg {
35 namespace Vst {
37 class IEventList;
38 class IParameterChanges;
39 struct ProcessContext;
41 //------------------------------------------------------------------------
42 /** Component Types used as subCategories in PClassInfo2 */
43 namespace PlugType
45 /**
46 \defgroup plugType Plug-in Type used for subCategories */
47 /*@{*/
48 //------------------------------------------------------------------------
49 const CString kFxAnalyzer = "Fx|Analyzer"; ///< Scope, FFT-Display, Loudness Processing...
50 const CString kFxDelay = "Fx|Delay"; ///< Delay, Multi-tap Delay, Ping-Pong Delay...
51 const CString kFxDistortion = "Fx|Distortion"; ///< Amp Simulator, Sub-Harmonic, SoftClipper...
52 const CString kFxDynamics = "Fx|Dynamics"; ///< Compressor, Expander, Gate, Limiter, Maximizer, Tape Simulator, EnvelopeShaper...
53 const CString kFxEQ = "Fx|EQ"; ///< Equalization, Graphical EQ...
54 const CString kFxFilter = "Fx|Filter"; ///< WahWah, ToneBooster, Specific Filter,...
55 const CString kFx = "Fx"; ///< others type (not categorized)
56 const CString kFxInstrument = "Fx|Instrument"; ///< Fx which could be loaded as Instrument too
57 const CString kFxInstrumentExternal = "Fx|Instrument|External"; ///< Fx which could be loaded as Instrument too and is external (wrapped Hardware)
58 const CString kFxSpatial = "Fx|Spatial"; ///< MonoToStereo, StereoEnhancer,...
59 const CString kFxGenerator = "Fx|Generator"; ///< Tone Generator, Noise Generator...
60 const CString kFxMastering = "Fx|Mastering"; ///< Dither, Noise Shaping,...
61 const CString kFxModulation = "Fx|Modulation"; ///< Phaser, Flanger, Chorus, Tremolo, Vibrato, AutoPan, Rotary, Cloner...
62 const CString kFxPitchShift = "Fx|Pitch Shift"; ///< Pitch Processing, Pitch Correction, Vocal Tuning...
63 const CString kFxRestoration = "Fx|Restoration"; ///< Denoiser, Declicker,...
64 const CString kFxReverb = "Fx|Reverb"; ///< Reverberation, Room Simulation, Convolution Reverb...
65 const CString kFxSurround = "Fx|Surround"; ///< dedicated to surround processing: LFE Splitter, Bass Manager...
66 const CString kFxTools = "Fx|Tools"; ///< Volume, Mixer, Tuner...
67 const CString kFxNetwork = "Fx|Network"; ///< using Network
69 const CString kInstrument = "Instrument"; ///< Effect used as instrument (sound generator), not as insert
70 const CString kInstrumentDrum = "Instrument|Drum"; ///< Instrument for Drum sounds
71 const CString kInstrumentExternal = "Instrument|External";///< External Instrument (wrapped Hardware)
72 const CString kInstrumentPiano = "Instrument|Piano"; ///< Instrument for Piano sounds
73 const CString kInstrumentSampler = "Instrument|Sampler"; ///< Instrument based on Samples
74 const CString kInstrumentSynth = "Instrument|Synth"; ///< Instrument based on Synthesis
75 const CString kInstrumentSynthSampler = "Instrument|Synth|Sampler"; ///< Instrument based on Synthesis and Samples
77 const CString kSpatial = "Spatial"; ///< used for SurroundPanner
78 const CString kSpatialFx = "Spatial|Fx"; ///< used for SurroundPanner and as insert effect
79 const CString kOnlyRealTime = "OnlyRT"; ///< indicates that it supports only realtime process call, no processing faster than realtime
80 const CString kOnlyOfflineProcess = "OnlyOfflineProcess"; ///< used for plug-in offline processing (will not work as normal insert plug-in)
81 const CString kOnlyARA = "OnlyARA"; ///< used for plug-ins that require ARA to operate (will not work as normal insert plug-in)
83 const CString kNoOfflineProcess = "NoOfflineProcess"; ///< will be NOT used for plug-in offline processing (will work as normal insert plug-in)
84 const CString kUpDownMix = "Up-Downmix"; ///< used for Mixconverter/Up-Mixer/Down-Mixer
85 const CString kAnalyzer = "Analyzer"; ///< Meter, Scope, FFT-Display, not selectable as insert plug-in
86 const CString kAmbisonics = "Ambisonics"; ///< used for Ambisonics channel (FX or Panner/Mixconverter/Up-Mixer/Down-Mixer when combined with other category)
88 const CString kMono = "Mono"; ///< used for Mono only plug-in [optional]
89 const CString kStereo = "Stereo"; ///< used for Stereo only plug-in [optional]
90 const CString kSurround = "Surround"; ///< used for Surround only plug-in [optional]
92 //------------------------------------------------------------------------
93 /*@}*/
96 //------------------------------------------------------------------------
97 /** Component Flags used as classFlags in PClassInfo2 */
98 enum ComponentFlags
100 //------------------------------------------------------------------------
101 kDistributable = 1 << 0, ///< Component can be run on remote computer
102 kSimpleModeSupported = 1 << 1 ///< Component supports simple IO mode (or works in simple mode anyway) see \ref vst3IoMode
103 //------------------------------------------------------------------------
106 //------------------------------------------------------------------------
107 /** Symbolic sample size.
108 \see ProcessSetup, ProcessData
110 enum SymbolicSampleSizes
112 kSample32, ///< 32-bit precision
113 kSample64 ///< 64-bit precision
116 //------------------------------------------------------------------------
117 /** Processing mode informs the plug-in about the context and at which frequency the process call is called.
118 VST3 defines 3 modes:
119 - kRealtime: each process call is called at a realtime frequency (defined by [numSamples of ProcessData] / samplerate).
120 The plug-in should always try to process as fast as possible in order to let enough time slice to other plug-ins.
121 - kPrefetch: each process call could be called at a variable frequency (jitter, slower / faster than realtime),
122 the plug-in should process at the same quality level than realtime, plug-in must not slow down to realtime
123 (e.g. disk streaming)!
124 The host should avoid to process in kPrefetch mode such sampler based plug-in.
125 - kOffline: each process call could be faster than realtime or slower, higher quality than realtime could be used.
126 plug-ins using disk streaming should be sure that they have enough time in the process call for streaming,
127 if needed by slowing down to realtime or slower.
129 Note about Process Modes switching:
130 - Switching between kRealtime and kPrefetch process modes are done in realtime thread without need of calling
131 IAudioProcessor::setupProcessing, the plug-in should check in process call the member processMode of ProcessData
132 in order to know in which mode it is processed.
133 - Switching between kRealtime (or kPrefetch) and kOffline requires that the host calls IAudioProcessor::setupProcessing
134 in order to inform the plug-in about this mode change.
136 \see ProcessSetup, ProcessData
138 enum ProcessModes
140 kRealtime, ///< realtime processing
141 kPrefetch, ///< prefetch processing
142 kOffline ///< offline processing
145 //------------------------------------------------------------------------
146 /** kNoTail
148 * to be returned by getTailSamples when no tail is wanted
149 \see IAudioProcessor::getTailSamples
151 static const uint32 kNoTail = 0;
153 //------------------------------------------------------------------------
154 /** kInfiniteTail
156 * to be returned by getTailSamples when infinite tail is wanted
157 \see IAudioProcessor::getTailSamples
159 static const uint32 kInfiniteTail = kMaxInt32u;
161 //------------------------------------------------------------------------
162 /** Audio processing setup.
163 \see IAudioProcessor::setupProcessing
165 struct ProcessSetup
167 //------------------------------------------------------------------------
168 int32 processMode; ///< \ref ProcessModes
169 int32 symbolicSampleSize; ///< \ref SymbolicSampleSizes
170 int32 maxSamplesPerBlock; ///< maximum number of samples per audio block
171 SampleRate sampleRate; ///< sample rate
172 //------------------------------------------------------------------------
175 //------------------------------------------------------------------------
176 /** Processing buffers of an audio bus.
177 This structure contains the processing buffer for each channel of an audio bus.
178 - The number of channels (numChannels) must always match the current bus arrangement.
179 It could be set to value '0' when the host wants to flush the parameters (when the plug-in is not processed).
180 - The size of the channel buffer array must always match the number of channels. So the host
181 must always supply an array for the channel buffers, regardless if the
182 bus is active or not. However, if an audio bus is currently inactive, the actual sample
183 buffer addresses are safe to be null.
184 - The silence flag is set when every sample of the according buffer has the value '0'. It is
185 intended to be used as help for optimizations allowing a plug-in to reduce processing activities.
186 But even if this flag is set for a channel, the channel buffers must still point to valid memory!
187 This flag is optional. A host is free to support it or not.
189 \see ProcessData
191 struct AudioBusBuffers
193 AudioBusBuffers () : numChannels (0), silenceFlags (0), channelBuffers64 (nullptr) {}
195 //------------------------------------------------------------------------
196 int32 numChannels; ///< number of audio channels in bus
197 uint64 silenceFlags; ///< Bitset of silence state per channel
198 union
200 Sample32** channelBuffers32; ///< sample buffers to process with 32-bit precision
201 Sample64** channelBuffers64; ///< sample buffers to process with 64-bit precision
203 //------------------------------------------------------------------------
206 //------------------------------------------------------------------------
207 /** Any data needed in audio processing.
208 The host prepares AudioBusBuffers for each input/output bus,
209 regardless of the bus activation state. Bus buffer indices always match
210 with bus indices used in IComponent::getBusInfo of media type kAudio.
211 \see AudioBusBuffers, IParameterChanges, IEventList, ProcessContext, IProcessContextRequirements
213 struct ProcessData
215 ProcessData ()
216 : processMode (0)
217 , symbolicSampleSize (kSample32)
218 , numSamples (0)
219 , numInputs (0)
220 , numOutputs (0)
221 , inputs (nullptr)
222 , outputs (nullptr)
223 , inputParameterChanges (nullptr)
224 , outputParameterChanges (nullptr)
225 , inputEvents (nullptr)
226 , outputEvents (nullptr)
227 , processContext (nullptr)
231 //------------------------------------------------------------------------
232 int32 processMode; ///< processing mode - value of \ref ProcessModes
233 int32 symbolicSampleSize; ///< sample size - value of \ref SymbolicSampleSizes
234 int32 numSamples; ///< number of samples to process
235 int32 numInputs; ///< number of audio input busses
236 int32 numOutputs; ///< number of audio output busses
237 AudioBusBuffers* inputs; ///< buffers of input busses
238 AudioBusBuffers* outputs; ///< buffers of output busses
240 IParameterChanges* inputParameterChanges; ///< incoming parameter changes for this block
241 IParameterChanges* outputParameterChanges; ///< outgoing parameter changes for this block (optional)
242 IEventList* inputEvents; ///< incoming events for this block (optional)
243 IEventList* outputEvents; ///< outgoing events for this block (optional)
244 ProcessContext* processContext; ///< processing context (optional, but most welcome)
245 //------------------------------------------------------------------------
248 //------------------------------------------------------------------------
249 /** Audio processing interface: Vst::IAudioProcessor
250 \ingroup vstIPlug vst300
251 - [plug imp]
252 - [extends IComponent]
253 - [released: 3.0.0]
254 - [mandatory]
256 This interface must always be supported by audio processing plug-ins.
258 class IAudioProcessor : public FUnknown
260 public:
261 //------------------------------------------------------------------------
262 /** Try to set (host => plug-in) a wanted arrangement for inputs and outputs.
263 The host should always deliver the same number of input and output busses than the plug-in
264 needs (see \ref IComponent::getBusCount). The plug-in has 3 possibilities to react on this
265 setBusArrangements call:\n
266 1. The plug-in accepts these arrangements, then it should modify, if needed, its busses to match
267 these new arrangements (later on asked by the host with IComponent::getBusInfo () or
268 IAudioProcessor::getBusArrangement ()) and then should return kResultTrue.\n
269 2. The plug-in does not accept or support these requested arrangements for all
270 inputs/outputs or just for some or only one bus, but the plug-in can try to adapt its current
271 arrangements according to the requested ones (requested arrangements for kMain busses should be
272 handled with more priority than the ones for kAux busses), then it should modify its busses arrangements
273 and should return kResultFalse.\n
274 3. Same than the point 2 above the plug-in does not support these requested arrangements
275 but the plug-in cannot find corresponding arrangements, the plug-in could keep its current arrangement
276 or fall back to a default arrangement by modifying its busses arrangements and should return kResultFalse.\n
277 \param inputs pointer to an array of /ref SpeakerArrangement
278 \param numIns number of /ref SpeakerArrangement in inputs array
279 \param outputs pointer to an array of /ref SpeakerArrangement
280 \param numOuts number of /ref SpeakerArrangement in outputs array
281 Returns kResultTrue when Arrangements is supported and is the current one, else returns kResultFalse. */
282 virtual tresult PLUGIN_API setBusArrangements (SpeakerArrangement* inputs, int32 numIns,
283 SpeakerArrangement* outputs, int32 numOuts) = 0;
285 /** Gets the bus arrangement for a given direction (input/output) and index.
286 Note: IComponent::getBusInfo () and IAudioProcessor::getBusArrangement () should be always return the same
287 information about the busses arrangements. */
288 virtual tresult PLUGIN_API getBusArrangement (BusDirection dir, int32 index, SpeakerArrangement& arr) = 0;
290 /** Asks if a given sample size is supported see \ref SymbolicSampleSizes. */
291 virtual tresult PLUGIN_API canProcessSampleSize (int32 symbolicSampleSize) = 0;
293 /** Gets the current Latency in samples.
294 The returned value defines the group delay or the latency of the plug-in. For example, if the plug-in internally needs
295 to look in advance (like compressors) 512 samples then this plug-in should report 512 as latency.
296 If during the use of the plug-in this latency change, the plug-in has to inform the host by
297 using IComponentHandler::restartComponent (kLatencyChanged), this could lead to audio playback interruption
298 because the host has to recompute its internal mixer delay compensation.
299 Note that for player live recording this latency should be zero or small. */
300 virtual uint32 PLUGIN_API getLatencySamples () = 0;
302 /** Called in disable state (setActive not called with true) before setProcessing is called and processing will begin. */
303 virtual tresult PLUGIN_API setupProcessing (ProcessSetup& setup) = 0;
305 /** Informs the plug-in about the processing state. This will be called before any process calls
306 start with true and after with false.
307 Note that setProcessing (false) may be called after setProcessing (true) without any process
308 calls.
309 Note this function could be called in the UI or in Processing Thread, thats why the plug-in
310 should only light operation (no memory allocation or big setup reconfiguration),
311 this could be used to reset some buffers (like Delay line or Reverb).
312 The host has to be sure that it is called only when the plug-in is enable (setActive (true)
313 was called). */
314 virtual tresult PLUGIN_API setProcessing (TBool state) = 0;
316 /** The Process call, where all information (parameter changes, event, audio buffer) are passed. */
317 virtual tresult PLUGIN_API process (ProcessData& data) = 0;
319 /** Gets tail size in samples. For example, if the plug-in is a Reverb plug-in and it knows that
320 the maximum length of the Reverb is 2sec, then it has to return in getTailSamples()
321 (in VST2 it was getGetTailSize ()): 2*sampleRate.
322 This information could be used by host for offline processing, process optimization and
323 downmix (avoiding signal cut (clicks)).
324 It should return:
325 - kNoTail when no tail
326 - x * sampleRate when x Sec tail.
327 - kInfiniteTail when infinite tail. */
328 virtual uint32 PLUGIN_API getTailSamples () = 0;
330 //------------------------------------------------------------------------
331 static const FUID iid;
334 DECLARE_CLASS_IID (IAudioProcessor, 0x42043F99, 0xB7DA453C, 0xA569E79D, 0x9AAEC33D)
336 //------------------------------------------------------------------------
337 /** Extended IAudioProcessor interface for a component: Vst::IAudioPresentationLatency
338 \ingroup vstIPlug vst310
339 - [plug imp]
340 - [extends IAudioProcessor]
341 - [released: 3.1.0]
342 - [optional]
344 Inform the plug-in about how long from the moment of generation/acquiring (from file or from Input)
345 it will take for its input to arrive, and how long it will take for its output to be presented (to output or to speaker).
347 Note for Input Presentation Latency: when reading from file, the first plug-in will have an input presentation latency set to zero.
348 When monitoring audio input from an audio device, the initial input latency is the input latency of the audio device itself.
350 Note for Output Presentation Latency: when writing to a file, the last plug-in will have an output presentation latency set to zero.
351 When the output of this plug-in is connected to an audio device, the initial output latency is the output
352 latency of the audio device itself.
354 A value of zero either means no latency or an unknown latency.
356 Each plug-in adding a latency (returning a none zero value for IAudioProcessor::getLatencySamples) will modify the input
357 presentation latency of the next plug-ins in the mixer routing graph and will modify the output presentation latency
358 of the previous plug-ins.
361 \image html "iaudiopresentationlatency_usage.png"
363 \see IAudioProcessor
364 \see IComponent
366 class IAudioPresentationLatency : public FUnknown
368 public:
369 //------------------------------------------------------------------------
370 /** Informs the plug-in about the Audio Presentation Latency in samples for a given direction (kInput/kOutput) and bus index. */
371 virtual tresult PLUGIN_API setAudioPresentationLatencySamples (BusDirection dir, int32 busIndex, uint32 latencyInSamples) = 0;
373 //------------------------------------------------------------------------
374 static const FUID iid;
377 DECLARE_CLASS_IID (IAudioPresentationLatency, 0x309ECE78, 0xEB7D4fae, 0x8B2225D9, 0x09FD08B6)
379 //------------------------------------------------------------------------
380 /** Extended IAudioProcessor interface for a component: Vst::IProcessContextRequirements
381 \ingroup vstIPlug vst370
382 - [plug imp]
383 - [extends IAudioProcessor]
384 - [released: 3.7.0]
385 - [mandatory]
387 To get accurate process context information (Vst::ProcessContext), it is now required to implement this interface and
388 return the desired bit mask of flags which your audio effect needs. If you do not implement this
389 interface, you may not get any information at all of the process function\x13.
391 The host asks for this information once between initialize and setActive. It cannot be changed afterwards.
393 This gives the host the opportunity to better optimize the audio process graph when it knows which
394 plug-ins need which information.
396 Plug-Ins built with an earlier SDK version (< 3.7) will still get the old information, but the information
397 may not be as accurate as when using this interface.
399 class IProcessContextRequirements : public FUnknown
401 public:
402 enum Flags
404 kNeedSystemTime = 1 << 0, // kSystemTimeValid
405 kNeedContinousTimeSamples = 1 << 1, // kContTimeValid
406 kNeedProjectTimeMusic = 1 << 2, // kProjectTimeMusicValid
407 kNeedBarPositionMusic = 1 << 3, // kBarPositionValid
408 kNeedCycleMusic = 1 << 4, // kCycleValid
409 kNeedSamplesToNextClock = 1 << 5, // kClockValid
410 kNeedTempo = 1 << 6, // kTempoValid
411 kNeedTimeSignature = 1 << 7, // kTimeSigValid
412 kNeedChord = 1 << 8, // kChordValid
413 kNeedFrameRate = 1 << 9, // kSmpteValid
414 kNeedTransportState = 1 << 10, // kPlaying, kCycleActive, kRecording
416 virtual uint32 PLUGIN_API getProcessContextRequirements () = 0;
417 //------------------------------------------------------------------------
418 static const FUID iid;
421 DECLARE_CLASS_IID (IProcessContextRequirements, 0x2A654303, 0xEF764E3D, 0x95B5FE83, 0x730EF6D0)
423 //------------------------------------------------------------------------
424 } // namespace Vst
425 } // namespace Steinberg
427 //------------------------------------------------------------------------
428 #include "pluginterfaces/base/falignpop.h"
429 //------------------------------------------------------------------------