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.

118 lines
5.2KB

  1. //-----------------------------------------------------------------------------
  2. // Project : VST SDK
  3. //
  4. // Category : Helpers
  5. // Filename : public.sdk/source/vst/vstcomponent.h
  6. // Created by : Steinberg, 04/2005
  7. // Description : Basic VST Plug-in Implementation
  8. //
  9. //-----------------------------------------------------------------------------
  10. // LICENSE
  11. // (c) 2019, Steinberg Media Technologies GmbH, All Rights Reserved
  12. //-----------------------------------------------------------------------------
  13. // Redistribution and use in source and binary forms, with or without modification,
  14. // are permitted provided that the following conditions are met:
  15. //
  16. // * Redistributions of source code must retain the above copyright notice,
  17. // this list of conditions and the following disclaimer.
  18. // * Redistributions in binary form must reproduce the above copyright notice,
  19. // this list of conditions and the following disclaimer in the documentation
  20. // and/or other materials provided with the distribution.
  21. // * Neither the name of the Steinberg Media Technologies nor the names of its
  22. // contributors may be used to endorse or promote products derived from this
  23. // software without specific prior written permission.
  24. //
  25. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  26. // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  27. // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  28. // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  29. // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  30. // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  32. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  33. // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  34. // OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //-----------------------------------------------------------------------------
  36. #pragma once
  37. #include "public.sdk/source/vst/vstcomponentbase.h"
  38. #include "public.sdk/source/vst/vstbus.h"
  39. #include "pluginterfaces/vst/ivstcomponent.h"
  40. //------------------------------------------------------------------------
  41. namespace Steinberg {
  42. namespace Vst {
  43. //------------------------------------------------------------------------
  44. /** Default implementation for a VST 3 Component.
  45. \ingroup vstClasses
  46. Can be used as base class for a VST 3 component implementation. */
  47. //------------------------------------------------------------------------
  48. class Component : public ComponentBase, public IComponent
  49. {
  50. public:
  51. //------------------------------------------------------------------------
  52. /** Constructor */
  53. Component ();
  54. //---Internal Methods-------
  55. /** Sets the controller Class ID associated to its component. */
  56. void setControllerClass (const FUID& cid) { controllerClass = cid; }
  57. /** Removes all Audio Buses. */
  58. tresult removeAudioBusses ();
  59. /** Removes all Event Buses. */
  60. tresult removeEventBusses ();
  61. /** Renames a specific bus. Do not forget to inform the host about this (see \ref
  62. * IComponentHandler::restartComponent (kIoTitlesChanged)). */
  63. tresult renameBus (MediaType type, BusDirection dir, int32 index, const String128 newName);
  64. //---from IComponent--------
  65. tresult PLUGIN_API getControllerClassId (TUID classID) SMTG_OVERRIDE;
  66. tresult PLUGIN_API setIoMode (IoMode mode) SMTG_OVERRIDE;
  67. int32 PLUGIN_API getBusCount (MediaType type, BusDirection dir) SMTG_OVERRIDE;
  68. tresult PLUGIN_API getBusInfo (MediaType type, BusDirection dir, int32 index, BusInfo& info) SMTG_OVERRIDE;
  69. tresult PLUGIN_API getRoutingInfo (RoutingInfo& inInfo, RoutingInfo& outInfo) SMTG_OVERRIDE;
  70. tresult PLUGIN_API activateBus (MediaType type, BusDirection dir, int32 index, TBool state) SMTG_OVERRIDE;
  71. tresult PLUGIN_API setActive (TBool state) SMTG_OVERRIDE;
  72. tresult PLUGIN_API setState (IBStream* state) SMTG_OVERRIDE;
  73. tresult PLUGIN_API getState (IBStream* state) SMTG_OVERRIDE;
  74. //---from ComponentBase------
  75. tresult PLUGIN_API initialize (FUnknown* context) SMTG_OVERRIDE;
  76. tresult PLUGIN_API terminate () SMTG_OVERRIDE;
  77. //---Interface---------
  78. OBJ_METHODS (Component, ComponentBase)
  79. DEFINE_INTERFACES
  80. DEF_INTERFACE (IComponent)
  81. END_DEFINE_INTERFACES (ComponentBase)
  82. REFCOUNT_METHODS (ComponentBase)
  83. //------------------------------------------------------------------------
  84. protected:
  85. FUID controllerClass;
  86. BusList audioInputs;
  87. BusList audioOutputs;
  88. BusList eventInputs;
  89. BusList eventOutputs;
  90. BusList* getBusList (MediaType type, BusDirection dir);
  91. tresult removeAllBusses ();
  92. };
  93. //------------------------------------------------------------------------
  94. // some Helper functions....
  95. //------------------------------------------------------------------------
  96. /** Gets the channel index of a given speaker in a arrangement, returns kResultFalse if speaker not
  97. * part of the arrangement else returns kResultTrue. */
  98. tresult getSpeakerChannelIndex (SpeakerArrangement arrangement, uint64 speaker, int32& channel);
  99. //------------------------------------------------------------------------
  100. } // namespace Vst
  101. } // namespace Steinberg