Skip to content

Commit

Permalink
Implement the CLAP remote control pages
Browse files Browse the repository at this point in the history
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 surge-synthesizer#6930
  • Loading branch information
baconpaul committed Apr 19, 2023
1 parent 8ef88f3 commit 1289312
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
75 changes: 75 additions & 0 deletions src/surge-xt/SurgeSynthProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &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(); }
Expand Down
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

0 comments on commit 1289312

Please sign in to comment.