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.

133 lines
5.1KB

  1. /*
  2. * Juce Internal Filters
  3. * Copyright (c) 2013 Raw Material Software Ltd.
  4. * Copyright (C) 2014 Filipe Coelho <falktx@falktx.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. */
  18. #ifndef JUCE_INTERNAL_FILTERS_HPP_INCLUDED
  19. #define JUCE_INTERNAL_FILTERS_HPP_INCLUDED
  20. #include "juce_audio_processors.h"
  21. // -----------------------------------------------------------------------
  22. namespace juce {
  23. class InternalPluginFormat : public AudioPluginFormat
  24. {
  25. public:
  26. enum InternalFilterType
  27. {
  28. audioInputFilter = 0,
  29. audioOutputFilter,
  30. midiInputFilter,
  31. midiOutputFilter,
  32. endOfFilterTypes
  33. };
  34. InternalPluginFormat()
  35. {
  36. {
  37. AudioProcessorGraph::AudioGraphIOProcessor p(AudioProcessorGraph::AudioGraphIOProcessor::audioOutputNode);
  38. p.fillInPluginDescription(audioOutDesc);
  39. }
  40. {
  41. AudioProcessorGraph::AudioGraphIOProcessor p(AudioProcessorGraph::AudioGraphIOProcessor::audioInputNode);
  42. p.fillInPluginDescription(audioInDesc);
  43. }
  44. {
  45. AudioProcessorGraph::AudioGraphIOProcessor p(AudioProcessorGraph::AudioGraphIOProcessor::midiInputNode);
  46. p.fillInPluginDescription(midiInDesc);
  47. }
  48. {
  49. AudioProcessorGraph::AudioGraphIOProcessor p(AudioProcessorGraph::AudioGraphIOProcessor::midiOutputNode);
  50. p.fillInPluginDescription(midiOutDesc);
  51. }
  52. }
  53. // -------------------------------------------------------------------
  54. const PluginDescription* getDescriptionFor(const InternalFilterType type)
  55. {
  56. switch (type)
  57. {
  58. case audioInputFilter:
  59. return &audioInDesc;
  60. case audioOutputFilter:
  61. return &audioOutDesc;
  62. case midiInputFilter:
  63. return &midiInDesc;
  64. case midiOutputFilter:
  65. return &midiOutDesc;
  66. default:
  67. return nullptr;
  68. }
  69. }
  70. void getAllTypes(OwnedArray <PluginDescription>& results) override
  71. {
  72. for (int i = 0; i < (int) endOfFilterTypes; ++i)
  73. results.add(new PluginDescription(*getDescriptionFor((InternalFilterType)i)));
  74. }
  75. AudioPluginInstance* createInstanceFromDescription(const PluginDescription& desc, double, int) override
  76. {
  77. if (desc.name == audioOutDesc.name)
  78. return new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioOutputNode);
  79. if (desc.name == audioInDesc.name)
  80. return new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioInputNode);
  81. if (desc.name == midiInDesc.name)
  82. return new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::midiInputNode);
  83. if (desc.name == midiOutDesc.name)
  84. return new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::midiOutputNode);
  85. return nullptr;
  86. }
  87. // -------------------------------------------------------------------
  88. String getName() const override { return "Internal"; }
  89. bool fileMightContainThisPluginType(const String&) override { return false; }
  90. FileSearchPath getDefaultLocationsToSearch() override { return FileSearchPath(); }
  91. bool canScanForPlugins() const override { return false; }
  92. bool doesPluginStillExist(const PluginDescription&) override { return true; }
  93. String getNameOfPluginFromIdentifier(const String& fileOrIdentifier) override { return fileOrIdentifier; }
  94. bool pluginNeedsRescanning(const PluginDescription&) override { return false; }
  95. StringArray searchPathsForPlugins(const FileSearchPath&, bool) override { return StringArray(); }
  96. void findAllTypesForFile(OwnedArray <PluginDescription>&, const String&) override {}
  97. // -------------------------------------------------------------------
  98. private:
  99. PluginDescription audioInDesc;
  100. PluginDescription audioOutDesc;
  101. PluginDescription midiInDesc;
  102. PluginDescription midiOutDesc;
  103. };
  104. } // namespace juce
  105. typedef juce::InternalPluginFormat JuceInternalPluginFormat;
  106. // -----------------------------------------------------------------------
  107. #endif // JUCE_INTERNAL_FILTERS_HPP_INCLUDED