AnalogTapeModel

Physical modelling signal processing for analog tape recording
Log | Files | Refs | Submodules | README | LICENSE

commit 8952e472fed6458f3c7d11d4decb33fbde4b8693
parent 861a09e4f76f211ffbdf82911bc6b430766aaaf7
Author: jatinchowdhury18 <jatinchowdhury18@gmail.com>
Date:   Wed, 16 Mar 2022 01:11:51 +0000

Use OpenGL by default if it is available on the host system (#250)


Diffstat:
MPlugin/Source/GUI/SettingsButton.cpp | 20++++++++++++--------
MPlugin/Source/GUI/SettingsButton.h | 4++--
MPlugin/Source/PluginProcessor.cpp | 5++++-
MPlugin/Source/PluginProcessor.h | 4++--
MPlugin/modules/CMakeLists.txt | 1+
5 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/Plugin/Source/GUI/SettingsButton.cpp b/Plugin/Source/GUI/SettingsButton.cpp @@ -6,11 +6,12 @@ const Colour onColour = Colour (0xFFEAA92C); const Colour offColour = Colours::white; } // namespace -SettingsButton::SettingsButton (const ChowtapeModelAudioProcessor& processor, chowdsp::OpenGLHelper& oglHelper) : DrawableButton ("Settings", DrawableButton::ImageFitted), +SettingsButton::SettingsButton (const ChowtapeModelAudioProcessor& processor, chowdsp::OpenGLHelper* oglHelper) : DrawableButton ("Settings", DrawableButton::ImageFitted), proc (processor), openGLHelper (oglHelper) { - pluginSettings->addProperties ({ { openglID, false } }, this); + const auto shouldUseOpenGLByDefault = openGLHelper != nullptr && openGLHelper->isOpenGLAvailable(); + pluginSettings->addProperties ({ { openglID, shouldUseOpenGLByDefault } }, this); globalSettingChanged (openglID); auto cog = Drawable::createFromImageData (BinaryData::cogsolid_svg, BinaryData::cogsolid_svgSize); @@ -29,12 +30,15 @@ void SettingsButton::globalSettingChanged (SettingID settingID) if (settingID != openglID) return; - const auto shouldUseOpenGL = pluginSettings->getProperty<bool> (openglID); - if (shouldUseOpenGL == openGLHelper.isAttached()) - return; // no change + if (openGLHelper != nullptr) + { + const auto shouldUseOpenGL = pluginSettings->getProperty<bool> (openglID); + if (shouldUseOpenGL == openGLHelper->isAttached()) + return; // no change - Logger::writeToLog ("Using OpenGL: " + String (shouldUseOpenGL ? "TRUE" : "FALSE")); - shouldUseOpenGL ? openGLHelper.attach() : openGLHelper.detach(); + Logger::writeToLog ("Using OpenGL: " + String (shouldUseOpenGL ? "TRUE" : "FALSE")); + shouldUseOpenGL ? openGLHelper->attach() : openGLHelper->detach(); + } } void SettingsButton::showSettingsMenu() @@ -75,7 +79,7 @@ void SettingsButton::showSettingsMenu() void SettingsButton::openGLManu (PopupMenu& menu, int itemID) { - if (! chowdsp::OpenGLHelper::isOpenGLAvailable()) + if (openGLHelper == nullptr || ! openGLHelper->isOpenGLAvailable()) return; const auto isCurrentlyOn = pluginSettings->getProperty<bool> (openglID); diff --git a/Plugin/Source/GUI/SettingsButton.h b/Plugin/Source/GUI/SettingsButton.h @@ -8,7 +8,7 @@ class SettingsButton : public DrawableButton, using SettingID = chowdsp::GlobalPluginSettings::SettingID; public: - SettingsButton (const ChowtapeModelAudioProcessor& processor, chowdsp::OpenGLHelper& openGLHelper); + SettingsButton (const ChowtapeModelAudioProcessor& processor, chowdsp::OpenGLHelper* openGLHelper); ~SettingsButton() override; void globalSettingChanged (SettingID settingID) final; @@ -19,7 +19,7 @@ private: void copyDiagnosticInfo(); const ChowtapeModelAudioProcessor& proc; - chowdsp::OpenGLHelper& openGLHelper; + chowdsp::OpenGLHelper* openGLHelper; chowdsp::SharedPluginSettings pluginSettings; chowdsp::SharedLNFAllocator lnfAllocator; diff --git a/Plugin/Source/PluginProcessor.cpp b/Plugin/Source/PluginProcessor.cpp @@ -306,6 +306,9 @@ bool ChowtapeModelAudioProcessor::hasEditor() const AudioProcessorEditor* ChowtapeModelAudioProcessor::createEditor() { + if (openGLHelper == nullptr) + openGLHelper = std::make_unique<chowdsp::OpenGLHelper>(); + struct ChowTapeInfoProvider : public chowdsp::StandardInfoProvider { static juce::String getWrapperTypeString (const ChowtapeModelAudioProcessor& proc) { return proc.getWrapperTypeString(); } @@ -366,7 +369,7 @@ AudioProcessorEditor* ChowtapeModelAudioProcessor::createEditor() // we need to set resize limits for StandalonePluginHolder editor->setResizeLimits (10, 10, 2000, 2000); - openGLHelper.setComponent (editor); + openGLHelper->setComponent (editor); return editor; } diff --git a/Plugin/Source/PluginProcessor.h b/Plugin/Source/PluginProcessor.h @@ -89,7 +89,7 @@ public: const AudioProcessorValueTreeState& getVTS() const { return vts; } const AudioPlayHead::CurrentPositionInfo& getPositionInfo() const { return positionInfo; } HysteresisProcessor& getHysteresisProcessor() { return hysteresis; } - auto& getOpenGLHelper() { return openGLHelper; } + auto* getOpenGLHelper() { return openGLHelper.get(); } private: using DryDelayType = chowdsp::DelayLine<float, chowdsp::DelayLineInterpolationTypes::Lagrange5th>; @@ -125,7 +125,7 @@ private: MixGroupsController mixGroupsController; AudioPlayHead::CurrentPositionInfo positionInfo; - chowdsp::OpenGLHelper openGLHelper; + std::unique_ptr<chowdsp::OpenGLHelper> openGLHelper = nullptr; #if CHOWDSP_AUTO_UPDATE AutoUpdater updater; diff --git a/Plugin/modules/CMakeLists.txt b/Plugin/modules/CMakeLists.txt @@ -45,6 +45,7 @@ target_compile_definitions(juce_plugin_modules JUCE_USE_CURL=0 JUCE_VST3_CAN_REPLACE_VST2=0 JUCE_MODAL_LOOPS_PERMITTED=1 + JUCE_COREGRAPHICS_DRAW_ASYNC=1 FOLEYS_SHOW_GUI_EDITOR_PALLETTE=0 FOLEYS_ENABLE_BINARY_DATA=1 CHOWDSP_USE_XSIMD=1