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.

227 lines
8.3KB

  1. //------------------------------------------------------------------------
  2. // Project : VST SDK
  3. //
  4. // Category : Interfaces
  5. // Filename : pluginterfaces/vst/ivstchannelcontextinfo.h
  6. // Created by : Steinberg, 02/2014
  7. // Description : VST Channel Context Info Interface
  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/vsttypes.h"
  18. #include "pluginterfaces/vst/ivstattributes.h"
  19. //------------------------------------------------------------------------
  20. #include "pluginterfaces/base/falignpush.h"
  21. //------------------------------------------------------------------------
  22. //------------------------------------------------------------------------
  23. namespace Steinberg {
  24. namespace Vst {
  25. /** For Channel Context Info Interface */
  26. namespace ChannelContext {
  27. //------------------------------------------------------------------------
  28. //------------------------------------------------------------------------
  29. //------------------------------------------------------------------------
  30. //------------------------------------------------------------------------
  31. //------------------------------------------------------------------------
  32. /** Channel Context Interface.
  33. \ingroup vstIHost vst365
  34. - [plug imp]
  35. - [extends IEditController]
  36. - [released: 3.6.5]
  37. - [optional]
  38. Allows the host to inform the Plug-in about the context in which the Plug-in is instantiated,
  39. mainly channel based info (color, name, index,...). Index could be defined inside a namespace
  40. (for example index start from 1 to N for Type Input/Output Channel (Index namespace) and index
  41. start from 1 to M for Type Audio Channel).\n
  42. As soon as the Plug-in provides this IInfoListener interface, the host will call setChannelContextInfos
  43. for each change occurring to this channel (new name, new color, new indexation,...)
  44. \section IChannelContextExample Example
  45. \code
  46. tresult PLUGIN_API MyPlugin::setChannelContextInfos (IAttributeList* list)
  47. {
  48. if (list)
  49. {
  50. // optional we can ask for the Channel Name Length
  51. int64 length;
  52. if (list->getInt (ChannelContext::kChannelNameLengthKey, length) == kResultTrue)
  53. {
  54. ...
  55. }
  56. // get the Channel Name where we, as Plug-in, are instantiated
  57. String128 name;
  58. if (list->getString (ChannelContext::kChannelNameKey, name, sizeof (name)) == kResultTrue)
  59. {
  60. ...
  61. }
  62. // get the Channel UID
  63. if (list->getString (ChannelContext::kChannelUIDKey, name, sizeof (name)) == kResultTrue)
  64. {
  65. ...
  66. }
  67. // get Channel Index
  68. int64 index;
  69. if (list->getInt (ChannelContext::kChannelIndexKey, index) == kResultTrue)
  70. {
  71. ...
  72. }
  73. // get the Channel Color
  74. int64 color;
  75. if (list->getInt (ChannelContext::kChannelColorKey, color) == kResultTrue)
  76. {
  77. uint32 channelColor = (uint32)color;
  78. String str;
  79. str.printf ("%x%x%x%x", ChannelContext::GetAlpha (channelColor),
  80. ChannelContext::GetRed (channelColor),
  81. ChannelContext::GetGreen (channelColor),
  82. ChannelContext::GetBlue (channelColor));
  83. String128 string128;
  84. Steinberg::UString (string128, 128).fromAscii (str);
  85. ...
  86. }
  87. // get Channel Index Namespace Order of the current used index namespace
  88. if (list->getInt (ChannelContext::kChannelIndexNamespaceOrderKey, index) == kResultTrue)
  89. {
  90. ...
  91. }
  92. // get the channel Index Namespace Length
  93. if (list->getInt (ChannelContext::kChannelIndexNamespaceLengthKey, length) == kResultTrue)
  94. {
  95. ...
  96. }
  97. // get the channel Index Namespace
  98. String128 namespaceName;
  99. if (list->getString (ChannelContext::kChannelIndexNamespaceKey, namespaceName, sizeof (namespaceName)) == kResultTrue)
  100. {
  101. ...
  102. }
  103. // get Plug-in Channel Location
  104. int64 location;
  105. if (list->getInt (ChannelContext::kChannelPluginLocationKey, location) == kResultTrue)
  106. {
  107. String128 string128;
  108. switch (location)
  109. {
  110. case ChannelContext::kPreVolumeFader:
  111. Steinberg::UString (string128, 128).fromAscii ("PreVolFader");
  112. break;
  113. case ChannelContext::kPostVolumeFader:
  114. Steinberg::UString (string128, 128).fromAscii ("PostVolFader");
  115. break;
  116. case ChannelContext::kUsedAsPanner:
  117. Steinberg::UString (string128, 128).fromAscii ("UsedAsPanner");
  118. break;
  119. default: Steinberg::UString (string128, 128).fromAscii ("unknown!");
  120. break;
  121. }
  122. }
  123. // do not forget to call addRef () if you want to keep this list
  124. }
  125. }
  126. \endcode */
  127. //------------------------------------------------------------------------
  128. class IInfoListener: public FUnknown
  129. {
  130. public:
  131. /** Receive the channel context infos from host. */
  132. virtual tresult PLUGIN_API setChannelContextInfos (IAttributeList* list) = 0;
  133. static const FUID iid;
  134. };
  135. DECLARE_CLASS_IID (IInfoListener, 0x0F194781, 0x8D984ADA, 0xBBA0C1EF, 0xC011D8D0)
  136. //------------------------------------------------------------------------
  137. /** Values used for kChannelPluginLocationKey */
  138. //------------------------------------------------------------------------
  139. enum ChannelPluginLocation
  140. {
  141. kPreVolumeFader = 0,
  142. kPostVolumeFader,
  143. kUsedAsPanner
  144. };
  145. //------------------------------------------------------------------------
  146. //------------------------------------------------------------------------
  147. // Colors
  148. typedef uint32 ColorSpec; ///< ARGB (Alpha-Red-Green-Blue)
  149. typedef uint8 ColorComponent;
  150. inline ColorComponent GetBlue (ColorSpec cs) {return (ColorComponent)(cs & 0x000000FF); }
  151. inline ColorComponent GetGreen (ColorSpec cs) {return (ColorComponent)((cs >> 8) & 0x000000FF); }
  152. inline ColorComponent GetRed (ColorSpec cs) {return (ColorComponent)((cs >> 16) & 0x000000FF); }
  153. inline ColorComponent GetAlpha (ColorSpec cs) {return (ColorComponent)((cs >> 24) & 0x000000FF); }
  154. //------------------------------------------------------------------------
  155. /** Keys used as AttrID (Attribute ID) in the return IAttributeList of
  156. * IInfoListener::setChannelContextInfos */
  157. //------------------------------------------------------------------------
  158. /** string (TChar) [optional]: unique id string used to identify a channel */
  159. const CString kChannelUIDKey = "channel uid";
  160. /** integer (int64) [optional]: number of characters in kChannelUIDKey */
  161. const CString kChannelUIDLengthKey = "channel uid length";
  162. /** string (TChar) [optional]: name of the channel like displayed in the mixer */
  163. const CString kChannelNameKey = "channel name";
  164. /** integer (int64) [optional]: number of characters in kChannelNameKey */
  165. const CString kChannelNameLengthKey = "channel name length";
  166. /** color (ColorSpec) [optional]: used color for the channel in mixer or track */
  167. const CString kChannelColorKey = "channel color";
  168. /** integer (int64) [optional]: index of the channel in a channel index namespace, start with 1 not * 0! */
  169. const CString kChannelIndexKey = "channel index";
  170. /** integer (int64) [optional]: define the order of the current used index namespace, start with 1 not 0!
  171. For example:
  172. index namespace is "Input" -> order 1,
  173. index namespace is "Channel" -> order 2,
  174. index namespace is "Output" -> order 3 */
  175. const CString kChannelIndexNamespaceOrderKey = "channel index namespace order";
  176. /** string (TChar) [optional]: name of the channel index namespace for example "Input", "Output", "Channel", ... */
  177. const CString kChannelIndexNamespaceKey = "channel index namespace";
  178. /** integer (int64) [optional]: number of characters in kChannelIndexNamespaceKey */
  179. const CString kChannelIndexNamespaceLengthKey = "channel index namespace length";
  180. /** PNG image representation as binary [optional] */
  181. const CString kChannelImageKey = "channel image";
  182. /** integer (int64) [optional]: routing position of the Plug-in in the channel (see ChannelPluginLocation) */
  183. const CString kChannelPluginLocationKey = "channel plugin location";
  184. //------------------------------------------------------------------------
  185. } // namespace ChannelContext
  186. } // namespace Vst
  187. } // namespace Steinberg
  188. //------------------------------------------------------------------------
  189. #include "pluginterfaces/base/falignpop.h"
  190. //------------------------------------------------------------------------