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.

ivstnoteexpression.h 12KB

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