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.

435 lines
19KB

  1. //------------------------------------------------------------------------
  2. // Project : VST SDK
  3. //
  4. // Category : Interfaces
  5. // Filename : pluginterfaces/vst/ivsteditcontroller.h
  6. // Created by : Steinberg, 09/2005
  7. // Description : VST Edit Controller 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. //-----------------------------------------------------------------------------
  16. #pragma once
  17. #include "pluginterfaces/base/ipluginbase.h"
  18. #include "vsttypes.h"
  19. //------------------------------------------------------------------------
  20. #include "pluginterfaces/base/falignpush.h"
  21. //------------------------------------------------------------------------
  22. //------------------------------------------------------------------------
  23. /** Class Category Name for Controller Component */
  24. //------------------------------------------------------------------------
  25. #ifndef kVstComponentControllerClass
  26. #define kVstComponentControllerClass "Component Controller Class"
  27. #endif
  28. //------------------------------------------------------------------------
  29. namespace Steinberg {
  30. class IPlugView;
  31. class IBStream;
  32. //------------------------------------------------------------------------
  33. namespace Vst {
  34. //------------------------------------------------------------------------
  35. /** Controller Parameter Info. */
  36. //------------------------------------------------------------------------
  37. struct ParameterInfo
  38. {
  39. //------------------------------------------------------------------------
  40. ParamID id; ///< unique identifier of this parameter (named tag too)
  41. String128 title; ///< parameter title (e.g. "Volume")
  42. String128 shortTitle; ///< parameter shortTitle (e.g. "Vol")
  43. String128 units; ///< parameter unit (e.g. "dB")
  44. int32 stepCount; ///< number of discrete steps (0: continuous, 1: toggle, discrete value otherwise
  45. ///< (corresponding to max - min, for example: 127 for a min = 0 and a max = 127) - see \ref vst3parameterIntro)
  46. ParamValue defaultNormalizedValue; ///< default normalized value [0,1] (in case of discrete value: defaultNormalizedValue = defDiscreteValue / stepCount)
  47. UnitID unitId; ///< id of unit this parameter belongs to (see \ref vst3UnitsIntro)
  48. int32 flags; ///< ParameterFlags (see below)
  49. enum ParameterFlags
  50. {
  51. kNoFlags = 0, ///< no flags wanted
  52. kCanAutomate = 1 << 0, ///< parameter can be automated
  53. kIsReadOnly = 1 << 1, ///< parameter cannot be changed from outside (implies that kCanAutomate is false)
  54. kIsWrapAround = 1 << 2, ///< attempts to set the parameter value out of the limits will result in a wrap around [SDK 3.0.2]
  55. kIsList = 1 << 3, ///< parameter should be displayed as list in generic editor or automation editing [SDK 3.1.0]
  56. kIsProgramChange = 1 << 15, ///< parameter is a program change (unitId gives info about associated unit
  57. ///< - see \ref vst3UnitPrograms)
  58. kIsBypass = 1 << 16 ///< special bypass parameter (only one allowed): Plug-in can handle bypass
  59. ///< (highly recommended to export a bypass parameter for effect Plug-in)
  60. };
  61. //------------------------------------------------------------------------
  62. };
  63. //------------------------------------------------------------------------
  64. /** View Types used for IEditController::createView */
  65. //------------------------------------------------------------------------
  66. namespace ViewType {
  67. const CString kEditor = "editor";
  68. }
  69. //------------------------------------------------------------------------
  70. /** Flags used for IComponentHandler::restartComponent */
  71. //------------------------------------------------------------------------
  72. enum RestartFlags
  73. {
  74. kReloadComponent = 1 << 0, ///< The Component should be reloaded [SDK 3.0.0]
  75. kIoChanged = 1 << 1, ///< Input and/or Output Bus configuration has changed [SDK 3.0.0]
  76. kParamValuesChanged = 1 << 2, ///< Multiple parameter values have changed
  77. ///< (as result of a program change for example) [SDK 3.0.0]
  78. kLatencyChanged = 1 << 3, ///< Latency has changed (IAudioProcessor.getLatencySamples) [SDK 3.0.0]
  79. kParamTitlesChanged = 1 << 4, ///< Parameter titles or default values or flags have changed [SDK 3.0.0]
  80. kMidiCCAssignmentChanged = 1 << 5, ///< MIDI Controller Assignments have changed [SDK 3.0.1]
  81. kNoteExpressionChanged = 1 << 6, ///< Note Expression has changed (info, count, PhysicalUIMapping, ...) [SDK 3.5.0]
  82. kIoTitlesChanged = 1 << 7, ///< Input and/or Output bus titles have changed [SDK 3.5.0]
  83. kPrefetchableSupportChanged = 1 << 8, ///< Prefetch support has changed (\see IPrefetchableSupport) [SDK 3.6.1]
  84. kRoutingInfoChanged = 1 << 9 ///< RoutingInfo has changed (\see IComponent) [SDK 3.6.6]
  85. };
  86. //------------------------------------------------------------------------
  87. /** Host callback interface for an edit controller.
  88. \ingroup vstIHost vst300
  89. - [host imp]
  90. - [released: 3.0.0]
  91. - [mandatory]
  92. Allow transfer of parameter editing to component (processor) via host and support automation.
  93. Cause the host to react on configuration changes (restartComponent)
  94. \see IEditController */
  95. //------------------------------------------------------------------------
  96. class IComponentHandler: public FUnknown
  97. {
  98. public:
  99. //------------------------------------------------------------------------
  100. /** To be called before calling a performEdit (e.g. on mouse-click-down event). */
  101. virtual tresult PLUGIN_API beginEdit (ParamID id) = 0;
  102. /** Called between beginEdit and endEdit to inform the handler that a given parameter has a new value. */
  103. virtual tresult PLUGIN_API performEdit (ParamID id, ParamValue valueNormalized) = 0;
  104. /** To be called after calling a performEdit (e.g. on mouse-click-up event). */
  105. virtual tresult PLUGIN_API endEdit (ParamID id) = 0;
  106. /** Instructs host to restart the component. This should be called in the UI-Thread context!
  107. \param flags is a combination of RestartFlags */
  108. virtual tresult PLUGIN_API restartComponent (int32 flags) = 0;
  109. //------------------------------------------------------------------------
  110. static const FUID iid;
  111. };
  112. DECLARE_CLASS_IID (IComponentHandler, 0x93A0BEA3, 0x0BD045DB, 0x8E890B0C, 0xC1E46AC6)
  113. //------------------------------------------------------------------------
  114. /** Extended Host callback interface IComponentHandler2 for an edit controller
  115. \ingroup vstIHost vst310
  116. - [host imp]
  117. - [extends IComponentHandler]
  118. - [released: 3.1.0]
  119. - [optional]
  120. One part handles:
  121. - Setting dirty state of Plug-in
  122. - requesting the host to open the editor
  123. The other part handles parameter group editing from Plug-in UI. It wraps a set of \ref IComponentHandler::beginEdit /
  124. \ref IComponentHandler::performEdit / \ref IComponentHandler::endEdit functions (see \ref IComponentHandler)
  125. which should use the same timestamp in the host when writing automation.
  126. This allows for better synchronizing multiple parameter changes at once.
  127. \section IComponentHandler2Example Examples of different use cases
  128. \code
  129. //--------------------------------------
  130. // in case of multiple switch buttons (with associated ParamID 1 and 3)
  131. // on mouse down :
  132. hostHandler2->startGroupEdit ();
  133. hostHandler->beginEdit (1);
  134. hostHandler->beginEdit (3);
  135. hostHandler->performEdit (1, 1.0);
  136. hostHandler->performEdit (3, 0.0); // the opposite of paramID 1 for example
  137. ....
  138. // on mouse up :
  139. hostHandler->endEdit (1);
  140. hostHandler->endEdit (3);
  141. hostHandler2->finishGroupEdit ();
  142. ....
  143. ....
  144. //--------------------------------------
  145. // in case of multiple faders (with associated ParamID 1 and 3)
  146. // on mouse down :
  147. hostHandler2->startGroupEdit ();
  148. hostHandler->beginEdit (1);
  149. hostHandler->beginEdit (3);
  150. hostHandler2->finishGroupEdit ();
  151. ....
  152. // on mouse move :
  153. hostHandler2->startGroupEdit ();
  154. hostHandler->performEdit (1, x); // x the wanted value
  155. hostHandler->performEdit (3, x);
  156. hostHandler2->finishGroupEdit ();
  157. ....
  158. // on mouse up :
  159. hostHandler2->startGroupEdit ();
  160. hostHandler->endEdit (1);
  161. hostHandler->endEdit (3);
  162. hostHandler2->finishGroupEdit ();
  163. \endcode
  164. \see IComponentHandler
  165. \see IEditController*/
  166. //------------------------------------------------------------------------
  167. class IComponentHandler2: public FUnknown
  168. {
  169. public:
  170. //------------------------------------------------------------------------
  171. /** Tells host that the Plug-in is dirty (something besides parameters has changed since last save),
  172. if true the host should apply a save before quitting. */
  173. virtual tresult PLUGIN_API setDirty (TBool state) = 0;
  174. /** Tells host that it should open the Plug-in editor the next time it's possible.
  175. You should use this instead of showing an alert and blocking the program flow (especially on loading projects). */
  176. virtual tresult PLUGIN_API requestOpenEditor (FIDString name = ViewType::kEditor) = 0;
  177. //------------------------------------------------------------------------
  178. /** Starts the group editing (call before a \ref IComponentHandler::beginEdit),
  179. the host will keep the current timestamp at this call and will use it for all \ref IComponentHandler::beginEdit
  180. / \ref IComponentHandler::performEdit / \ref IComponentHandler::endEdit calls until a \ref finishGroupEdit (). */
  181. virtual tresult PLUGIN_API startGroupEdit () = 0;
  182. /** Finishes the group editing started by a \ref startGroupEdit (call after a \ref IComponentHandler::endEdit). */
  183. virtual tresult PLUGIN_API finishGroupEdit () = 0;
  184. //------------------------------------------------------------------------
  185. static const FUID iid;
  186. };
  187. DECLARE_CLASS_IID (IComponentHandler2, 0xF040B4B3, 0xA36045EC, 0xABCDC045, 0xB4D5A2CC)
  188. //------------------------------------------------------------------------
  189. /** Extended Host callback interface IComponentHandlerBusActivation for an edit controller.
  190. \ingroup vstIHost vst368
  191. - [host imp]
  192. - [extends IComponentHandler]
  193. - [released: 3.6.8]
  194. - [optional]
  195. Allows the Plug-in to request the host to activate or deactivate a specific bus,
  196. if the host accepts it will call later on IComponent::activateBus (see \ref IComponent::activateBus).
  197. Useful especially for Instrument with more than 1 outputs, where the user could request
  198. from the Plug-in UI a given output bus activation.
  199. \see \ref IComponentHandler */
  200. //------------------------------------------------------------------------
  201. class IComponentHandlerBusActivation : public FUnknown
  202. {
  203. public:
  204. //------------------------------------------------------------------------
  205. /** request the host to activate or deactivate a specific bus. */
  206. virtual tresult PLUGIN_API requestBusActivation (MediaType type, BusDirection dir, int32 index,
  207. TBool state) = 0;
  208. //------------------------------------------------------------------------
  209. static const FUID iid;
  210. };
  211. DECLARE_CLASS_IID (IComponentHandlerBusActivation, 0x067D02C1, 0x5B4E274D, 0xA92D90FD, 0x6EAF7240)
  212. //------------------------------------------------------------------------
  213. /** Edit controller component interface.
  214. \ingroup vstIPlug vst300
  215. - [plug imp]
  216. - [released: 3.0.0]
  217. - [mandatory]
  218. The Controller part of an effect or instrument with parameter handling (export, definition, conversion...).
  219. \see IComponent::getControllerClassId, IMidiMapping */
  220. //------------------------------------------------------------------------
  221. class IEditController: public IPluginBase
  222. {
  223. public:
  224. //------------------------------------------------------------------------
  225. /** Receives the component state. */
  226. virtual tresult PLUGIN_API setComponentState (IBStream* state) = 0;
  227. /** Sets the controller state. */
  228. virtual tresult PLUGIN_API setState (IBStream* state) = 0;
  229. /** Gets the controller state. */
  230. virtual tresult PLUGIN_API getState (IBStream* state) = 0;
  231. // parameters -------------------------
  232. /** Returns the number of parameters exported. */
  233. virtual int32 PLUGIN_API getParameterCount () = 0;
  234. /** Gets for a given index the parameter information. */
  235. virtual tresult PLUGIN_API getParameterInfo (int32 paramIndex, ParameterInfo& info /*out*/) = 0;
  236. /** Gets for a given paramID and normalized value its associated string representation. */
  237. virtual tresult PLUGIN_API getParamStringByValue (ParamID id, ParamValue valueNormalized /*in*/, String128 string /*out*/) = 0;
  238. /** Gets for a given paramID and string its normalized value. */
  239. virtual tresult PLUGIN_API getParamValueByString (ParamID id, TChar* string /*in*/, ParamValue& valueNormalized /*out*/) = 0;
  240. /** Returns for a given paramID and a normalized value its plain representation
  241. (for example 90 for 90db - see \ref vst3AutomationIntro). */
  242. virtual ParamValue PLUGIN_API normalizedParamToPlain (ParamID id, ParamValue valueNormalized) = 0;
  243. /** Returns for a given paramID and a plain value its normalized value. (see \ref vst3AutomationIntro) */
  244. virtual ParamValue PLUGIN_API plainParamToNormalized (ParamID id, ParamValue plainValue) = 0;
  245. /** Returns the normalized value of the parameter associated to the paramID. */
  246. virtual ParamValue PLUGIN_API getParamNormalized (ParamID id) = 0;
  247. /** Sets the normalized value to the parameter associated to the paramID. The controller must never
  248. pass this value-change back to the host via the IComponentHandler. It should update the according
  249. GUI element(s) only!*/
  250. virtual tresult PLUGIN_API setParamNormalized (ParamID id, ParamValue value) = 0;
  251. // handler ----------------------------
  252. /** Gets from host a handler. */
  253. virtual tresult PLUGIN_API setComponentHandler (IComponentHandler* handler) = 0;
  254. // view -------------------------------
  255. /** Creates the editor view of the Plug-in, currently only "editor" is supported, see \ref ViewType.
  256. The life time of the editor view will never exceed the life time of this controller instance. */
  257. virtual IPlugView* PLUGIN_API createView (FIDString name) = 0;
  258. //------------------------------------------------------------------------
  259. static const FUID iid;
  260. };
  261. DECLARE_CLASS_IID (IEditController, 0xDCD7BBE3, 0x7742448D, 0xA874AACC, 0x979C759E)
  262. //------------------------------------------------------------------------
  263. /** Knob Mode */
  264. //------------------------------------------------------------------------
  265. enum KnobModes
  266. {
  267. kCircularMode = 0, ///< Circular with jump to clicked position
  268. kRelativCircularMode, ///< Circular without jump to clicked position
  269. kLinearMode ///< Linear: depending on vertical movement
  270. };
  271. typedef int32 KnobMode; ///< Knob Mode
  272. //------------------------------------------------------------------------
  273. /** Edit controller component interface extension.
  274. \ingroup vstIPlug vst310
  275. - [plug imp]
  276. - [extends IEditController]
  277. - [released: 3.1.0]
  278. - [optional]
  279. Extension to inform the Plug-in about the host Knob Mode,
  280. and to open the Plug-in about box or help documentation.
  281. \see IEditController*/
  282. //------------------------------------------------------------------------
  283. class IEditController2: public FUnknown
  284. {
  285. public:
  286. /** Host could set the Knob Mode for the Plug-in. Return kResultFalse means not supported mode. \see KnobModes. */
  287. virtual tresult PLUGIN_API setKnobMode (KnobMode mode) = 0;
  288. /** Host could ask to open the Plug-in help (could be: opening a PDF document or link to a web page).
  289. The host could call it with onlyCheck set to true for testing support of open Help.
  290. Return kResultFalse means not supported function. */
  291. virtual tresult PLUGIN_API openHelp (TBool onlyCheck) = 0;
  292. /** Host could ask to open the Plug-in about box.
  293. The host could call it with onlyCheck set to true for testing support of open AboutBox.
  294. Return kResultFalse means not supported function. */
  295. virtual tresult PLUGIN_API openAboutBox (TBool onlyCheck) = 0;
  296. //------------------------------------------------------------------------
  297. static const FUID iid;
  298. };
  299. DECLARE_CLASS_IID (IEditController2, 0x7F4EFE59, 0xF3204967, 0xAC27A3AE, 0xAFB63038)
  300. //------------------------------------------------------------------------
  301. /** MIDI Mapping Interface.
  302. \ingroup vstIPlug vst301
  303. - [plug imp]
  304. - [extends IEditController]
  305. - [released: 3.0.1]
  306. - [optional]
  307. MIDI controllers are not transmitted directly to a VST component. MIDI as hardware protocol has
  308. restrictions that can be avoided in software. Controller data in particular come along with unclear
  309. and often ignored semantics. On top of this they can interfere with regular parameter automation and
  310. the host is unaware of what happens in the Plug-in when passing MIDI controllers directly.
  311. So any functionality that is to be controlled by MIDI controllers must be exported as regular parameter.
  312. The host will transform incoming MIDI controller data using this interface and transmit them as normal
  313. parameter change. This allows the host to automate them in the same way as other parameters.
  314. CtrlNumber could be typical MIDI controller value extended to some others values like pitch bend or
  315. after touch (see \ref ControllerNumbers).
  316. If the mapping has changed, the Plug-in should call IComponentHandler::restartComponent (kMidiCCAssignmentChanged)
  317. to inform the host about this change. */
  318. //------------------------------------------------------------------------
  319. class IMidiMapping: public FUnknown
  320. {
  321. public:
  322. /** Gets an (preferred) associated ParamID for a given Input Event Bus index, channel and MIDI Controller.
  323. * @param[in] busIndex - index of Input Event Bus
  324. * @param[in] channel - channel of the bus
  325. * @param[in] midiControllerNumber - see \ref ControllerNumbers for expected values (could be bigger than 127)
  326. * @param[in] id - return the associated ParamID to the given midiControllerNumber
  327. */
  328. virtual tresult PLUGIN_API getMidiControllerAssignment (int32 busIndex, int16 channel,
  329. CtrlNumber midiControllerNumber, ParamID& id/*out*/) = 0;
  330. //------------------------------------------------------------------------
  331. static const FUID iid;
  332. };
  333. DECLARE_CLASS_IID (IMidiMapping, 0xDF0FF9F7, 0x49B74669, 0xB63AB732, 0x7ADBF5E5)
  334. //------------------------------------------------------------------------
  335. /** Parameter Editing from Host.
  336. \ingroup vstIPlug vst350
  337. - [plug imp]
  338. - [extends IEditController]
  339. - [released: 3.5.0]
  340. - [optional]
  341. If this interface is implemented by the edit controller and when performing edits from outside
  342. the Plug-in (host / remote) of a not automatable and not read only flagged parameter (kind of helper parameter),
  343. the host will start with a beginEditFromHost before calling setParamNormalized and end with an endEditFromHost.
  344. Here the sequencing, the host will call:
  345. - beginEditFromHost ()
  346. - setParamNormalized ()
  347. - setParamNormalized ()
  348. - ...
  349. - endEditFromHost ()
  350. \see IEditController */
  351. //------------------------------------------------------------------------
  352. class IEditControllerHostEditing : public FUnknown
  353. {
  354. public:
  355. /** Called before a setParamNormalized sequence, a endEditFromHost will be call at the end of the editing action. */
  356. virtual tresult PLUGIN_API beginEditFromHost (ParamID paramID) = 0;
  357. /** Called after a beginEditFromHost and a sequence of setParamNormalized. */
  358. virtual tresult PLUGIN_API endEditFromHost (ParamID paramID) = 0;
  359. //------------------------------------------------------------------------
  360. static const FUID iid;
  361. };
  362. DECLARE_CLASS_IID (IEditControllerHostEditing, 0xC1271208, 0x70594098, 0xB9DD34B3, 0x6BB0195E)
  363. //------------------------------------------------------------------------
  364. } // namespace Vst
  365. } // namespace Steinberg
  366. //------------------------------------------------------------------------
  367. #include "pluginterfaces/base/falignpop.h"
  368. //------------------------------------------------------------------------