From 1289312d1398b7264ddfe777a64ea93fd9785137 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Tue, 18 Apr 2023 21:53:48 -0400 Subject: [PATCH 1/2] Implement the CLAP remote control pages For now just 5 pages; macros and the mixer and filters from each. But I'm sure we could add more if people like it Addresses #6930 --- src/surge-xt/SurgeSynthProcessor.cpp | 75 ++++++++++++++++++++++++++++ src/surge-xt/SurgeSynthProcessor.h | 8 +++ 2 files changed, 83 insertions(+) diff --git a/src/surge-xt/SurgeSynthProcessor.cpp b/src/surge-xt/SurgeSynthProcessor.cpp index 0030ec0e151..b042d8996c6 100644 --- a/src/surge-xt/SurgeSynthProcessor.cpp +++ b/src/surge-xt/SurgeSynthProcessor.cpp @@ -1020,6 +1020,81 @@ juce::AudioProcessorParameter *SurgeSynthProcessor::getBypassParameter() const void SurgeSynthProcessor::reset() { blockPos = 0; } +uint32_t SurgeSynthProcessor::remoteControlsPageCount() noexcept +{ + return 5; // macros + scene a and b mixer and filters +} + +bool SurgeSynthProcessor::remoteControlsPageFill( + uint32_t pageIndex, juce::String §ionName, uint32_t &pageID, juce::String &pageName, + std::array ¶ms) noexcept +{ + if (pageIndex < 0 || pageIndex >= remoteControlsPageCount()) + return false; + + pageID = pageIndex + 2054; + for (auto &p : params) + p = nullptr; + switch (pageIndex) + { + case 0: + { + sectionName = "Global"; + pageName = "Macros"; + for (int i = 0; i < CLAP_REMOTE_CONTROLS_COUNT && i < macrosById.size(); ++i) + params[i] = macrosById[i]; + } + break; + case 1: + case 3: + { + int scene = 0; + sectionName = "Scene A"; + pageName = "Scene A Mixer"; + if (pageIndex == 3) + { + sectionName = "Scene B"; + pageName = "Scene B Mixer"; + scene = 1; + } + auto &sc = surge->storage.getPatch().scene[scene]; + params[0] = paramsByID[surge->idForParameter(&sc.level_o1)]; + params[1] = paramsByID[surge->idForParameter(&sc.level_o2)]; + params[2] = paramsByID[surge->idForParameter(&sc.level_o3)]; + params[3] = nullptr; + params[4] = paramsByID[surge->idForParameter(&sc.level_noise)]; + params[5] = paramsByID[surge->idForParameter(&sc.level_ring_12)]; + params[6] = paramsByID[surge->idForParameter(&sc.level_ring_23)]; + params[7] = paramsByID[surge->idForParameter(&sc.level_pfg)]; + } + break; + case 2: + case 4: + { + int scene = 0; + sectionName = "Scene A"; + pageName = "Scene A Filters"; + if (pageIndex == 4) + { + scene = 1; + sectionName = "Scene B"; + pageName = "Scene B Filters"; + } + auto &sc = surge->storage.getPatch().scene[scene]; + params[0] = paramsByID[surge->idForParameter(&sc.filterunit[0].cutoff)]; + params[1] = paramsByID[surge->idForParameter(&sc.filterunit[0].resonance)]; + params[2] = paramsByID[surge->idForParameter(&sc.filterunit[1].cutoff)]; + params[3] = paramsByID[surge->idForParameter(&sc.filterunit[1].resonance)]; + params[4] = paramsByID[surge->idForParameter(&sc.wsunit.drive)]; + params[5] = nullptr; + params[6] = paramsByID[surge->idForParameter(&sc.filter_balance)]; + params[7] = paramsByID[surge->idForParameter(&sc.feedback)]; + } + break; + } + return true; +} + //============================================================================== // This creates new instances of the plugin.. juce::AudioProcessor *JUCE_CALLTYPE createPluginFilter() { return new SurgeSynthProcessor(); } diff --git a/src/surge-xt/SurgeSynthProcessor.h b/src/surge-xt/SurgeSynthProcessor.h index 232bd32cf00..9e8e6521c14 100644 --- a/src/surge-xt/SurgeSynthProcessor.h +++ b/src/surge-xt/SurgeSynthProcessor.h @@ -161,6 +161,7 @@ struct SurgeParamToJuceParamAdapter : SurgeBaseParam { s->applyParameterMonophonicModulation(p, value); } + #endif }; @@ -393,6 +394,13 @@ class SurgeSynthProcessor : public juce::AudioProcessor, info->flags = CLAP_VOICE_INFO_SUPPORTS_OVERLAPPING_NOTES; return true; } + bool supportsRemoteControls() const noexcept override { return true; } + uint32_t remoteControlsPageCount() noexcept override; + bool + remoteControlsPageFill(uint32_t /*pageIndex*/, juce::String & /*sectionName*/, + uint32_t & /*pageID*/, juce::String & /*pageName*/, + std::array + & /*params*/) noexcept override; #endif private: From 2a2e96dc5b970b4be1acd02bac903f312f935f35 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Wed, 19 Apr 2023 07:49:02 -0400 Subject: [PATCH 2/2] Turn off the factory for 32 bit temporarily also --- azure-pipelines.yml | 2 +- src/surge-xt/CMakeLists.txt | 2 +- src/surge-xt/SurgeSynthProcessor.cpp | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5b33da8d3ad..ddbcb709ac6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,7 +28,7 @@ jobs: isWindows: True cmakeArguments: "-A Win32 -DCMAKE_BUILD_TYPE=Debug" cmakeConfig: "Debug" - cmakeTarget: "surge-xt_Standalone" # just a subset for time + cmakeTarget: "surge-xt_CLAP" # just a subset for time macOS-x86: imageName: 'macos-latest' isMac: True diff --git a/src/surge-xt/CMakeLists.txt b/src/surge-xt/CMakeLists.txt index 07faab57a5f..ef18e36fe4d 100644 --- a/src/surge-xt/CMakeLists.txt +++ b/src/surge-xt/CMakeLists.txt @@ -56,7 +56,7 @@ juce_add_plugin(${PROJECT_NAME} if(SURGE_BUILD_CLAP) clap_juce_extensions_plugin(TARGET surge-xt CLAP_ID "org.surge-synth-team.surge-xt" - CLAP_SUPPORTS_CUSTOM_FACTORY 1 + # CLAP_SUPPORTS_CUSTOM_FACTORY 1 CLAP_FEATURES "instrument" "synthesizer" "hybrid" "free and open source") endif() diff --git a/src/surge-xt/SurgeSynthProcessor.cpp b/src/surge-xt/SurgeSynthProcessor.cpp index b042d8996c6..553f00d3c6e 100644 --- a/src/surge-xt/SurgeSynthProcessor.cpp +++ b/src/surge-xt/SurgeSynthProcessor.cpp @@ -1099,9 +1099,11 @@ bool SurgeSynthProcessor::remoteControlsPageFill( // This creates new instances of the plugin.. juce::AudioProcessor *JUCE_CALLTYPE createPluginFilter() { return new SurgeSynthProcessor(); } +#if 0 void *JUCE_CALLTYPE clapJuceExtensionCustomFactory(const char *) { // ToDo: Implement preset discovery here // See #6930 return nullptr; -} \ No newline at end of file +} +#endif \ No newline at end of file