Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / src / audio / plugin_host / juce_AudioPluginFormatManager.cpp
blob673541260c432ba6e7c8914a076895344c5cf206
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../../core/juce_StandardHeader.h"
28 BEGIN_JUCE_NAMESPACE
30 #include "juce_AudioPluginFormatManager.h"
31 #include "juce_PluginDescription.h"
32 #include "../../text/juce_LocalisedStrings.h"
34 #include "formats/juce_VSTPluginFormat.h"
35 #include "formats/juce_AudioUnitPluginFormat.h"
36 #include "formats/juce_DirectXPluginFormat.h"
37 #include "formats/juce_LADSPAPluginFormat.h"
40 //==============================================================================
41 AudioPluginFormatManager::AudioPluginFormatManager()
45 AudioPluginFormatManager::~AudioPluginFormatManager()
47 clearSingletonInstance();
50 juce_ImplementSingleton_SingleThreaded (AudioPluginFormatManager);
52 //==============================================================================
53 void AudioPluginFormatManager::addDefaultFormats()
55 #if JUCE_DEBUG
56 // you should only call this method once!
57 for (int i = formats.size(); --i >= 0;)
59 #if JUCE_PLUGINHOST_VST && ! (JUCE_MAC && JUCE_64BIT)
60 jassert (dynamic_cast <VSTPluginFormat*> (formats[i]) == nullptr);
61 #endif
63 #if JUCE_PLUGINHOST_AU && JUCE_MAC
64 jassert (dynamic_cast <AudioUnitPluginFormat*> (formats[i]) == nullptr);
65 #endif
67 #if JUCE_PLUGINHOST_DX && JUCE_WINDOWS
68 jassert (dynamic_cast <DirectXPluginFormat*> (formats[i]) == nullptr);
69 #endif
71 #if JUCE_PLUGINHOST_LADSPA && JUCE_LINUX
72 jassert (dynamic_cast <LADSPAPluginFormat*> (formats[i]) == nullptr);
73 #endif
75 #endif
77 #if JUCE_PLUGINHOST_AU && JUCE_MAC
78 formats.add (new AudioUnitPluginFormat());
79 #endif
81 #if JUCE_PLUGINHOST_VST && ! (JUCE_MAC && JUCE_64BIT)
82 formats.add (new VSTPluginFormat());
83 #endif
85 #if JUCE_PLUGINHOST_DX && JUCE_WINDOWS
86 formats.add (new DirectXPluginFormat());
87 #endif
89 #if JUCE_PLUGINHOST_LADSPA && JUCE_LINUX
90 formats.add (new LADSPAPluginFormat());
91 #endif
94 int AudioPluginFormatManager::getNumFormats()
96 return formats.size();
99 AudioPluginFormat* AudioPluginFormatManager::getFormat (const int index)
101 return formats [index];
104 void AudioPluginFormatManager::addFormat (AudioPluginFormat* const format)
106 formats.add (format);
109 AudioPluginInstance* AudioPluginFormatManager::createPluginInstance (const PluginDescription& description,
110 String& errorMessage) const
112 AudioPluginInstance* result = nullptr;
114 for (int i = 0; i < formats.size(); ++i)
116 result = formats.getUnchecked(i)->createInstanceFromDescription (description);
118 if (result != nullptr)
119 break;
122 if (result == nullptr)
124 if (! doesPluginStillExist (description))
125 errorMessage = TRANS ("This plug-in file no longer exists");
126 else
127 errorMessage = TRANS ("This plug-in failed to load correctly");
130 return result;
133 bool AudioPluginFormatManager::doesPluginStillExist (const PluginDescription& description) const
135 for (int i = 0; i < formats.size(); ++i)
136 if (formats.getUnchecked(i)->getName() == description.pluginFormatName)
137 return formats.getUnchecked(i)->doesPluginStillExist (description);
139 return false;
143 END_JUCE_NAMESPACE