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.

250 lines
12KB

  1. //------------------------------------------------------------------------
  2. // Project : VST SDK
  3. // Version : 3.6.7
  4. //
  5. // Category : Interfaces
  6. // Filename : pluginterfaces/vst/ivstnoteexpression.h
  7. // Created by : Steinberg, 10/2010
  8. // Description : VST Note Expression 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/funknown.h"
  19. #include "vsttypes.h"
  20. //------------------------------------------------------------------------
  21. #include "pluginterfaces/base/falignpush.h"
  22. //------------------------------------------------------------------------
  23. namespace Steinberg {
  24. namespace Vst {
  25. typedef uint32 NoteExpressionTypeID;
  26. typedef double NoteExpressionValue;
  27. //------------------------------------------------------------------------
  28. /** NoteExpressionTypeIDs describes the type of the note expression.
  29. VST predefines some types like volume, pan, tuning by defining their ranges and curves.
  30. Used by NoteExpressionEvent::typeId and NoteExpressionTypeID::typeId
  31. \see NoteExpressionTypeInfo
  32. */
  33. enum NoteExpressionTypeIDs
  34. {
  35. kVolumeTypeID = 0, ///< Volume, plain range [0 = -oo , 0.25 = 0dB, 0.5 = +6dB, 1 = +12dB]: plain = 20 * log (4 * norm)
  36. kPanTypeID, ///< Panning (L-R), plain range [0 = left, 0.5 = center, 1 = right]
  37. kTuningTypeID, ///< Tuning, plain range [0 = -120.0 (ten octaves down), 0.5 none, 1 = +120.0 (ten octaves up)]
  38. ///< plain = 240 * (norm - 0.5) and norm = plain / 240 + 0.5
  39. ///< oneOctave is 12.0 / 240.0; oneHalfTune = 1.0 / 240.0;
  40. kVibratoTypeID, ///< Vibrato
  41. kExpressionTypeID, ///< Expression
  42. kBrightnessTypeID, ///< Brightness
  43. kTextTypeID, ///< TODO:
  44. kPhonemeTypeID, ///< TODO:
  45. kCustomStart = 100000 ///< custom note change type ids must start from here
  46. };
  47. //------------------------------------------------------------------------
  48. /** Description of a Note Expression Type
  49. This structure is part of the NoteExpressionTypeInfo structure, it describes for given NoteExpressionTypeID its default value
  50. (for example 0.5 for a kTuningTypeID (kIsBipolar: centered)), its minimum and maximum (for predefined NoteExpressionTypeID the full range is predefined too)
  51. and a stepCount when the given NoteExpressionTypeID is limited to discrete values (like on/off state).
  52. \see NoteExpressionTypeInfo
  53. */
  54. //------------------------------------------------------------------------
  55. struct NoteExpressionValueDescription
  56. {
  57. NoteExpressionValue defaultValue; ///< default normalized value [0,1]
  58. NoteExpressionValue minimum; ///< minimum normalized value [0,1]
  59. NoteExpressionValue maximum; ///< maximum normalized value [0,1]
  60. int32 stepCount; ///< number of discrete steps (0: continuous, 1: toggle, discrete value otherwise - see \ref vst3parameterIntro)
  61. };
  62. #if WINDOWS && !PLATFORM_64
  63. #include "pluginterfaces/vst/vstpshpack4.h"
  64. #endif
  65. //------------------------------------------------------------------------
  66. /** Note Expression Value event. Used in \ref Event (union)
  67. A note expression event affects one single playing note (referring its noteId).
  68. This kind of event is send from host to the Plug-in like other events (NoteOnEvent, NoteOffEvent,...) in \ref ProcessData during the process call.
  69. Note expression events for a specific noteId can only occur after a NoteOnEvent. The host must take care that the event list (\ref IEventList) is properly sorted.
  70. Expression events are always absolute normalized values [0.0, 1.0].
  71. The predefined types have a predefined mapping of the normalized values (see \ref NoteExpressionTypeIDs)
  72. \sa INoteExpressionController
  73. */
  74. //------------------------------------------------------------------------
  75. struct NoteExpressionValueEvent
  76. {
  77. NoteExpressionTypeID typeId; ///< see \ref NoteExpressionTypeID
  78. int32 noteId; ///< associated note identifier to apply the change
  79. NoteExpressionValue value; ///< normalized value [0.0, 1.0].
  80. };
  81. //------------------------------------------------------------------------
  82. /** Note Expression Text event. Used in Event (union)
  83. A Expression event affects one single playing note. \sa INoteExpressionController
  84. \see NoteExpressionTypeInfo*/
  85. //------------------------------------------------------------------------
  86. struct NoteExpressionTextEvent
  87. {
  88. NoteExpressionTypeID typeId; ///< see \ref NoteExpressionTypeID (kTextTypeID or kPhoneticTypeID)
  89. int32 noteId; ///< associated note identifier to apply the change
  90. uint32 textLen; ///< the number of characters (TChar) between the beginning of text and the terminating
  91. ///< null character (without including the terminating null character itself)
  92. const TChar* text; ///< UTF-16, null terminated
  93. };
  94. #if WINDOWS && !PLATFORM_64
  95. #include "pluginterfaces/base/falignpop.h"
  96. #endif
  97. //------------------------------------------------------------------------
  98. /** NoteExpressionTypeInfo is the structure describing a note expression supported by the Plug-in.
  99. This structure is used by the method \ref INoteExpressionController::getNoteExpressionInfo.
  100. \see INoteExpressionController
  101. */
  102. //------------------------------------------------------------------------
  103. struct NoteExpressionTypeInfo
  104. {
  105. NoteExpressionTypeID typeId; ///< unique identifier of this note Expression type
  106. String128 title; ///< note Expression type title (e.g. "Volume")
  107. String128 shortTitle; ///< note Expression type short title (e.g. "Vol")
  108. String128 units; ///< note Expression type unit (e.g. "dB")
  109. int32 unitId; ///< id of unit this NoteExpression belongs to (see \ref vst3UnitsIntro), in order to sort the note expression, it is possible to use unitId like for parameters. -1 means no unit used.
  110. NoteExpressionValueDescription valueDesc; ///< value description see \ref NoteExpressionValueDescription
  111. ParamID associatedParameterId; ///< optional associated parameter ID (for mapping from note expression to global (using the parameter automation for example) and back). Only used when kAssociatedParameterIDValid is set in flags.
  112. int32 flags; ///< NoteExpressionTypeFlags (see below)
  113. enum NoteExpressionTypeFlags
  114. {
  115. kIsBipolar = 1 << 0, ///< event is bipolar (centered), otherwise unipolar
  116. kIsOneShot = 1 << 1, ///< event occurs only one time for its associated note (at begin of the noteOn)
  117. kIsAbsolute = 1 << 2, ///< This note expression will apply an absolute change to the sound (not relative (offset))
  118. kAssociatedParameterIDValid = 1 << 3,///< indicates that the associatedParameterID is valid and could be used
  119. };
  120. };
  121. //------------------------------------------------------------------------
  122. /** Extended Plug-in interface IEditController for note expression event support
  123. \ingroup vstIPlug vst350
  124. - [plug imp]
  125. - [extends IEditController]
  126. - [released: 3.5.0]
  127. - [optional]
  128. With this Plug-in interface, the host can retrieve all necessary note expression information supported by the Plug-in.
  129. Note expression information (\ref NoteExpressionTypeInfo) are specific for given channel and event bus.
  130. Note that there is only one NoteExpressionTypeID per given channel of an event bus.
  131. The method getNoteExpressionStringByValue allows conversion from a normalized value to a string representation
  132. and the getNoteExpressionValueByString method from a string to a normalized value.
  133. When the note expression state changes (per example when switching presets) the Plug-in needs
  134. to inform the host about it via \ref IComponentHandler::restartComponent (kNoteExpressionChanged).
  135. */
  136. //------------------------------------------------------------------------
  137. class INoteExpressionController: public FUnknown
  138. {
  139. public:
  140. /** Returns number of supported note change types for event bus index and channel. */
  141. virtual int32 PLUGIN_API getNoteExpressionCount (int32 busIndex, int16 channel) = 0;
  142. /** Returns note change type info. */
  143. virtual tresult PLUGIN_API getNoteExpressionInfo (int32 busIndex, int16 channel, int32 noteExpressionIndex, NoteExpressionTypeInfo& info /*out*/) = 0;
  144. /** Gets a user readable representation of the normalized note change value. */
  145. virtual tresult PLUGIN_API getNoteExpressionStringByValue (int32 busIndex, int16 channel, NoteExpressionTypeID id, NoteExpressionValue valueNormalized /*in*/, String128 string /*out*/) = 0;
  146. /** Converts the user readable representation to the normalized note change value. */
  147. virtual tresult PLUGIN_API getNoteExpressionValueByString (int32 busIndex, int16 channel, NoteExpressionTypeID id, const TChar* string /*in*/, NoteExpressionValue& valueNormalized /*out*/) = 0;
  148. //------------------------------------------------------------------------
  149. static const FUID iid;
  150. };
  151. DECLARE_CLASS_IID (INoteExpressionController, 0xB7F8F859, 0x41234872, 0x91169581, 0x4F3721A3)
  152. //------------------------------------------------------------------------
  153. //------------------------------------------------------------------------
  154. /** KeyswitchTypeIDs describes the type of a key switch
  155. \see KeyswitchInfo
  156. */
  157. enum KeyswitchTypeIDs
  158. {
  159. kNoteOnKeyswitchTypeID = 0, ///< press before noteOn is played
  160. kOnTheFlyKeyswitchTypeID, ///< press while noteOn is played
  161. kOnReleaseKeyswitchTypeID, ///< press before entering release
  162. kKeyRangeTypeID ///< key should be maintained pressed for playing
  163. };
  164. typedef uint32 KeyswitchTypeID;
  165. //------------------------------------------------------------------------
  166. /** KeyswitchInfo is the structure describing a key switch
  167. This structure is used by the method \ref IKeyswitchController::getKeyswitchInfo.
  168. \see IKeyswitchController
  169. */
  170. struct KeyswitchInfo
  171. {
  172. KeyswitchTypeID typeId; ///< see KeyswitchTypeID
  173. String128 title; ///< name of key switch (e.g. "Accentuation")
  174. String128 shortTitle; ///< short title (e.g. "Acc")
  175. int32 keyswitchMin; ///< associated main key switch min (value between [0, 127])
  176. int32 keyswitchMax; ///< associated main key switch max (value between [0, 127])
  177. int32 keyRemapped; /** optional remapped key switch (default -1), the Plug-in could provide one remapped
  178. key for a key switch (allowing better location on the keyboard of the key switches) */
  179. int32 unitId; ///< id of unit this key switch belongs to (see \ref vst3UnitsIntro), -1 means no unit used.
  180. int32 flags; ///< not yet used (set to 0)
  181. };
  182. //------------------------------------------------------------------------
  183. /** Extended Plug-in interface IEditController for key switches support
  184. \ingroup vstIPlug vst350
  185. - [plug imp]
  186. - [extends IEditController]
  187. - [released: 3.5.0]
  188. - [optional]
  189. When a (instrument) Plug-in supports such interface, the host could get from the Plug-in the current set
  190. of used key switches (megatrig/articulation) for a given channel of a event bus and then automatically use them (like in Cubase 6) to
  191. create VST Expression Map (allowing to associated symbol to a given articulation / key switch).
  192. */
  193. //------------------------------------------------------------------------
  194. class IKeyswitchController: public FUnknown
  195. {
  196. public:
  197. /** Returns number of supported key switches for event bus index and channel. */
  198. virtual int32 PLUGIN_API getKeyswitchCount (int32 busIndex, int16 channel) = 0;
  199. /** Returns key switch info. */
  200. virtual tresult PLUGIN_API getKeyswitchInfo (int32 busIndex, int16 channel, int32 keySwitchIndex, KeyswitchInfo& info /*out*/) = 0;
  201. //------------------------------------------------------------------------
  202. static const FUID iid;
  203. };
  204. DECLARE_CLASS_IID (IKeyswitchController, 0x1F2F76D3, 0xBFFB4B96, 0xB99527A5, 0x5EBCCEF4)
  205. //------------------------------------------------------------------------
  206. } // namespace Vst
  207. } // namespace Steinberg
  208. //------------------------------------------------------------------------
  209. #include "pluginterfaces/base/falignpop.h"
  210. //------------------------------------------------------------------------