| @@ -49,16 +49,15 @@ FilterConnection::~FilterConnection() | |||
| { | |||
| } | |||
| //============================================================================== | |||
| const int FilterGraph::midiChannelNumber = 0x1000; | |||
| FilterGraph::FilterGraph() | |||
| FilterGraph::FilterGraph (AudioPluginFormatManager& formatManager_) | |||
| : FileBasedDocument (filenameSuffix, | |||
| filenameWildcard, | |||
| "Load a filter graph", | |||
| "Save a filter graph"), | |||
| lastUID (0) | |||
| formatManager (formatManager_), lastUID (0) | |||
| { | |||
| InternalPluginFormat internalFormat; | |||
| @@ -106,8 +105,7 @@ void FilterGraph::addFilter (const PluginDescription* desc, double x, double y) | |||
| { | |||
| String errorMessage; | |||
| AudioPluginInstance* instance | |||
| = AudioPluginFormatManager::getInstance()->createPluginInstance (*desc, errorMessage); | |||
| AudioPluginInstance* instance = formatManager.createPluginInstance (*desc, errorMessage); | |||
| AudioProcessorGraph::Node* node = nullptr; | |||
| @@ -329,8 +327,7 @@ void FilterGraph::createNodeFromXml (const XmlElement& xml) | |||
| String errorMessage; | |||
| AudioPluginInstance* instance | |||
| = AudioPluginFormatManager::getInstance()->createPluginInstance (pd, errorMessage); | |||
| AudioPluginInstance* instance = formatManager.createPluginInstance (pd, errorMessage); | |||
| if (instance == nullptr) | |||
| { | |||
| @@ -67,7 +67,7 @@ class FilterGraph : public FileBasedDocument | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| FilterGraph(); | |||
| FilterGraph (AudioPluginFormatManager& formatManager); | |||
| ~FilterGraph(); | |||
| //============================================================================== | |||
| @@ -126,6 +126,7 @@ public: | |||
| private: | |||
| //============================================================================== | |||
| AudioPluginFormatManager& formatManager; | |||
| AudioProcessorGraph graph; | |||
| AudioProcessorPlayer player; | |||
| @@ -1014,8 +1014,9 @@ private: | |||
| }; | |||
| //============================================================================== | |||
| GraphDocumentComponent::GraphDocumentComponent (AudioDeviceManager* deviceManager_) | |||
| : deviceManager (deviceManager_) | |||
| GraphDocumentComponent::GraphDocumentComponent (AudioPluginFormatManager& formatManager, | |||
| AudioDeviceManager* deviceManager_) | |||
| : graph (formatManager), deviceManager (deviceManager_) | |||
| { | |||
| addAndMakeVisible (graphPanel = new GraphEditorPanel (graph)); | |||
| @@ -83,7 +83,8 @@ class GraphDocumentComponent : public Component | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| GraphDocumentComponent (AudioDeviceManager* deviceManager); | |||
| GraphDocumentComponent (AudioPluginFormatManager& formatManager, | |||
| AudioDeviceManager* deviceManager); | |||
| ~GraphDocumentComponent(); | |||
| //============================================================================== | |||
| @@ -59,9 +59,6 @@ public: | |||
| commandManager = new ApplicationCommandManager(); | |||
| AudioPluginFormatManager::getInstance()->addDefaultFormats(); | |||
| AudioPluginFormatManager::getInstance()->addFormat (new InternalPluginFormat()); | |||
| mainWindow = new MainHostWindow(); | |||
| //mainWindow->setUsingNativeTitleBar (true); | |||
| @@ -32,7 +32,7 @@ | |||
| class MainHostWindow::PluginListWindow : public DocumentWindow | |||
| { | |||
| public: | |||
| PluginListWindow (MainHostWindow& owner_) | |||
| PluginListWindow (MainHostWindow& owner_, AudioPluginFormatManager& formatManager) | |||
| : DocumentWindow ("Available Plugins", Colours::white, | |||
| DocumentWindow::minimiseButton | DocumentWindow::closeButton), | |||
| owner (owner_) | |||
| @@ -40,7 +40,8 @@ public: | |||
| const File deadMansPedalFile (appProperties->getUserSettings() | |||
| ->getFile().getSiblingFile ("RecentlyCrashedPluginsList")); | |||
| setContentOwned (new PluginListComponent (owner.knownPluginList, | |||
| setContentOwned (new PluginListComponent (formatManager, | |||
| owner.knownPluginList, | |||
| deadMansPedalFile, | |||
| appProperties->getUserSettings()), true); | |||
| @@ -75,6 +76,9 @@ MainHostWindow::MainHostWindow() | |||
| : DocumentWindow (JUCEApplication::getInstance()->getApplicationName(), Colours::lightgrey, | |||
| DocumentWindow::allButtons) | |||
| { | |||
| formatManager.addDefaultFormats(); | |||
| formatManager.addFormat (new InternalPluginFormat()); | |||
| ScopedPointer<XmlElement> savedAudioState (appProperties->getUserSettings() | |||
| ->getXmlValue ("audioDeviceState")); | |||
| @@ -84,7 +88,7 @@ MainHostWindow::MainHostWindow() | |||
| setResizeLimits (500, 400, 10000, 10000); | |||
| centreWithSize (800, 600); | |||
| setContentOwned (new GraphDocumentComponent (&deviceManager), false); | |||
| setContentOwned (new GraphDocumentComponent (formatManager, &deviceManager), false); | |||
| restoreWindowStateFromString (appProperties->getUserSettings()->getValue ("mainWindowPos")); | |||
| @@ -378,7 +382,7 @@ bool MainHostWindow::perform (const InvocationInfo& info) | |||
| case CommandIDs::showPluginListEditor: | |||
| if (pluginListWindow == nullptr) | |||
| pluginListWindow = new PluginListWindow (*this); | |||
| pluginListWindow = new PluginListWindow (*this, formatManager); | |||
| pluginListWindow->toFront (true); | |||
| break; | |||
| @@ -455,7 +459,7 @@ void MainHostWindow::filesDropped (const StringArray& files, int x, int y) | |||
| else | |||
| { | |||
| OwnedArray <PluginDescription> typesFound; | |||
| knownPluginList.scanAndAddDragAndDroppedFiles (files, typesFound); | |||
| knownPluginList.scanAndAddDragAndDroppedFiles (formatManager, files, typesFound); | |||
| Point<int> pos (graphEditor->getLocalPoint (this, Point<int> (x, y))); | |||
| @@ -88,6 +88,7 @@ public: | |||
| private: | |||
| //============================================================================== | |||
| AudioDeviceManager deviceManager; | |||
| AudioPluginFormatManager formatManager; | |||
| OwnedArray <PluginDescription> internalTypes; | |||
| KnownPluginList knownPluginList; | |||
| @@ -23,16 +23,8 @@ | |||
| ============================================================================== | |||
| */ | |||
| AudioPluginFormatManager::AudioPluginFormatManager() | |||
| { | |||
| } | |||
| AudioPluginFormatManager::~AudioPluginFormatManager() | |||
| { | |||
| clearSingletonInstance(); | |||
| } | |||
| juce_ImplementSingleton_SingleThreaded (AudioPluginFormatManager); | |||
| AudioPluginFormatManager::AudioPluginFormatManager() {} | |||
| AudioPluginFormatManager::~AudioPluginFormatManager() {} | |||
| //============================================================================== | |||
| void AudioPluginFormatManager::addDefaultFormats() | |||
| @@ -35,7 +35,7 @@ | |||
| @see AudioPluginFormat | |||
| */ | |||
| class JUCE_API AudioPluginFormatManager : public DeletedAtShutdown | |||
| class JUCE_API AudioPluginFormatManager : private DeletedAtShutdown | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| @@ -44,8 +44,6 @@ public: | |||
| /** Destructor. */ | |||
| ~AudioPluginFormatManager(); | |||
| juce_DeclareSingleton_SingleThreaded (AudioPluginFormatManager, false); | |||
| //============================================================================== | |||
| /** Adds any formats that it knows about, e.g. VST. | |||
| */ | |||
| @@ -163,14 +163,15 @@ bool KnownPluginList::scanAndAddFile (const String& fileOrIdentifier, | |||
| return addedOne; | |||
| } | |||
| void KnownPluginList::scanAndAddDragAndDroppedFiles (const StringArray& files, | |||
| void KnownPluginList::scanAndAddDragAndDroppedFiles (AudioPluginFormatManager& formatManager, | |||
| const StringArray& files, | |||
| OwnedArray <PluginDescription>& typesFound) | |||
| { | |||
| for (int i = 0; i < files.size(); ++i) | |||
| { | |||
| for (int j = 0; j < AudioPluginFormatManager::getInstance()->getNumFormats(); ++j) | |||
| for (int j = 0; j < formatManager.getNumFormats(); ++j) | |||
| { | |||
| AudioPluginFormat* const format = AudioPluginFormatManager::getInstance()->getFormat (j); | |||
| AudioPluginFormat* const format = formatManager.getFormat (j); | |||
| if (scanAndAddFile (files[i], true, typesFound, *format)) | |||
| return; | |||
| @@ -190,7 +191,7 @@ void KnownPluginList::scanAndAddDragAndDroppedFiles (const StringArray& files, | |||
| s.add (subFiles.getReference(j).getFullPathName()); | |||
| } | |||
| scanAndAddDragAndDroppedFiles (s, typesFound); | |||
| scanAndAddDragAndDroppedFiles (formatManager, s, typesFound); | |||
| } | |||
| } | |||
| } | |||
| @@ -107,7 +107,8 @@ public: | |||
| If any types are found in the files, their descriptions are returned in the array. | |||
| */ | |||
| void scanAndAddDragAndDroppedFiles (const StringArray& filenames, | |||
| void scanAndAddDragAndDroppedFiles (AudioPluginFormatManager& formatManager, | |||
| const StringArray& filenames, | |||
| OwnedArray <PluginDescription>& typesFound); | |||
| //============================================================================== | |||
| @@ -23,10 +23,12 @@ | |||
| ============================================================================== | |||
| */ | |||
| PluginListComponent::PluginListComponent (KnownPluginList& listToEdit, | |||
| PluginListComponent::PluginListComponent (AudioPluginFormatManager& formatManager_, | |||
| KnownPluginList& listToEdit, | |||
| const File& deadMansPedalFile_, | |||
| PropertiesFile* const propertiesToUse_) | |||
| : list (listToEdit), | |||
| : formatManager (formatManager_), | |||
| list (listToEdit), | |||
| deadMansPedalFile (deadMansPedalFile_), | |||
| optionsButton ("Options..."), | |||
| propertiesToUse (propertiesToUse_) | |||
| @@ -151,7 +153,7 @@ void PluginListComponent::optionsMenuCallback (int result) | |||
| case 7: | |||
| for (int i = list.getNumTypes(); --i >= 0;) | |||
| if (! AudioPluginFormatManager::getInstance()->doesPluginStillExist (*list.getType (i))) | |||
| if (! formatManager.doesPluginStillExist (*list.getType (i))) | |||
| list.removeType (i); | |||
| break; | |||
| @@ -188,9 +190,9 @@ void PluginListComponent::buttonClicked (Button* button) | |||
| menu.addItem (4, TRANS("Sort by manufacturer")); | |||
| menu.addSeparator(); | |||
| for (int i = 0; i < AudioPluginFormatManager::getInstance()->getNumFormats(); ++i) | |||
| for (int i = 0; i < formatManager.getNumFormats(); ++i) | |||
| { | |||
| AudioPluginFormat* const format = AudioPluginFormatManager::getInstance()->getFormat (i); | |||
| AudioPluginFormat* const format = formatManager.getFormat (i); | |||
| if (format->getDefaultLocationsToSearch().getNumPaths() > 0) | |||
| menu.addItem (10 + i, "Scan for new or updated " + format->getName() + " plugins..."); | |||
| @@ -204,7 +206,7 @@ void PluginListComponent::buttonClicked (Button* button) | |||
| void PluginListComponent::timerCallback() | |||
| { | |||
| stopTimer(); | |||
| scanFor (AudioPluginFormatManager::getInstance()->getFormat (typeToScan)); | |||
| scanFor (formatManager.getFormat (typeToScan)); | |||
| } | |||
| bool PluginListComponent::isInterestedInFileDrag (const StringArray& /*files*/) | |||
| @@ -215,7 +217,7 @@ bool PluginListComponent::isInterestedInFileDrag (const StringArray& /*files*/) | |||
| void PluginListComponent::filesDropped (const StringArray& files, int, int) | |||
| { | |||
| OwnedArray <PluginDescription> typesFound; | |||
| list.scanAndAddDragAndDroppedFiles (files, typesFound); | |||
| list.scanAndAddDragAndDroppedFiles (formatManager, files, typesFound); | |||
| } | |||
| void PluginListComponent::scanFor (AudioPluginFormat* format) | |||
| @@ -51,7 +51,8 @@ public: | |||
| The properties file, if supplied, is used to store the user's last search paths. | |||
| */ | |||
| PluginListComponent (KnownPluginList& listToRepresent, | |||
| PluginListComponent (AudioPluginFormatManager& formatManager, | |||
| KnownPluginList& listToRepresent, | |||
| const File& deadMansPedalFile, | |||
| PropertiesFile* propertiesToUse); | |||
| @@ -74,6 +75,7 @@ public: | |||
| private: | |||
| //============================================================================== | |||
| AudioPluginFormatManager& formatManager; | |||
| KnownPluginList& list; | |||
| File deadMansPedalFile; | |||
| ListBox listBox; | |||