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.

ivsteditcontroller.h 18KB

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