Skip to content

Commit

Permalink
Add option for AUv3 plugins to disable parameter tree refresh (#254)
Browse files Browse the repository at this point in the history
* Add option for AUv3 plugins to disable parameter tree refresh

* Apply clang-format

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
jatinchowdhury18 and github-actions[bot] committed Jan 8, 2023
1 parent d369246 commit c6d6779
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 40 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
All notable changes to this project will be documented in this file.

## [UNRELEASED]
- Added "Muff Clipper" module.
- Added "Smoothing" parameter for "Muff Drive" module.
- Added new factory presets.
- Added option to skip parameter tree refreshes for AUv3 hosts.
- Fixed parameter name changes not showing up in some CLAP hosts.
- Fixed crashes when loading AUv3 plugin state in GarageBand.

## [1.1.0] 2022-11-21
- Added support for the CLAP plugin format (with parameter modulation).
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.15)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment target")
project(BYOD VERSION 1.1.1)
project(BYOD VERSION 1.1.2)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_STANDARD 17)
Expand Down
2 changes: 1 addition & 1 deletion modules/JUCE
Submodule JUCE updated 329 files
56 changes: 23 additions & 33 deletions src/gui/toolbar/SettingsButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "BYOD.h"
#include "gui/pedalboard/BoardViewport.h"
#include "processors/chain/ProcessorChainPortMagnitudesHelper.h"
#include "state/ParamForwardManager.h"

