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.

111 lines
4.6KB

  1. //-----------------------------------------------------------------------------
  2. // Project : VST SDK
  3. //
  4. // Category : Helpers
  5. // Filename : public.sdk/source/vst/vstcomponentbase.h
  6. // Created by : Steinberg, 05/2005
  7. // Description : Base class for Component and Edit Controller
  8. //
  9. //-----------------------------------------------------------------------------
  10. // LICENSE
  11. // (c) 2021, 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 "pluginterfaces/base/ipluginbase.h"
  38. #include "pluginterfaces/vst/ivstmessage.h"
  39. #include "pluginterfaces/vst/ivsthostapplication.h"
  40. #include "base/source/fobject.h"
  41. //------------------------------------------------------------------------
  42. namespace Steinberg {
  43. namespace Vst {
  44. //------------------------------------------------------------------------
  45. /** Base class for VST 3 Component and Edit Controller.
  46. \ingroup vstClasses
  47. */
  48. class ComponentBase: public FObject,
  49. public IPluginBase,
  50. public IConnectionPoint
  51. {
  52. public:
  53. //------------------------------------------------------------------------
  54. ComponentBase ();
  55. ~ComponentBase () override;
  56. //--- Internal Methods------
  57. /** Returns the hostContext (set by the host during initialize call). */
  58. FUnknown* getHostContext () const { return hostContext; }
  59. /** Returns the peer for the messaging communication (you can only use IConnectionPoint::notify
  60. * for communicate between peers, do not try to cast peerConnection. */
  61. IConnectionPoint* getPeer () const { return peerConnection; }
  62. /** Allocates a message instance (do not forget to release it). */
  63. IMessage* allocateMessage () const;
  64. /** Sends the given message to the peer. */
  65. tresult sendMessage (IMessage* message) const;
  66. /** Sends a simple text message to the peer (max 255 characters).
  67. Text is interpreted as UTF-8. */
  68. tresult sendTextMessage (const char8* text) const;
  69. /** Sends a message with a given ID without any other payload. */
  70. tresult sendMessageID (const char8* messageID) const;
  71. /** Receives a simple text message from the peer (max 255 characters). Text is UTF-8 encoded. */
  72. virtual tresult receiveText (const char8* text);
  73. //---from IPluginBase------
  74. tresult PLUGIN_API initialize (FUnknown* context) SMTG_OVERRIDE;
  75. tresult PLUGIN_API terminate () SMTG_OVERRIDE;
  76. //---from IConnectionPoint-----------
  77. tresult PLUGIN_API connect (IConnectionPoint* other) SMTG_OVERRIDE;
  78. tresult PLUGIN_API disconnect (IConnectionPoint* other) SMTG_OVERRIDE;
  79. tresult PLUGIN_API notify (IMessage* message) SMTG_OVERRIDE;
  80. //---Interface------
  81. OBJ_METHODS (ComponentBase, FObject)
  82. DEFINE_INTERFACES
  83. DEF_INTERFACE (IPluginBase)
  84. DEF_INTERFACE (IConnectionPoint)
  85. END_DEFINE_INTERFACES (FObject)
  86. REFCOUNT_METHODS (FObject)
  87. //------------------------------------------------------------------------
  88. protected:
  89. IPtr<FUnknown> hostContext;
  90. IPtr<IConnectionPoint> peerConnection;
  91. };
  92. //------------------------------------------------------------------------
  93. } // namespace Vst
  94. } // namespace Steinberg