mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added some static methods to all the AudioPluginFormat classes to allow their type names to be retrieved without an instance being created. Also added a method AudioPluginFormatManager::getFormats() for easier iteration of formats
This commit is contained in:
parent
f950061ed5
commit
6ba85cb46c
8 changed files with 33 additions and 43 deletions
|
|
@ -74,14 +74,14 @@ void AudioPluginFormatManager::addDefaultFormats()
|
|||
#endif
|
||||
}
|
||||
|
||||
int AudioPluginFormatManager::getNumFormats()
|
||||
{
|
||||
return formats.size();
|
||||
}
|
||||
int AudioPluginFormatManager::getNumFormats() const { return formats.size(); }
|
||||
AudioPluginFormat* AudioPluginFormatManager::getFormat (int index) const { return formats[index]; }
|
||||
|
||||
AudioPluginFormat* AudioPluginFormatManager::getFormat (int index)
|
||||
Array<AudioPluginFormat*> AudioPluginFormatManager::getFormats() const
|
||||
{
|
||||
return formats[index];
|
||||
Array<AudioPluginFormat*> a;
|
||||
a.addArray (formats);
|
||||
return a;
|
||||
}
|
||||
|
||||
void AudioPluginFormatManager::addFormat (AudioPluginFormat* format)
|
||||
|
|
|
|||
|
|
@ -52,12 +52,15 @@ public:
|
|||
/** Returns the number of types of format that are available.
|
||||
Use getFormat() to get one of them.
|
||||
*/
|
||||
int getNumFormats();
|
||||
int getNumFormats() const;
|
||||
|
||||
/** Returns one of the available formats.
|
||||
@see getNumFormats
|
||||
*/
|
||||
AudioPluginFormat* getFormat (int index);
|
||||
AudioPluginFormat* getFormat (int index) const;
|
||||
|
||||
/** Returns a list of all the registered formats. */
|
||||
Array<AudioPluginFormat*> getFormats() const;
|
||||
|
||||
//==============================================================================
|
||||
/** Adds a format to the list.
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ public:
|
|||
~AudioUnitPluginFormat() override;
|
||||
|
||||
//==============================================================================
|
||||
String getName() const override { return "AudioUnit"; }
|
||||
static String getFormatName() { return "AudioUnit"; }
|
||||
String getName() const override { return getFormatName(); }
|
||||
bool canScanForPlugins() const override { return true; }
|
||||
bool isTrivialToScan() const override { return false; }
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ public:
|
|||
~LADSPAPluginFormat() override;
|
||||
|
||||
//==============================================================================
|
||||
String getName() const override { return "LADSPA"; }
|
||||
static String getFormatName() { return "LADSPA"; }
|
||||
String getName() const override { return getFormatName(); }
|
||||
bool canScanForPlugins() const override { return true; }
|
||||
bool isTrivialToScan() const override { return false; }
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ public:
|
|||
static bool setStateFromVSTPresetFile (AudioPluginInstance*, const MemoryBlock&);
|
||||
|
||||
//==============================================================================
|
||||
String getName() const override { return "VST3"; }
|
||||
static String getFormatName() { return "VST3"; }
|
||||
String getName() const override { return getFormatName(); }
|
||||
bool canScanForPlugins() const override { return true; }
|
||||
bool isTrivialToScan() const override { return false; }
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ public:
|
|||
static AudioPluginInstance* getPluginInstanceFromVstEffectInterface (void* aEffect);
|
||||
|
||||
//==============================================================================
|
||||
String getName() const override { return "VST"; }
|
||||
static String getFormatName() { return "VST"; }
|
||||
String getName() const override { return getFormatName(); }
|
||||
bool canScanForPlugins() const override { return true; }
|
||||
bool isTrivialToScan() const override { return false; }
|
||||
|
||||
|
|
|
|||
|
|
@ -211,10 +211,8 @@ void KnownPluginList::scanAndAddDragAndDroppedFiles (AudioPluginFormatManager& f
|
|||
{
|
||||
bool found = false;
|
||||
|
||||
for (int j = 0; j < formatManager.getNumFormats(); ++j)
|
||||
for (auto format : formatManager.getFormats())
|
||||
{
|
||||
auto* format = formatManager.getFormat (j);
|
||||
|
||||
if (format->fileMightContainThisPluginType (filenameOrID)
|
||||
&& scanAndAddFile (filenameOrID, true, typesFound, *format))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -295,23 +295,15 @@ PopupMenu PluginListComponent::createOptionsMenu()
|
|||
|
||||
menu.addSeparator();
|
||||
|
||||
for (int i = 0; i < formatManager.getNumFormats(); ++i)
|
||||
{
|
||||
if (auto format = formatManager.getFormat(i))
|
||||
{
|
||||
if (format->canScanForPlugins())
|
||||
{
|
||||
menu.addItem (PopupMenu::Item ("Remove all " + format->getName() + " plug-ins")
|
||||
.setEnabled (! list.getTypesForFormat (*format).isEmpty())
|
||||
.setAction ([this, i]
|
||||
{
|
||||
if (auto f = formatManager.getFormat (i))
|
||||
for (auto& pd : list.getTypesForFormat (*f))
|
||||
list.removeType (pd);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto format : formatManager.getFormats())
|
||||
if (format->canScanForPlugins())
|
||||
menu.addItem (PopupMenu::Item ("Remove all " + format->getName() + " plug-ins")
|
||||
.setEnabled (! list.getTypesForFormat (*format).isEmpty())
|
||||
.setAction ([this, format]
|
||||
{
|
||||
for (auto& pd : list.getTypesForFormat (*format))
|
||||
list.removeType (pd);
|
||||
}));
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
|
|
@ -332,17 +324,10 @@ PopupMenu PluginListComponent::createOptionsMenu()
|
|||
|
||||
menu.addSeparator();
|
||||
|
||||
for (int i = 0; i < formatManager.getNumFormats(); ++i)
|
||||
{
|
||||
if (auto format = formatManager.getFormat(i))
|
||||
if (format->canScanForPlugins())
|
||||
menu.addItem (PopupMenu::Item ("Scan for new or updated " + format->getName() + " plug-ins")
|
||||
.setAction ([this, i]
|
||||
{
|
||||
if (auto f = formatManager.getFormat (i))
|
||||
scanFor (*f);
|
||||
}));
|
||||
}
|
||||
for (auto format : formatManager.getFormats())
|
||||
if (format->canScanForPlugins())
|
||||
menu.addItem (PopupMenu::Item ("Scan for new or updated " + format->getName() + " plug-ins")
|
||||
.setAction ([this, format] { scanFor (*format); }));
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue