The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

140 lines
6.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. // MSVC does not like it if you override a deprecated method even if you
  21. // keep the deprecation attribute. Other compilers are more forgiving.
  22. JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4996)
  23. //==============================================================================
  24. /**
  25. Base class for an active instance of a plugin.
  26. This derives from the AudioProcessor class, and adds some extra functionality
  27. that helps when wrapping dynamically loaded plugins.
  28. This class is not needed when writing plugins, and you should never need to derive
  29. your own sub-classes from it. The plugin hosting classes use it internally and will
  30. return AudioPluginInstance objects which wrap external plugins.
  31. @see AudioProcessor, AudioPluginFormat
  32. @tags{Audio}
  33. */
  34. class JUCE_API AudioPluginInstance : public AudioProcessor
  35. {
  36. public:
  37. //==============================================================================
  38. /** Destructor.
  39. Make sure that you delete any UI components that belong to this plugin before
  40. deleting the plugin.
  41. */
  42. ~AudioPluginInstance() override = default;
  43. //==============================================================================
  44. /** Fills-in the appropriate parts of this plugin description object. */
  45. virtual void fillInPluginDescription (PluginDescription&) const = 0;
  46. /** Returns a PluginDescription for this plugin.
  47. This is just a convenience method to avoid calling fillInPluginDescription.
  48. */
  49. PluginDescription getPluginDescription() const;
  50. /** Allows retrieval of information related to the inner workings of a particular plugin format,
  51. such as the AEffect* of a VST, or the handle of an AudioUnit.
  52. To use this, create a new class derived from ExtensionsVisitor, and override
  53. each of the visit member functions. If this AudioPluginInstance wraps a VST3 plugin
  54. the visitVST3() member will be called, while if the AudioPluginInstance wraps an
  55. unknown format the visitUnknown() member will be called. The argument of the visit function
  56. can be queried to extract information related to the AudioPluginInstance's implementation.
  57. */
  58. virtual void getExtensions (ExtensionsVisitor&) const;
  59. /** Use the new typesafe visitor-based interface rather than this function.
  60. Returns a pointer to some kind of platform-specific data about the plugin.
  61. E.g. For a VST, this value can be cast to an AEffect*. For an AudioUnit, it can be
  62. cast to an AudioUnit handle.
  63. */
  64. JUCE_DEPRECATED (virtual void* getPlatformSpecificData());
  65. // Rather than using these methods you should call the corresponding methods
  66. // on the AudioProcessorParameter objects returned from getParameters().
  67. // See the implementations of the methods below for some examples of how to
  68. // do this.
  69. //
  70. // In addition to being marked as deprecated these methods will assert on
  71. // the first call.
  72. JUCE_DEPRECATED (String getParameterID (int index) override);
  73. JUCE_DEPRECATED (float getParameter (int parameterIndex) override);
  74. JUCE_DEPRECATED (void setParameter (int parameterIndex, float newValue) override);
  75. JUCE_DEPRECATED (const String getParameterName (int parameterIndex) override);
  76. JUCE_DEPRECATED (String getParameterName (int parameterIndex, int maximumStringLength) override);
  77. JUCE_DEPRECATED (const String getParameterText (int parameterIndex) override);
  78. JUCE_DEPRECATED (String getParameterText (int parameterIndex, int maximumStringLength) override);
  79. JUCE_DEPRECATED (int getParameterNumSteps (int parameterIndex) override);
  80. JUCE_DEPRECATED (bool isParameterDiscrete (int parameterIndex) const override);
  81. JUCE_DEPRECATED (bool isParameterAutomatable (int parameterIndex) const override);
  82. JUCE_DEPRECATED (float getParameterDefaultValue (int parameterIndex) override);
  83. JUCE_DEPRECATED (String getParameterLabel (int parameterIndex) const override);
  84. JUCE_DEPRECATED (bool isParameterOrientationInverted (int parameterIndex) const override);
  85. JUCE_DEPRECATED (bool isMetaParameter (int parameterIndex) const override);
  86. JUCE_DEPRECATED (AudioProcessorParameter::Category getParameterCategory (int parameterIndex) const override);
  87. protected:
  88. //==============================================================================
  89. /** Structure used to describe plugin parameters */
  90. struct Parameter : public AudioProcessorParameter
  91. {
  92. Parameter();
  93. ~Parameter() override;
  94. String getText (float value, int maximumStringLength) const override;
  95. float getValueForText (const String& text) const override;
  96. StringArray onStrings, offStrings;
  97. };
  98. AudioPluginInstance() = default;
  99. AudioPluginInstance (const BusesProperties& ioLayouts) : AudioProcessor (ioLayouts) {}
  100. template <size_t numLayouts>
  101. AudioPluginInstance (const short channelLayoutList[numLayouts][2]) : AudioProcessor (channelLayoutList) {}
  102. private:
  103. void assertOnceOnDeprecatedMethodUse() const noexcept;
  104. static bool deprecationAssertiontriggered;
  105. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioPluginInstance)
  106. };
  107. JUCE_END_IGNORE_WARNINGS_MSVC
  108. } // namespace juce