Update juce_StandaloneFilterWindow.h
JUCE 5.4.7 compatibility update
This commit is contained in:
parent
1f5fb7b33b
commit
7cf812a9bd
1 changed files with 77 additions and 63 deletions
140
Modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h
Executable file → Normal file
140
Modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h
Executable file → Normal file
|
@ -42,7 +42,8 @@ namespace juce
|
||||||
@tags{Audio}
|
@tags{Audio}
|
||||||
*/
|
*/
|
||||||
class StandalonePluginHolder : private AudioIODeviceCallback,
|
class StandalonePluginHolder : private AudioIODeviceCallback,
|
||||||
private Timer
|
private Timer,
|
||||||
|
private Value::Listener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
@ -72,15 +73,17 @@ public:
|
||||||
#if JUCE_ANDROID || JUCE_IOS
|
#if JUCE_ANDROID || JUCE_IOS
|
||||||
bool shouldAutoOpenMidiDevices = true
|
bool shouldAutoOpenMidiDevices = true
|
||||||
#else
|
#else
|
||||||
bool shouldAutoOpenMidiDevices = false
|
bool shouldAutoOpenMidiDevices = true
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
|
|
||||||
: settings (settingsToUse, takeOwnershipOfSettings),
|
: settings (settingsToUse, takeOwnershipOfSettings),
|
||||||
channelConfiguration (channels),
|
channelConfiguration (channels),
|
||||||
shouldMuteInput (! isInterAppAudioConnected()),
|
|
||||||
autoOpenMidiDevices (shouldAutoOpenMidiDevices)
|
autoOpenMidiDevices (shouldAutoOpenMidiDevices)
|
||||||
{
|
{
|
||||||
|
shouldMuteInput.addListener (this);
|
||||||
|
shouldMuteInput = ! isInterAppAudioConnected();
|
||||||
|
|
||||||
createPlugin();
|
createPlugin();
|
||||||
|
|
||||||
auto inChannels = (channelConfiguration.size() > 0 ? channelConfiguration[0].numIns
|
auto inChannels = (channelConfiguration.size() > 0 ? channelConfiguration[0].numIns
|
||||||
|
@ -109,7 +112,7 @@ public:
|
||||||
startTimer (500);
|
startTimer (500);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~StandalonePluginHolder()
|
virtual ~StandalonePluginHolder() override
|
||||||
{
|
{
|
||||||
stopTimer();
|
stopTimer();
|
||||||
|
|
||||||
|
@ -158,6 +161,7 @@ public:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
Value& getMuteInputValue() { return shouldMuteInput; }
|
Value& getMuteInputValue() { return shouldMuteInput; }
|
||||||
bool getProcessorHasPotentialFeedbackLoop() const { return processorHasPotentialFeedbackLoop; }
|
bool getProcessorHasPotentialFeedbackLoop() const { return processorHasPotentialFeedbackLoop; }
|
||||||
|
void valueChanged (Value& value) override { muteInput = (bool) value.getValue(); }
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
File getLastFile() const
|
File getLastFile() const
|
||||||
|
@ -251,38 +255,29 @@ public:
|
||||||
{
|
{
|
||||||
DialogWindow::LaunchOptions o;
|
DialogWindow::LaunchOptions o;
|
||||||
|
|
||||||
int minNumInputs = std::numeric_limits<int>::max(), maxNumInputs = 0,
|
int maxNumInputs = 0, maxNumOutputs = 0;
|
||||||
minNumOutputs = std::numeric_limits<int>::max(), maxNumOutputs = 0;
|
|
||||||
|
|
||||||
auto updateMinAndMax = [] (int newValue, int& minValue, int& maxValue)
|
|
||||||
{
|
|
||||||
minValue = jmin (minValue, newValue);
|
|
||||||
maxValue = jmax (maxValue, newValue);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (channelConfiguration.size() > 0)
|
if (channelConfiguration.size() > 0)
|
||||||
{
|
{
|
||||||
auto defaultConfig = channelConfiguration.getReference (0);
|
auto& defaultConfig = channelConfiguration.getReference (0);
|
||||||
updateMinAndMax ((int) defaultConfig.numIns, minNumInputs, maxNumInputs);
|
|
||||||
updateMinAndMax ((int) defaultConfig.numOuts, minNumOutputs, maxNumOutputs);
|
maxNumInputs = jmax (0, (int) defaultConfig.numIns);
|
||||||
|
maxNumOutputs = jmax (0, (int) defaultConfig.numOuts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto* bus = processor->getBus (true, 0))
|
if (auto* bus = processor->getBus (true, 0))
|
||||||
updateMinAndMax (bus->getDefaultLayout().size(), minNumInputs, maxNumInputs);
|
maxNumInputs = jmax (0, bus->getDefaultLayout().size());
|
||||||
|
|
||||||
if (auto* bus = processor->getBus (false, 0))
|
if (auto* bus = processor->getBus (false, 0))
|
||||||
updateMinAndMax (bus->getDefaultLayout().size(), minNumOutputs, maxNumOutputs);
|
maxNumOutputs = jmax (0, bus->getDefaultLayout().size());
|
||||||
|
|
||||||
minNumInputs = jmin (minNumInputs, maxNumInputs);
|
o.content.setOwned (new SettingsComponent (*this, deviceManager, maxNumInputs, maxNumOutputs));
|
||||||
minNumOutputs = jmin (minNumOutputs, maxNumOutputs);
|
#if JUCE_MAC
|
||||||
|
|
||||||
o.content.setOwned (new SettingsComponent (*this, deviceManager,
|
|
||||||
minNumInputs,
|
|
||||||
maxNumInputs,
|
|
||||||
minNumOutputs,
|
|
||||||
maxNumOutputs));
|
|
||||||
o.content->setSize (500, 240);
|
o.content->setSize (500, 240);
|
||||||
|
#endif
|
||||||
|
#if ! JUCE_MAC
|
||||||
|
o.content->setSize (500, 340);
|
||||||
|
#endif
|
||||||
o.dialogTitle = TRANS("Audio/MIDI Settings");
|
o.dialogTitle = TRANS("Audio/MIDI Settings");
|
||||||
o.dialogBackgroundColour = o.content->getLookAndFeel().findColour (ResizableWindow::backgroundColourId);
|
o.dialogBackgroundColour = o.content->getLookAndFeel().findColour (ResizableWindow::backgroundColourId);
|
||||||
o.escapeKeyTriggersCloseButton = true;
|
o.escapeKeyTriggersCloseButton = true;
|
||||||
|
@ -296,7 +291,7 @@ public:
|
||||||
{
|
{
|
||||||
if (settings != nullptr)
|
if (settings != nullptr)
|
||||||
{
|
{
|
||||||
std::unique_ptr<XmlElement> xml (deviceManager.createStateXml());
|
auto xml = deviceManager.createStateXml();
|
||||||
|
|
||||||
settings->setValue ("audioSetup", xml.get());
|
settings->setValue ("audioSetup", xml.get());
|
||||||
|
|
||||||
|
@ -314,7 +309,7 @@ public:
|
||||||
|
|
||||||
if (settings != nullptr)
|
if (settings != nullptr)
|
||||||
{
|
{
|
||||||
savedState.reset (settings->getXmlValue ("audioSetup"));
|
savedState = settings->getXmlValue ("audioSetup");
|
||||||
|
|
||||||
#if ! (JUCE_IOS || JUCE_ANDROID)
|
#if ! (JUCE_IOS || JUCE_ANDROID)
|
||||||
shouldMuteInput.setValue (settings->getBoolValue ("shouldMuteInput", true));
|
shouldMuteInput.setValue (settings->getBoolValue ("shouldMuteInput", true));
|
||||||
|
@ -406,12 +401,13 @@ public:
|
||||||
|
|
||||||
// avoid feedback loop by default
|
// avoid feedback loop by default
|
||||||
bool processorHasPotentialFeedbackLoop = true;
|
bool processorHasPotentialFeedbackLoop = true;
|
||||||
|
std::atomic<bool> muteInput { true };
|
||||||
Value shouldMuteInput;
|
Value shouldMuteInput;
|
||||||
AudioBuffer<float> emptyBuffer;
|
AudioBuffer<float> emptyBuffer;
|
||||||
bool autoOpenMidiDevices;
|
bool autoOpenMidiDevices;
|
||||||
|
|
||||||
std::unique_ptr<AudioDeviceManager::AudioDeviceSetup> options;
|
std::unique_ptr<AudioDeviceManager::AudioDeviceSetup> options;
|
||||||
StringArray lastMidiDevices;
|
Array<MidiDeviceInfo> lastMidiDevices;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
@ -420,16 +416,14 @@ private:
|
||||||
public:
|
public:
|
||||||
SettingsComponent (StandalonePluginHolder& pluginHolder,
|
SettingsComponent (StandalonePluginHolder& pluginHolder,
|
||||||
AudioDeviceManager& deviceManagerToUse,
|
AudioDeviceManager& deviceManagerToUse,
|
||||||
int minAudioInputChannels,
|
|
||||||
int maxAudioInputChannels,
|
int maxAudioInputChannels,
|
||||||
int minAudioOutputChannels,
|
|
||||||
int maxAudioOutputChannels)
|
int maxAudioOutputChannels)
|
||||||
: owner (pluginHolder),
|
: owner (pluginHolder),
|
||||||
deviceSelector (deviceManagerToUse,
|
deviceSelector (deviceManagerToUse,
|
||||||
minAudioInputChannels, maxAudioInputChannels,
|
0, maxAudioInputChannels,
|
||||||
minAudioOutputChannels, maxAudioOutputChannels,
|
0, maxAudioOutputChannels,
|
||||||
true,
|
true,
|
||||||
(pluginHolder.processor.get() != nullptr && pluginHolder.processor->producesMidi()),
|
false, // disables MIDI Out // (pluginHolder.processor.get() != nullptr && pluginHolder.processor->producesMidi()),
|
||||||
true, false),
|
true, false),
|
||||||
shouldMuteLabel ("Feedback Loop:", "Feedback Loop:"),
|
shouldMuteLabel ("Feedback Loop:", "Feedback Loop:"),
|
||||||
shouldMuteButton ("Mute audio input")
|
shouldMuteButton ("Mute audio input")
|
||||||
|
@ -492,9 +486,7 @@ private:
|
||||||
int numOutputChannels,
|
int numOutputChannels,
|
||||||
int numSamples) override
|
int numSamples) override
|
||||||
{
|
{
|
||||||
const bool inputMuted = shouldMuteInput.getValue();
|
if (muteInput)
|
||||||
|
|
||||||
if (inputMuted)
|
|
||||||
{
|
{
|
||||||
emptyBuffer.clear();
|
emptyBuffer.clear();
|
||||||
inputChannelData = emptyBuffer.getArrayOfReadPointers();
|
inputChannelData = emptyBuffer.getArrayOfReadPointers();
|
||||||
|
@ -526,7 +518,7 @@ private:
|
||||||
const AudioDeviceManager::AudioDeviceSetup* preferredSetupOptions)
|
const AudioDeviceManager::AudioDeviceSetup* preferredSetupOptions)
|
||||||
{
|
{
|
||||||
deviceManager.addAudioCallback (this);
|
deviceManager.addAudioCallback (this);
|
||||||
deviceManager.addMidiInputCallback ({}, &player);
|
deviceManager.addMidiInputDeviceCallback ({}, &player);
|
||||||
|
|
||||||
reloadAudioDeviceState (enableAudioInput, preferredDefaultDeviceName, preferredSetupOptions);
|
reloadAudioDeviceState (enableAudioInput, preferredDefaultDeviceName, preferredSetupOptions);
|
||||||
}
|
}
|
||||||
|
@ -535,23 +527,25 @@ private:
|
||||||
{
|
{
|
||||||
saveAudioDeviceState();
|
saveAudioDeviceState();
|
||||||
|
|
||||||
deviceManager.removeMidiInputCallback ({}, &player);
|
deviceManager.removeMidiInputDeviceCallback ({}, &player);
|
||||||
deviceManager.removeAudioCallback (this);
|
deviceManager.removeAudioCallback (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void timerCallback() override
|
void timerCallback() override
|
||||||
{
|
{
|
||||||
auto newMidiDevices = MidiInput::getDevices();
|
auto newMidiDevices = MidiInput::getAvailableDevices();
|
||||||
|
|
||||||
if (newMidiDevices != lastMidiDevices)
|
if (newMidiDevices != lastMidiDevices)
|
||||||
{
|
{
|
||||||
for (auto& oldDevice : lastMidiDevices)
|
for (auto& oldDevice : lastMidiDevices)
|
||||||
if (! newMidiDevices.contains (oldDevice))
|
if (! newMidiDevices.contains (oldDevice))
|
||||||
deviceManager.setMidiInputEnabled (oldDevice, false);
|
deviceManager.setMidiInputDeviceEnabled (oldDevice.identifier, false);
|
||||||
|
|
||||||
for (auto& newDevice : newMidiDevices)
|
for (auto& newDevice : newMidiDevices)
|
||||||
if (! lastMidiDevices.contains (newDevice))
|
if (! lastMidiDevices.contains (newDevice))
|
||||||
deviceManager.setMidiInputEnabled (newDevice, true);
|
deviceManager.setMidiInputDeviceEnabled (newDevice.identifier, true);
|
||||||
|
|
||||||
|
lastMidiDevices = newMidiDevices;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +589,7 @@ public:
|
||||||
bool autoOpenMidiDevices = true
|
bool autoOpenMidiDevices = true
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
: DocumentWindow (title, Colour::fromHSV (0.0f, 0.0f, 0.1f, 1.0f), DocumentWindow::minimiseButton | DocumentWindow::closeButton)
|
: DocumentWindow ("", Colour::fromHSV (0.0f, 0.0f, 0.1f, 1.0f), DocumentWindow::minimiseButton | DocumentWindow::closeButton)
|
||||||
, menuBar(this)
|
, menuBar(this)
|
||||||
#if ! JUCE_MAC
|
#if ! JUCE_MAC
|
||||||
, optionsButton ("Settings")
|
, optionsButton ("Settings")
|
||||||
|
@ -644,7 +638,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
~StandaloneFilterWindow()
|
~StandaloneFilterWindow() override
|
||||||
{
|
{
|
||||||
#if JUCE_MAC
|
#if JUCE_MAC
|
||||||
setMacMainMenu(nullptr);
|
setMacMainMenu(nullptr);
|
||||||
|
@ -717,16 +711,17 @@ public:
|
||||||
|
|
||||||
void buttonClicked (Button*) override
|
void buttonClicked (Button*) override
|
||||||
{
|
{
|
||||||
PopupMenu m;
|
pluginHolder->showAudioSettingsDialog();
|
||||||
m.addItem (1, TRANS("Audio/MIDI Settings..."));
|
|
||||||
m.addSeparator();
|
|
||||||
m.addItem (2, TRANS("Save current state..."));
|
|
||||||
m.addItem (3, TRANS("Load a saved state..."));
|
|
||||||
m.addSeparator();
|
|
||||||
m.addItem (4, TRANS("Reset to default state"));
|
|
||||||
|
|
||||||
m.showMenuAsync (PopupMenu::Options(),
|
// PopupMenu m;
|
||||||
ModalCallbackFunction::forComponent (menuCallback, this));
|
// m.addItem (1, TRANS("Audio/MIDI Settings..."));
|
||||||
|
// m.addSeparator();
|
||||||
|
// m.addItem (2, TRANS("Save current state..."));
|
||||||
|
// m.addItem (3, TRANS("Load a saved state..."));
|
||||||
|
// m.addSeparator();
|
||||||
|
// m.addItem (4, TRANS("Reset to default state"));
|
||||||
|
|
||||||
|
// m.showMenuAsync (PopupMenu::Options(),ModalCallbackFunction::forComponent (menuCallback, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMenuResult (int result)
|
void handleMenuResult (int result)
|
||||||
|
@ -771,7 +766,8 @@ private:
|
||||||
public:
|
public:
|
||||||
MainContentComponent (StandaloneFilterWindow& filterWindow)
|
MainContentComponent (StandaloneFilterWindow& filterWindow)
|
||||||
: owner (filterWindow), notification (this),
|
: owner (filterWindow), notification (this),
|
||||||
editor (owner.getAudioProcessor()->createEditorIfNeeded())
|
editor (owner.getAudioProcessor()->hasEditor() ? owner.getAudioProcessor()->createEditorIfNeeded()
|
||||||
|
: new GenericAudioProcessorEditor (*owner.getAudioProcessor()))
|
||||||
{
|
{
|
||||||
Value& inputMutedValue = owner.pluginHolder->getMuteInputValue();
|
Value& inputMutedValue = owner.pluginHolder->getMuteInputValue();
|
||||||
|
|
||||||
|
@ -794,7 +790,7 @@ private:
|
||||||
inputMutedChanged (shouldShowNotification);
|
inputMutedChanged (shouldShowNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
~MainContentComponent()
|
~MainContentComponent() override
|
||||||
{
|
{
|
||||||
if (editor != nullptr)
|
if (editor != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -811,7 +807,9 @@ private:
|
||||||
if (shouldShowNotification)
|
if (shouldShowNotification)
|
||||||
notification.setBounds (r.removeFromTop (NotificationArea::height));
|
notification.setBounds (r.removeFromTop (NotificationArea::height));
|
||||||
|
|
||||||
editor->setBounds (r);
|
if (editor != nullptr)
|
||||||
|
editor->setBounds (editor->getLocalArea (this, r)
|
||||||
|
.withPosition (r.getTopLeft().transformedBy (editor->getTransform().inverted())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -871,9 +869,13 @@ private:
|
||||||
#if JUCE_IOS || JUCE_ANDROID
|
#if JUCE_IOS || JUCE_ANDROID
|
||||||
resized();
|
resized();
|
||||||
#else
|
#else
|
||||||
setSize (editor->getWidth(),
|
if (editor != nullptr)
|
||||||
editor->getHeight()
|
{
|
||||||
+ (shouldShowNotification ? NotificationArea::height : 0));
|
auto rect = getSizeToContainEditor();
|
||||||
|
|
||||||
|
setSize (rect.getWidth(),
|
||||||
|
rect.getHeight() + (shouldShowNotification ? NotificationArea::height : 0));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,11 +890,23 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
void componentMovedOrResized (Component&, bool, bool wasResized) override
|
void componentMovedOrResized (Component&, bool, bool) override
|
||||||
{
|
{
|
||||||
if (wasResized && editor != nullptr)
|
if (editor != nullptr)
|
||||||
setSize (editor->getWidth(),
|
{
|
||||||
editor->getHeight() + (shouldShowNotification ? NotificationArea::height : 0));
|
auto rect = getSizeToContainEditor();
|
||||||
|
|
||||||
|
setSize (rect.getWidth(),
|
||||||
|
rect.getHeight() + (shouldShowNotification ? NotificationArea::height : 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle<int> getSizeToContainEditor() const
|
||||||
|
{
|
||||||
|
if (editor != nullptr)
|
||||||
|
return getLocalArea (editor.get(), editor->getLocalBounds());
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
Loading…
Reference in a new issue