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.

92 lines
3.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. #pragma once
  14. #include "../UI/PluginWindow.h"
  15. //==============================================================================
  16. /**
  17. A collection of plugins and some connections between them.
  18. */
  19. class PluginGraph : public FileBasedDocument,
  20. public AudioProcessorListener,
  21. private ChangeListener
  22. {
  23. public:
  24. //==============================================================================
  25. PluginGraph (AudioPluginFormatManager&);
  26. ~PluginGraph() override;
  27. //==============================================================================
  28. using NodeID = AudioProcessorGraph::NodeID;
  29. void addPlugin (const PluginDescription&, Point<double>);
  30. AudioProcessorGraph::Node::Ptr getNodeForName (const String& name) const;
  31. void setNodePosition (NodeID, Point<double>);
  32. Point<double> getNodePosition (NodeID) const;
  33. //==============================================================================
  34. void clear();
  35. PluginWindow* getOrCreateWindowFor (AudioProcessorGraph::Node*, PluginWindow::Type);
  36. void closeCurrentlyOpenWindowsFor (AudioProcessorGraph::NodeID);
  37. bool closeAnyOpenPluginWindows();
  38. //==============================================================================
  39. void audioProcessorParameterChanged (AudioProcessor*, int, float) override {}
  40. void audioProcessorChanged (AudioProcessor*) override { changed(); }
  41. //==============================================================================
  42. std::unique_ptr<XmlElement> createXml() const;
  43. void restoreFromXml (const XmlElement&);
  44. static const char* getFilenameSuffix() { return ".filtergraph"; }
  45. static const char* getFilenameWildcard() { return "*.filtergraph"; }
  46. //==============================================================================
  47. void newDocument();
  48. String getDocumentTitle() override;
  49. Result loadDocument (const File& file) override;
  50. Result saveDocument (const File& file) override;
  51. File getLastDocumentOpened() override;
  52. void setLastDocumentOpened (const File& file) override;
  53. static File getDefaultGraphDocumentOnMobile();
  54. //==============================================================================
  55. AudioProcessorGraph graph;
  56. private:
  57. //==============================================================================
  58. AudioPluginFormatManager& formatManager;
  59. OwnedArray<PluginWindow> activePluginWindows;
  60. NodeID lastUID;
  61. NodeID getNextUID() noexcept;
  62. void createNodeFromXml (const XmlElement&);
  63. void addPluginCallback (std::unique_ptr<AudioPluginInstance>, const String& error, Point<double>);
  64. void changeListenerCallback (ChangeBroadcaster*) override;
  65. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginGraph)
  66. };