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.

170 lines
6.3KB

  1. //------------------------------------------------------------------------
  2. // Project : VST SDK
  3. //
  4. // Category : Interfaces
  5. // Filename : pluginterfaces/vst/ivstphysicalui.h
  6. // Created by : Steinberg, 06/2018
  7. // Description : VST Physical User Interface support
  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/vst/ivstnoteexpression.h"
  18. //------------------------------------------------------------------------
  19. #include "pluginterfaces/base/falignpush.h"
  20. //------------------------------------------------------------------------
  21. //------------------------------------------------------------------------
  22. namespace Steinberg {
  23. namespace Vst {
  24. //------------------------------------------------------------------------
  25. /** \defgroup vst3typedef VST 3 Data Types */
  26. /*@{*/
  27. //------------------------------------------------------------------------
  28. /** Physical UI Type */
  29. typedef uint32 PhysicalUITypeID;
  30. /*@}*/
  31. //------------------------------------------------------------------------
  32. /** PhysicalUITypeIDs describes the type of Physical UI (PUI) which could be associated to a note
  33. expression.
  34. \see PhysicalUIMap
  35. */
  36. enum PhysicalUITypeIDs
  37. {
  38. /** absolute X position when touching keys of PUIs. Range [0=left, 0.5=middle, 1=right] */
  39. kPUIXMovement = 0,
  40. /** absolute Y position when touching keys of PUIs. Range [0=bottom/near, 0.5=center, 1=top/far] */
  41. kPUIYMovement,
  42. /** pressing a key down on keys of PUIs. Range [0=No Pressure, 1=Full Pressure] */
  43. kPUIPressure,
  44. kPUITypeCount, ///< count of current defined PUIs
  45. kInvalidPUITypeID = 0xFFFFFFFF ///< indicates an invalid or not initialized PUI type
  46. };
  47. //------------------------------------------------------------------------
  48. /** PhysicalUIMap describes a mapping of a noteExpression Type to a Physical UI Type.
  49. It is used in PhysicalUIMapList.
  50. \see PhysicalUIMapList
  51. */
  52. struct PhysicalUIMap
  53. {
  54. /** This represents the physical UI. /see PhysicalUITypeIDs, this is set by the caller of
  55. * getPhysicalUIMapping */
  56. PhysicalUITypeID physicalUITypeID;
  57. /** This represents the associated noteExpression TypeID to the given physicalUITypeID. This
  58. * will be filled by the plug-in in the call getPhysicalUIMapping, set it to kInvalidTypeID if
  59. * no Note Expression is associated to the given PUI. */
  60. NoteExpressionTypeID noteExpressionTypeID;
  61. };
  62. //------------------------------------------------------------------------
  63. /** PhysicalUIMapList describes a list of PhysicalUIMap
  64. \see INoteExpressionPhysicalUIMapping
  65. */
  66. struct PhysicalUIMapList
  67. {
  68. /** Count of entries in the map array, set by the caller of getPhysicalUIMapping. */
  69. uint32 count;
  70. /** Pointer to a list of PhysicalUIMap containing count entries. */
  71. PhysicalUIMap* map;
  72. };
  73. //------------------------------------------------------------------------
  74. /** Extended plug-in interface IEditController for note expression event support: Vst::INoteExpressionPhysicalUIMapping
  75. \ingroup vstIPlug vst3611
  76. - [plug imp]
  77. - [extends IEditController]
  78. - [released: 3.6.11]
  79. - [optional]
  80. With this plug-in interface, the host can retrieve the preferred physical mapping associated to note
  81. expression supported by the plug-in.
  82. When the mapping changes (for example when switching presets) the plug-in needs
  83. to inform the host about it via \ref IComponentHandler::restartComponent (kNoteExpressionChanged).
  84. \section INoteExpressionPhysicalUIMappingExample Example
  85. \code{.cpp}
  86. //------------------------------------------------------------------------
  87. // here an example of how a VST3 plug-in could support this INoteExpressionPhysicalUIMapping interface.
  88. // we need to define somewhere the iids:
  89. //in MyController class declaration
  90. class MyController : public Vst::EditController, public Vst::INoteExpressionPhysicalUIMapping
  91. {
  92. // ...
  93. //--- INoteExpressionPhysicalUIMapping ---------------------------------
  94. tresult PLUGIN_API getPhysicalUIMapping (int32 busIndex, int16 channel, PhysicalUIMapList& list) SMTG_OVERRIDE;
  95. // ...
  96. OBJ_METHODS (MyController, Vst::EditController)
  97. DEFINE_INTERFACES
  98. // ...
  99. DEF_INTERFACE (Vst::INoteExpressionPhysicalUIMapping)
  100. END_DEFINE_INTERFACES (Vst::EditController)
  101. //...
  102. }
  103. // In mycontroller.cpp
  104. #include "pluginterfaces/vst/ivstnoteexpression.h"
  105. namespace Steinberg {
  106. namespace Vst {
  107. DEF_CLASS_IID (INoteExpressionPhysicalUIMapping)
  108. }
  109. }
  110. //------------------------------------------------------------------------
  111. tresult PLUGIN_API MyController::getPhysicalUIMapping (int32 busIndex, int16 channel, PhysicalUIMapList& list)
  112. {
  113. if (busIndex == 0 && channel == 0)
  114. {
  115. for (uint32 i = 0; i < list.count; ++i)
  116. {
  117. NoteExpressionTypeID type = kInvalidTypeID;
  118. if (kPUIXMovement == list.map[i].physicalUITypeID)
  119. list.map[i].noteExpressionTypeID = kCustomStart + 1;
  120. else if (kPUIYMovement == list.map[i].physicalUITypeID)
  121. list.map[i].noteExpressionTypeID = kCustomStart + 2;
  122. }
  123. return kResultTrue;
  124. }
  125. return kResultFalse;
  126. }
  127. \endcode
  128. */
  129. class INoteExpressionPhysicalUIMapping : public FUnknown
  130. {
  131. public:
  132. /** Fills the list of mapped [physical UI (in) - note expression (out)] for a given bus index
  133. * and channel. */
  134. virtual tresult PLUGIN_API getPhysicalUIMapping (int32 busIndex, int16 channel,
  135. PhysicalUIMapList& list) = 0;
  136. //------------------------------------------------------------------------
  137. static const FUID iid;
  138. };
  139. DECLARE_CLASS_IID (INoteExpressionPhysicalUIMapping, 0xB03078FF, 0x94D24AC8, 0x90CCD303, 0xD4133324)
  140. //------------------------------------------------------------------------
  141. } // namespace Vst
  142. } // namespace Steinberg
  143. //------------------------------------------------------------------------
  144. #include "pluginterfaces/base/falignpop.h"
  145. //------------------------------------------------------------------------