Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ivstaudioprocessor.h 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. //------------------------------------------------------------------------
  2. // Project : VST SDK
  3. // Version : 3.6.7
  4. //
  5. // Category : Interfaces
  6. // Filename : pluginterfaces/vst/ivstaudioprocessor.h
  7. // Created by : Steinberg, 10/2005
  8. // Description : VST Audio Processing Interfaces
  9. //
  10. //-----------------------------------------------------------------------------
  11. // This file is part of a Steinberg SDK. It is subject to the license terms
  12. // in the LICENSE file found in the top-level directory of this distribution
  13. // and at www.steinberg.net/sdklicenses.
  14. // No part of the SDK, including this file, may be copied, modified, propagated,
  15. // or distributed except according to the terms contained in the LICENSE file.
  16. //-----------------------------------------------------------------------------
  17. #pragma once
  18. #include "ivstcomponent.h"
  19. //------------------------------------------------------------------------
  20. #include "pluginterfaces/base/falignpush.h"
  21. //------------------------------------------------------------------------
  22. //------------------------------------------------------------------------
  23. /** Class Category Name for Audio Processor Component */
  24. //------------------------------------------------------------------------
  25. #ifndef kVstAudioEffectClass
  26. #define kVstAudioEffectClass "Audio Module Class"
  27. #endif
  28. //------------------------------------------------------------------------
  29. namespace Steinberg {
  30. namespace Vst {
  31. class IEventList;
  32. class IParameterChanges;
  33. struct ProcessContext;
  34. //------------------------------------------------------------------------
  35. /** Component Types used as subCategories in PClassInfo2 */
  36. //------------------------------------------------------------------------
  37. namespace PlugType
  38. {
  39. /**
  40. \defgroup plugType Plug-in Type used for subCategories */
  41. /*@{*/
  42. //------------------------------------------------------------------------
  43. const CString kFxAnalyzer = "Fx|Analyzer"; ///< Scope, FFT-Display, Loudness Processing...
  44. const CString kFxDelay = "Fx|Delay"; ///< Delay, Multi-tap Delay, Ping-Pong Delay...
  45. const CString kFxDistortion = "Fx|Distortion"; ///< Amp Simulator, Sub-Harmonic, SoftClipper...
  46. const CString kFxDynamics = "Fx|Dynamics"; ///< Compressor, Expander, Gate, Limiter, Maximizer, Tape Simulator, EnvelopeShaper...
  47. const CString kFxEQ = "Fx|EQ"; ///< Equalization, Graphical EQ...
  48. const CString kFxFilter = "Fx|Filter"; ///< WahWah, ToneBooster, Specific Filter,...
  49. const CString kFx = "Fx"; ///< others type (not categorized)
  50. const CString kFxInstrument = "Fx|Instrument"; ///< Fx which could be loaded as Instrument too
  51. const CString kFxInstrumentExternal = "Fx|Instrument|External"; ///< Fx which could be loaded as Instrument too and is external (wrapped Hardware)
  52. const CString kFxSpatial = "Fx|Spatial"; ///< MonoToStereo, StereoEnhancer,...
  53. const CString kFxGenerator = "Fx|Generator"; ///< Tone Generator, Noise Generator...
  54. const CString kFxMastering = "Fx|Mastering"; ///< Dither, Noise Shaping,...
  55. const CString kFxModulation = "Fx|Modulation"; ///< Phaser, Flanger, Chorus, Tremolo, Vibrato, AutoPan, Rotary, Cloner...
  56. const CString kFxPitchShift = "Fx|Pitch Shift"; ///< Pitch Processing, Pitch Correction, Vocal Tuning...
  57. const CString kFxRestoration = "Fx|Restoration"; ///< Denoiser, Declicker,...
  58. const CString kFxReverb = "Fx|Reverb"; ///< Reverberation, Room Simulation, Convolution Reverb...
  59. const CString kFxSurround = "Fx|Surround"; ///< dedicated to surround processing: LFE Splitter, Bass Manager...
  60. const CString kFxTools = "Fx|Tools"; ///< Volume, Mixer, Tuner...
  61. const CString kFxNetwork = "Fx|Network"; ///< using Network
  62. const CString kInstrument = "Instrument"; ///< Effect used as instrument (sound generator), not as insert
  63. const CString kInstrumentDrum = "Instrument|Drum"; ///< Instrument for Drum sounds
  64. const CString kInstrumentSampler = "Instrument|Sampler"; ///< Instrument based on Samples
  65. const CString kInstrumentSynth = "Instrument|Synth"; ///< Instrument based on Synthesis
  66. const CString kInstrumentSynthSampler = "Instrument|Synth|Sampler"; ///< Instrument based on Synthesis and Samples
  67. const CString kInstrumentExternal = "Instrument|External";///< External Instrument (wrapped Hardware)
  68. const CString kSpatial = "Spatial"; ///< used for SurroundPanner
  69. const CString kSpatialFx = "Spatial|Fx"; ///< used for SurroundPanner and as insert effect
  70. const CString kOnlyRealTime = "OnlyRT"; ///< indicates that it supports only realtime process call, no processing faster than realtime
  71. const CString kOnlyOfflineProcess = "OnlyOfflineProcess"; ///< used for Plug-in offline processing (will not work as normal insert Plug-in)
  72. const CString kNoOfflineProcess = "NoOfflineProcess"; ///< will be NOT used for Plug-in offline processing (will work as normal insert Plug-in)
  73. const CString kUpDownMix = "Up-Downmix"; ///< used for Mixconverter/Up-Mixer/Down-Mixer
  74. const CString kAnalyzer = "Analyzer"; ///< Meter, Scope, FFT-Display, not selectable as insert plugin
  75. const CString kMono = "Mono"; ///< used for Mono only Plug-in [optional]
  76. const CString kStereo = "Stereo"; ///< used for Stereo only Plug-in [optional]
  77. const CString kSurround = "Surround"; ///< used for Surround only Plug-in [optional]
  78. //------------------------------------------------------------------------
  79. /*@}*/
  80. }
  81. //------------------------------------------------------------------------
  82. /** Component Flags used as classFlags in PClassInfo2 */
  83. //------------------------------------------------------------------------
  84. enum ComponentFlags
  85. {
  86. //------------------------------------------------------------------------
  87. kDistributable = 1 << 0, ///< Component can be run on remote computer
  88. kSimpleModeSupported = 1 << 1 ///< Component supports simple IO mode (or works in simple mode anyway) see \ref vst3IoMode
  89. //------------------------------------------------------------------------
  90. };
  91. //------------------------------------------------------------------------
  92. /** Symbolic sample size.
  93. \see ProcessSetup, ProcessData */
  94. //------------------------------------------------------------------------
  95. enum SymbolicSampleSizes
  96. {
  97. kSample32, ///< 32-bit precision
  98. kSample64 ///< 64-bit precision
  99. };
  100. //------------------------------------------------------------------------
  101. /** Processing mode informs the Plug-in about the context and at which frequency the process call is called.
  102. VST3 defines 3 modes:
  103. - kRealtime: each process call is called at a realtime frequency (defined by [numSamples of ProcessData] / samplerate).
  104. The Plug-in should always try to process as fast as possible in order to let enough time slice to other Plug-ins.
  105. - kPrefetch: each process call could be called at a variable frequency (jitter, slower / faster than realtime),
  106. the Plug-in should process at the same quality level than realtime, Plug-in must not slow down to realtime
  107. (e.g. disk streaming)!
  108. The host should avoid to process in kPrefetch mode such sampler based Plug-in.
  109. - kOffline: each process call could be faster than realtime or slower, higher quality than realtime could be used.
  110. Plug-ins using disk streaming should be sure that they have enough time in the process call for streaming,
  111. if needed by slowing down to realtime or slower.
  112. .
  113. Note about Process Modes switching:
  114. -Switching between kRealtime and kPrefetch process modes are done in realtime thread without need of calling
  115. IAudioProcessor::setupProcessing, the Plug-in should check in process call the member processMode of ProcessData
  116. in order to know in which mode it is processed.
  117. -Switching between kRealtime (or kPrefetch) and kOffline requires that the host calls IAudioProcessor::setupProcessing
  118. in order to inform the Plug-in about this mode change.
  119. .
  120. \see ProcessSetup, ProcessData */
  121. //------------------------------------------------------------------------
  122. enum ProcessModes
  123. {
  124. kRealtime, ///< realtime processing
  125. kPrefetch, ///< prefetch processing
  126. kOffline ///< offline processing
  127. };
  128. //------------------------------------------------------------------------
  129. /** kNoTail
  130. *
  131. * to be returned by getTailSamples when no tail is wanted
  132. \see IAudioProcessor::getTailSamples */
  133. //------------------------------------------------------------------------
  134. static const uint32 kNoTail = 0;
  135. //------------------------------------------------------------------------
  136. /** kInfiniteTail
  137. *
  138. * to be returned by getTailSamples when infinite tail is wanted
  139. \see IAudioProcessor::getTailSamples */
  140. //------------------------------------------------------------------------
  141. static const uint32 kInfiniteTail = kMaxInt32u;
  142. //------------------------------------------------------------------------
  143. /** Audio processing setup.
  144. \see IAudioProcessor::setupProcessing */
  145. //------------------------------------------------------------------------
  146. struct ProcessSetup
  147. {
  148. //------------------------------------------------------------------------
  149. int32 processMode; ///< \ref ProcessModes
  150. int32 symbolicSampleSize; ///< \ref SymbolicSampleSizes
  151. int32 maxSamplesPerBlock; ///< maximum number of samples per audio block
  152. SampleRate sampleRate; ///< sample rate
  153. //------------------------------------------------------------------------
  154. };
  155. //------------------------------------------------------------------------
  156. /** Processing buffers of an audio bus.
  157. This structure contains the processing buffer for each channel of an audio bus.
  158. - The number of channels (numChannels) must always match the current bus arrangement.
  159. It could be set to value '0' when the host wants to flush the parameters (when the Plug-in is not processed).
  160. - The size of the channel buffer array must always match the number of channels. So the host
  161. must always supply an array for the channel buffers, regardless if the
  162. bus is active or not. However, if an audio bus is currently inactive, the actual sample
  163. buffer addresses are safe to be null.
  164. - The silence flag is set when every sample of the according buffer has the value '0'. It is
  165. intended to be used as help for optimizations allowing a Plug-in to reduce processing activities.
  166. But even if this flag is set for a channel, the channel buffers must still point to valid memory!
  167. This flag is optional. A host is free to support it or not.
  168. .
  169. \see ProcessData */
  170. //------------------------------------------------------------------------
  171. struct AudioBusBuffers
  172. {
  173. AudioBusBuffers () : numChannels (0), silenceFlags (0), channelBuffers64 (0) {}
  174. //------------------------------------------------------------------------
  175. int32 numChannels; ///< number of audio channels in bus
  176. uint64 silenceFlags; ///< Bitset of silence state per channel
  177. union
  178. {
  179. Sample32** channelBuffers32; ///< sample buffers to process with 32-bit precision
  180. Sample64** channelBuffers64; ///< sample buffers to process with 64-bit precision
  181. };
  182. //------------------------------------------------------------------------
  183. };
  184. //------------------------------------------------------------------------
  185. /** Any data needed in audio processing.
  186. The host prepares AudioBusBuffers for each input/output bus,
  187. regardless of the bus activation state. Bus buffer indices always match
  188. with bus indices used in IComponent::getBusInfo of media type kAudio.
  189. \see AudioBusBuffers, IParameterChanges, IEventList, ProcessContext */
  190. //------------------------------------------------------------------------
  191. struct ProcessData
  192. {
  193. ProcessData ()
  194. : processMode (0), symbolicSampleSize (kSample32), numSamples (0), numInputs (0)
  195. , numOutputs (0), inputs (0), outputs (0), inputParameterChanges (0), outputParameterChanges (0)
  196. , inputEvents (0), outputEvents (0), processContext (0) {}
  197. //------------------------------------------------------------------------
  198. int32 processMode; ///< processing mode - value of \ref ProcessModes
  199. int32 symbolicSampleSize; ///< sample size - value of \ref SymbolicSampleSizes
  200. int32 numSamples; ///< number of samples to process
  201. int32 numInputs; ///< number of audio input buses
  202. int32 numOutputs; ///< number of audio output buses
  203. AudioBusBuffers* inputs; ///< buffers of input buses
  204. AudioBusBuffers* outputs; ///< buffers of output buses
  205. IParameterChanges* inputParameterChanges; ///< incoming parameter changes for this block
  206. IParameterChanges* outputParameterChanges; ///< outgoing parameter changes for this block (optional)
  207. IEventList* inputEvents; ///< incoming events for this block (optional)
  208. IEventList* outputEvents; ///< outgoing events for this block (optional)
  209. ProcessContext* processContext; ///< processing context (optional, but most welcome)
  210. //------------------------------------------------------------------------
  211. };
  212. //------------------------------------------------------------------------
  213. /** Audio Processing Interface.
  214. \ingroup vstIPlug vst300
  215. - [plug imp]
  216. - [extends IComponent]
  217. - [released: 3.0.0]
  218. - [mandatory]
  219. This interface must always be supported by audio processing Plug-ins. */
  220. //------------------------------------------------------------------------
  221. class IAudioProcessor: public FUnknown
  222. {
  223. public:
  224. //------------------------------------------------------------------------
  225. /** Try to set (from host) a predefined arrangement for inputs and outputs.
  226. The host should always deliver the same number of input and output buses than the Plug-in needs
  227. (see \ref IComponent::getBusCount).
  228. The Plug-in returns kResultFalse if wanted arrangements are not supported.
  229. If the Plug-in accepts these arrangements, it should modify its buses to match the new arrangements
  230. (asked by the host with IComponent::getInfo () or IAudioProcessor::getBusArrangement ()) and then return kResultTrue.
  231. If the Plug-in does not accept these arrangements, but can adapt its current arrangements (according to the wanted ones),
  232. it should modify its buses arrangements and return kResultFalse. */
  233. virtual tresult PLUGIN_API setBusArrangements (SpeakerArrangement* inputs, int32 numIns,
  234. SpeakerArrangement* outputs, int32 numOuts) = 0;
  235. /** Gets the bus arrangement for a given direction (input/output) and index.
  236. Note: IComponent::getInfo () and IAudioProcessor::getBusArrangement () should be always return the same
  237. information about the buses arrangements. */
  238. virtual tresult PLUGIN_API getBusArrangement (BusDirection dir, int32 index, SpeakerArrangement& arr) = 0;
  239. /** Asks if a given sample size is supported see \ref SymbolicSampleSizes. */
  240. virtual tresult PLUGIN_API canProcessSampleSize (int32 symbolicSampleSize) = 0;
  241. /** Gets the current Latency in samples.
  242. The returned value defines the group delay or the latency of the Plug-in. For example, if the Plug-in internally needs
  243. to look in advance (like compressors) 512 samples then this Plug-in should report 512 as latency.
  244. If during the use of the Plug-in this latency change, the Plug-in has to inform the host by
  245. using IComponentHandler::restartComponent (kLatencyChanged), this could lead to audio playback interruption
  246. because the host has to recompute its internal mixer delay compensation.
  247. Note that for player live recording this latency should be zero or small. */
  248. virtual uint32 PLUGIN_API getLatencySamples () = 0;
  249. /** Called in disable state (not active) before processing will begin. */
  250. virtual tresult PLUGIN_API setupProcessing (ProcessSetup& setup) = 0;
  251. /** Informs the Plug-in about the processing state. This will be called before any process calls start with true and after with false.
  252. Note that setProcessing (false) may be called after setProcessing (true) without any process calls.
  253. In this call the Plug-in should do only light operation (no memory allocation or big setup reconfiguration),
  254. this could be used to reset some buffers (like Delay line or Reverb). */
  255. virtual tresult PLUGIN_API setProcessing (TBool state) = 0;
  256. /** The Process call, where all information (parameter changes, event, audio buffer) are passed. */
  257. virtual tresult PLUGIN_API process (ProcessData& data) = 0;
  258. /** Gets tail size in samples. For example, if the Plug-in is a Reverb Plug-in and it knows that
  259. the maximum length of the Reverb is 2sec, then it has to return in getTailSamples()
  260. (in VST2 it was getGetTailSize ()): 2*sampleRate.
  261. This information could be used by host for offline processing, process optimization and
  262. downmix (avoiding signal cut (clicks)).
  263. It should return:
  264. - kNoTail when no tail
  265. - x * sampleRate when x Sec tail.
  266. - kInfiniteTail when infinite tail. */
  267. virtual uint32 PLUGIN_API getTailSamples () = 0;
  268. //------------------------------------------------------------------------
  269. static const FUID iid;
  270. };
  271. DECLARE_CLASS_IID (IAudioProcessor, 0x42043F99, 0xB7DA453C, 0xA569E79D, 0x9AAEC33D)
  272. //------------------------------------------------------------------------
  273. /** Extended IAudioProcessor interface for a component.
  274. \ingroup vstIPlug vst310
  275. - [plug imp]
  276. - [extends IAudioProcessor]
  277. - [released: 3.1.0]
  278. Inform the Plug-in about how long from the moment of generation/acquiring (from file or from Input)
  279. 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).
  280. Note for Input Presentation Latency: when reading from file, the first Plug-in will have an input presentation latency set to zero.
  281. When monitoring audio input from a Audio Device, then this initial input latency will be the input latency of the Audio Device itself.
  282. Note for Output Presentation Latency: when writing to a file, the last Plug-in will have an output presentation latency set to zero.
  283. When the output of this Plug-in is connected to a Audio Device then this initial output latency will be the output
  284. latency of the Audio Device itself.
  285. A value of zero means either no latency or an unknown latency.
  286. Each Plug-in adding a latency (returning a none zero value for IAudioProcessor::getLatencySamples) will modify the input
  287. presentation latency of the next Plug-ins in the mixer routing graph and will modify the output presentation latency
  288. of the previous Plug-ins.
  289. \see IAudioProcessor
  290. \see IComponent*/
  291. //------------------------------------------------------------------------
  292. class IAudioPresentationLatency: public FUnknown
  293. {
  294. public:
  295. //------------------------------------------------------------------------
  296. /** Informs the Plug-in about the Audio Presentation Latency in samples for a given direction (kInput/kOutput) and bus index. */
  297. virtual tresult PLUGIN_API setAudioPresentationLatencySamples (BusDirection dir, int32 busIndex, uint32 latencyInSamples) = 0;
  298. //------------------------------------------------------------------------
  299. static const FUID iid;
  300. };
  301. DECLARE_CLASS_IID (IAudioPresentationLatency, 0x309ECE78, 0xEB7D4fae, 0x8B2225D9, 0x09FD08B6)
  302. //------------------------------------------------------------------------
  303. } // namespace Vst
  304. } // namespace Steinberg
  305. //------------------------------------------------------------------------
  306. #include "pluginterfaces/base/falignpop.h"
  307. //------------------------------------------------------------------------