VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_audio_processors / scanning / juce_PluginDirectoryScanner.h
blob30f532c954394a2561b1afaf7df7dba2f05381f6
1 /*
2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
23 ==============================================================================
26 namespace juce
29 //==============================================================================
30 /**
31 Scans a directory for plugins, and adds them to a KnownPluginList.
33 To use one of these, create it and call scanNextFile() repeatedly, until
34 it returns false.
36 @tags{Audio}
38 class JUCE_API PluginDirectoryScanner
40 public:
41 //==============================================================================
42 /**
43 Creates a scanner.
45 @param listToAddResultsTo this will get the new types added to it.
46 @param formatToLookFor this is the type of format that you want to look for
47 @param directoriesToSearch the path to search
48 @param searchRecursively true to search recursively
49 @param deadMansPedalFile if this isn't File(), then it will be used as a file
50 to store the names of any plugins that crash during
51 initialisation. If there are any plugins listed in it,
52 then these will always be scanned after all other possible
53 files have been tried - in this way, even if there's a few
54 dodgy plugins in your path, then a couple of rescans
55 will still manage to find all the proper plugins.
56 It's probably best to choose a file in the user's
57 application data directory (alongside your app's
58 settings file) for this. The file format it uses
59 is just a list of filenames of the modules that
60 failed.
61 @param allowPluginsWhichRequireAsynchronousInstantiation
62 If this is false then the scanner will exclude plug-ins
63 asynchronous creation - such as AUv3 plug-ins.
65 PluginDirectoryScanner (KnownPluginList& listToAddResultsTo,
66 AudioPluginFormat& formatToLookFor,
67 FileSearchPath directoriesToSearch,
68 bool searchRecursively,
69 const File& deadMansPedalFile,
70 bool allowPluginsWhichRequireAsynchronousInstantiation = false);
72 /** Destructor. */
73 ~PluginDirectoryScanner();
75 //==============================================================================
76 /** Sets a specific list of filesOrIdentifiersToScan to scan.
77 N.B. This list must match the format passed to the constructor.
78 @see AudioPluginFormat::searchPathsForPlugins
80 void setFilesOrIdentifiersToScan (const StringArray& filesOrIdentifiersToScan);
82 /** Tries the next likely-looking file.
84 If dontRescanIfAlreadyInList is true, then the file will only be loaded and
85 re-tested if it's not already in the list, or if the file's modification
86 time has changed since the list was created. If dontRescanIfAlreadyInList is
87 false, the file will always be reloaded and tested.
88 The nameOfPluginBeingScanned will be updated to the name of the plugin being
89 scanned before the scan starts.
91 Returns false when there are no more files to try.
93 bool scanNextFile (bool dontRescanIfAlreadyInList,
94 String& nameOfPluginBeingScanned);
96 /** Skips over the next file without scanning it.
97 Returns false when there are no more files to try.
99 bool skipNextFile();
101 /** Returns the description of the plugin that will be scanned during the next
102 call to scanNextFile().
104 This is handy if you want to show the user which file is currently getting
105 scanned.
107 String getNextPluginFileThatWillBeScanned() const;
109 /** Returns the estimated progress, between 0 and 1. */
110 float getProgress() const { return progress; }
112 /** This returns a list of all the filenames of things that looked like being
113 a plugin file, but which failed to open for some reason.
115 const StringArray& getFailedFiles() const noexcept { return failedFiles; }
117 /** Reads the given dead-mans-pedal file and applies its contents to the list. */
118 static void applyBlacklistingsFromDeadMansPedal (KnownPluginList& listToApplyTo,
119 const File& deadMansPedalFile);
121 private:
122 //==============================================================================
123 KnownPluginList& list;
124 AudioPluginFormat& format;
125 StringArray filesOrIdentifiersToScan;
126 File deadMansPedalFile;
127 StringArray failedFiles;
128 Atomic<int> nextIndex;
129 std::atomic<float> progress { 0.0f };
130 const bool allowAsync;
132 void updateProgress();
133 void setDeadMansPedalFile (const StringArray& newContents);
135 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginDirectoryScanner)
138 } // namespace juce