Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the CLAP remote control pages #6958

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
79 changes: 78 additions & 1 deletion src/surge-xt/SurgeSynthProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,13 +1020,90 @@ 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 &sectionName, uint32_t &pageID, juce::String &pageName,
std::array<juce::AudioProcessorParameter *, CLAP_REMOTE_CONTROLS_COUNT> &params) 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(); }

#if 0
void *JUCE_CALLTYPE clapJuceExtensionCustomFactory(const char *)
{
// ToDo: Implement preset discovery here
// See #6930
return nullptr;
}
}
#endif
8 changes: 8 additions & 0 deletions src/surge-xt/SurgeSynthProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ struct SurgeParamToJuceParamAdapter : SurgeBaseParam
{
s->applyParameterMonophonicModulation(p, value);
}

#endif
};

Expand Down Expand Up @@ -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<juce::AudioProcessorParameter *, CLAP_REMOTE_CONTROLS_COUNT>
& /*params*/) noexcept override;
#endif

private:
Expand Down