namespace
{
Expand All @@ -28,7 +29,7 @@ SettingsButton::SettingsButton (BYOD& processor, chowdsp::OpenGLHelper* oglHelpe
globalSettingChanged (openglID);

setImages (Drawable::createFromImageData (BinaryData::cogsolid_svg, BinaryData::cogsolid_svgSize).get());
onClick = [=]
onClick = [this]
{ showSettingsMenu(); };
}

Expand All @@ -52,9 +53,15 @@ void SettingsButton::showSettingsMenu()
{
PopupMenu menu;

cableVizMenu (menu, 100);
defaultZoomMenu (menu, 200);
openGLManu (menu, 300);
addPluginSettingMenuOption ("Cable Visualizations", ProcessorChainPortMagnitudesHelper::cableVizOnOffID, menu, 100);

if (openGLHelper != nullptr && openGLHelper->isOpenGLAvailable())
addPluginSettingMenuOption ("Use OpenGL", openglID, menu, 200);

if (pluginSettings->hasProperty (ParamForwardManager::refreshParamTreeID))
addPluginSettingMenuOption ("Refresh Parameter Tree", ParamForwardManager::refreshParamTreeID, menu, 300);

defaultZoomMenu (menu, 400);

menu.addSeparator();
menu.addItem ("View Source Code", []
Expand All @@ -77,20 +84,6 @@ void SettingsButton::showSettingsMenu()
menu.showMenuAsync (options);
}

void SettingsButton::cableVizMenu (PopupMenu& menu, int itemID)
{
const auto isCurrentlyOn = pluginSettings->getProperty<bool> (ProcessorChainPortMagnitudesHelper::cableVizOnOffID);

PopupMenu::Item item;
item.itemID = ++itemID;
item.text = "Cable Visualizations";
item.action = [=]
{ pluginSettings->setProperty (ProcessorChainPortMagnitudesHelper::cableVizOnOffID, ! isCurrentlyOn); };
item.colour = isCurrentlyOn ? onColour : offColour;

menu.addItem (item);
}

void SettingsButton::defaultZoomMenu (PopupMenu& menu, int itemID)
{
PopupMenu defaultZoomMenu;
Expand All @@ -103,7 +96,7 @@ void SettingsButton::defaultZoomMenu (PopupMenu& menu, int itemID)
PopupMenu::Item item;
item.itemID = ++itemID;
item.text = String (int (zoomLevel * 100.0)) + "%";
item.action = [=]
item.action = [this, zoomLevel]
{ pluginSettings->setProperty (BoardViewport::defaultZoomSettingID, zoomLevel); };
item.colour = isWithin (zoomLevel, curDefaultZoomLevel, 0.001) ? onColour : offColour;

Expand All @@ -113,25 +106,22 @@ void SettingsButton::defaultZoomMenu (PopupMenu& menu, int itemID)
menu.addSubMenu ("Default Zoom", defaultZoomMenu);
}

void SettingsButton::openGLManu (PopupMenu& menu, int itemID)
void SettingsButton::copyDiagnosticInfo()
{
if (openGLHelper == nullptr || ! openGLHelper->isOpenGLAvailable())
return;
Logger::writeToLog ("Copying diagnostic info...");
SystemClipboard::copyTextToClipboard (chowdsp::PluginDiagnosticInfo::getDiagnosticsString (proc));
}

const auto isCurrentlyOn = pluginSettings->getProperty<bool> (openglID);
void SettingsButton::addPluginSettingMenuOption (const String& name, const SettingID& id, PopupMenu& menu, int itemID)
{
const auto isCurrentlyOn = pluginSettings->getProperty<bool> (id);

PopupMenu::Item item;
item.itemID = ++itemID;
item.text = "Use OpenGL";
item.action = [=]
{ pluginSettings->setProperty (openglID, ! isCurrentlyOn); };
item.itemID = itemID;
item.text = name;
item.action = [this, id, isCurrentlyOn]
{ pluginSettings->setProperty (id, ! isCurrentlyOn); };
item.colour = isCurrentlyOn ? onColour : offColour;

menu.addItem (item);
}

void SettingsButton::copyDiagnosticInfo()
{
Logger::writeToLog ("Copying diagnostic info...");
SystemClipboard::copyTextToClipboard (chowdsp::PluginDiagnosticInfo::getDiagnosticsString (proc));
}
3 changes: 1 addition & 2 deletions src/gui/toolbar/SettingsButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ class SettingsButton : public DrawableButton,

private:
void showSettingsMenu();
void cableVizMenu (PopupMenu& menu, int itemID);
void defaultZoomMenu (PopupMenu& menu, int itemID);
void openGLManu (PopupMenu& menu, int itemID);
void copyDiagnosticInfo();
void addPluginSettingMenuOption (const String& name, const SettingID& id, PopupMenu& menu, int itemID);

const BYOD& proc;
chowdsp::OpenGLHelper* openGLHelper;
Expand Down
2 changes: 1 addition & 1 deletion src/processors/other/ShimmerReverb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void ShimmerReverb::prepare (double sampleRate, int samplesPerBlock)
};
sizeParam.setRampLength (0.2);
sizeParam.prepare (sampleRate, samplesPerBlock);

feedbackParam.mappingFunction = [] (float x)
{
const auto delayMs = 1000.0f * std::pow (10000.0f / 1000.0f, x);
Expand Down
20 changes: 20 additions & 0 deletions src/state/ParamForwardManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
ParamForwardManager::ParamForwardManager (AudioProcessorValueTreeState& vts, ProcessorChain& procChain) : chowdsp::ForwardingParametersManager<ParamForwardManager, 500> (vts),
chain (procChain)
{
// In some AUv3 hosts (cough, cough, GarageBand), sending parameter info change notifications
// causes the host to crash. Since there's no way for the plugin to determine which AUv3
// host it's running in, we give the user an option to disable these notifications.
// @TODO: get rid of this option once GarageBand fixes the crash on their end.
if (vts.processor.wrapperType == AudioProcessor::WrapperType::wrapperType_AudioUnitv3)
pluginSettings->addProperties<&ParamForwardManager::deferHostNotificationsGlobalSettingChanged> (
{ { refreshParamTreeID, true } }, *this);
deferHostNotificationsGlobalSettingChanged (refreshParamTreeID);

callbacks += {
chain.processorAddedBroadcaster.connect<&ParamForwardManager::processorAdded> (this),
chain.processorRemovedBroadcaster.connect<&ParamForwardManager::processorRemoved> (this),
Expand Down Expand Up @@ -82,3 +91,14 @@ void ParamForwardManager::processorRemoved (const BaseProcessor* proc)
}
}
}

void ParamForwardManager::deferHostNotificationsGlobalSettingChanged (SettingID settingID)
{
if (settingID != refreshParamTreeID)
return;

if (pluginSettings->getProperty<bool> (refreshParamTreeID))
deferHostNotifs.reset();
else
deferHostNotifs.emplace (*this);
}
12 changes: 11 additions & 1 deletion src/state/ParamForwardManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

#include "processors/chain/ProcessorChain.h"

class ParamForwardManager : public chowdsp::ForwardingParametersManager<ParamForwardManager, 500>
class ParamForwardManager : public chowdsp::ForwardingParametersManager<ParamForwardManager, 500>,
public chowdsp::TrackedByBroadcasters
{
using SettingID = chowdsp::GlobalPluginSettings::SettingID;

public:
ParamForwardManager (AudioProcessorValueTreeState& vts, ProcessorChain& chain);
~ParamForwardManager();
Expand All @@ -15,10 +18,17 @@ class ParamForwardManager : public chowdsp::ForwardingParametersManager<ParamFor

const RangedAudioParameter* getForwardedParameterFromInternal (const RangedAudioParameter& internalParameter) const;

static constexpr SettingID refreshParamTreeID = "refresh_param_tree"; // IOS+AUv3 only!

private:
void deferHostNotificationsGlobalSettingChanged (SettingID settingID);

ProcessorChain& chain;

chowdsp::ScopedCallbackList callbacks;

chowdsp::SharedPluginSettings pluginSettings;
std::optional<ScopedForceDeferHostNotifications> deferHostNotifs {};

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ParamForwardManager)
};

0 comments on commit c6d6779

Please sign in to comment.