MCPcopy Create free account
hub / github.com/DBraun/DawDreamer / loadPlugin

Method loadPlugin

Source/PluginProcessor.cpp:60–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60bool PluginProcessor::loadPlugin(double sampleRate, int samplesPerBlock) {
61 OwnedArray<PluginDescription> pluginDescriptions;
62 KnownPluginList pluginList;
63 AudioPluginFormatManager pluginFormatManager;
64
65 pluginFormatManager.addDefaultFormats();
66
67 for (int i = pluginFormatManager.getNumFormats(); --i >= 0;) {
68 pluginList.scanAndAddFile(String(myPluginPath), true, pluginDescriptions,
69 *pluginFormatManager.getFormat(i));
70 }
71
72 if (myPlugin.get()) {
73 myPlugin.get()->releaseResources();
74 myPlugin.reset();
75 }
76
77 // If there is a problem here first check the preprocessor definitions
78 // in the projucer are sensible - is it set up to scan for plugin's?
79 if (pluginDescriptions.size() <= 0) {
80 throw std::runtime_error("Unable to load plugin.");
81 }
82
83 String errorMessage;
84
85 myPlugin = pluginFormatManager.createPluginInstance(
86 *pluginDescriptions[0], sampleRate, samplesPerBlock, errorMessage);
87
88 if (myPlugin.get() == nullptr) {
89 throw std::runtime_error("PluginProcessor::loadPlugin error: " +
90 errorMessage.toStdString());
91 }
92 // We loaded the plugin.
93
94 auto outputs = myPlugin->getTotalNumOutputChannels();
95
96 if (outputs == 0) {
97 myPlugin->enableAllBuses();
98 myPlugin->disableNonMainBuses();
99 outputs = myPlugin->getTotalNumOutputChannels();
100 }
101 auto inputs = myPlugin->getTotalNumInputChannels();
102
103 ProcessorBase::setBusesLayout(myPlugin->getBusesLayout());
104
105 this->setPlayConfigDetails(inputs, outputs, sampleRate, samplesPerBlock);
106 myPlugin->prepareToPlay(sampleRate, samplesPerBlock);
107 myPlugin->setNonRealtime(true);
108 mySampleRate = sampleRate;
109
110 createParameterLayout();
111
112 {
113 // Process a block of silence a few times to "warm up" the processor.
114 juce::AudioSampleBuffer audioBuffer =
115 AudioSampleBuffer(std::max(inputs, outputs), samplesPerBlock);
116 MidiBuffer emptyMidiBuffer;
117 for (int i = 0; i < 5; i++) {

Callers

nothing calls this directly

Calls 15

maxFunction · 0.85
addDefaultFormatsMethod · 0.80
getNumFormatsMethod · 0.80
scanAndAddFileMethod · 0.80
toStdStringMethod · 0.80
enableAllBusesMethod · 0.80
disableNonMainBusesMethod · 0.80
setPlayConfigDetailsMethod · 0.80
StringFunction · 0.50
getFormatMethod · 0.45
getMethod · 0.45
releaseResourcesMethod · 0.45

Tested by

no test coverage detected