Browse Source

Add stubs for host-exposed parameters; Move app scenes to DSP

Signed-off-by: falkTX <falktx@falktx.com>
tags/22.02
falkTX 3 years ago
parent
commit
d989bdcc59
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 41 additions and 24 deletions
  1. +35
    -7
      src/CardinalPlugin.cpp
  2. +4
    -17
      src/CardinalUI.cpp
  3. +2
    -0
      src/PluginContext.hpp

+ 35
- 7
src/CardinalPlugin.cpp View File

@@ -129,7 +129,7 @@ class CardinalPlugin : public CardinalBasePlugin
rack::audio::Device* fCurrentDevice; rack::audio::Device* fCurrentDevice;
Mutex fDeviceMutex; Mutex fDeviceMutex;
float fParameters[kWindowParameterCount];
float fParameters[kModuleParameters + kWindowParameterCount];
struct ScopedContext { struct ScopedContext {
const MutexLocker cml; const MutexLocker cml;
@@ -148,17 +148,19 @@ class CardinalPlugin : public CardinalBasePlugin
public: public:
CardinalPlugin() CardinalPlugin()
: CardinalBasePlugin(kWindowParameterCount, 0, 1),
: CardinalBasePlugin(kModuleParameters + kWindowParameterCount, 0, 1),
fContext(new CardinalPluginContext(this)), fContext(new CardinalPluginContext(this)),
fAudioBufferIn(nullptr), fAudioBufferIn(nullptr),
fAudioBufferOut(nullptr), fAudioBufferOut(nullptr),
fIsActive(false), fIsActive(false),
fCurrentDevice(nullptr) fCurrentDevice(nullptr)
{ {
fParameters[kWindowParameterCableOpacity] = 50.0f;
fParameters[kWindowParameterCableTension] = 50.0f;
fParameters[kWindowParameterRackBrightness] = 100.0f;
fParameters[kWindowParameterHaloBrightness] = 25.0f;
std::memset(fParameters, 0, sizeof(fParameters));
fParameters[kModuleParameters + kWindowParameterCableOpacity] = 50.0f;
fParameters[kModuleParameters + kWindowParameterCableTension] = 50.0f;
fParameters[kModuleParameters + kWindowParameterRackBrightness] = 100.0f;
fParameters[kModuleParameters + kWindowParameterHaloBrightness] = 25.0f;
// create unique temporary path for this instance // create unique temporary path for this instance
try { try {
@@ -186,6 +188,11 @@ public:
fContext->patch = new rack::patch::Manager; fContext->patch = new rack::patch::Manager;
fContext->patch->autosavePath = fAutosavePath; fContext->patch->autosavePath = fAutosavePath;
fContext->patch->templatePath = CARDINAL_PLUGIN_SOURCE_DIR DISTRHO_OS_SEP_STR "template.vcv"; fContext->patch->templatePath = CARDINAL_PLUGIN_SOURCE_DIR DISTRHO_OS_SEP_STR "template.vcv";
fContext->event = new rack::widget::EventState;
fContext->scene = new rack::app::Scene;
fContext->event->rootWidget = fContext->scene;
fContext->patch->loadTemplate(); fContext->patch->loadTemplate();
fContext->engine->startFallbackThread(); fContext->engine->startFallbackThread();
} }
@@ -194,6 +201,13 @@ public:
{ {
{ {
const ScopedContext sc(this); const ScopedContext sc(this);
/*
delete fContext->scene;
fContext->scene = nullptr;
delete fContext->event;
fContext->event = nullptr;
*/
delete fContext; delete fContext;
} }
@@ -285,7 +299,21 @@ protected:
void initParameter(const uint32_t index, Parameter& parameter) override void initParameter(const uint32_t index, Parameter& parameter) override
{ {
switch (index)
if (index < kModuleParameters)
{
parameter.name = "Parameter ";
parameter.name += String(index + 1);
parameter.symbol = "param_";
parameter.symbol += String(index + 1);
parameter.unit = "v";
parameter.hints = kParameterIsAutomable;
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 10.0f;
return;
}
switch (index - kModuleParameters)
{ {
case kWindowParameterCableOpacity: case kWindowParameterCableOpacity:
parameter.name = "Cable Opacity"; parameter.name = "Cable Opacity";


+ 4
- 17
src/CardinalUI.cpp View File

@@ -100,10 +100,6 @@ public:
{ {
const ScopedContext sc(this); const ScopedContext sc(this);


fContext->event = new rack::widget::EventState;
fContext->scene = new rack::app::Scene;
fContext->event->rootWidget = fContext->scene;

rack::window::WindowInit(fContext->window, this); rack::window::WindowInit(fContext->window, this);


// Hide non-wanted menu entries // Hide non-wanted menu entries
@@ -143,12 +139,6 @@ public:
} }
} }
} }

// we need to reload current patch for things to show on screen :(
// FIXME always save
if (! fContext->patch->hasAutosave())
fContext->patch->saveAutosave();
fContext->patch->loadAutosave();
} }


WindowParametersSetCallback(fContext->window, this); WindowParametersSetCallback(fContext->window, this);
@@ -160,12 +150,6 @@ public:


delete fContext->window; delete fContext->window;
fContext->window = nullptr; fContext->window = nullptr;

delete fContext->scene;
fContext->scene = nullptr;

delete fContext->event;
fContext->event = nullptr;
} }


void onNanoDisplay() override void onNanoDisplay() override
@@ -218,7 +202,10 @@ protected:
*/ */
void parameterChanged(const uint32_t index, const float value) override void parameterChanged(const uint32_t index, const float value) override
{ {
switch (index)
if (index < kModuleParameters)
return;

switch (index - kModuleParameters)
{ {
case kWindowParameterCableOpacity: case kWindowParameterCableOpacity:
fWindowParameters.cableOpacity = value / 100.0f; fWindowParameters.cableOpacity = value / 100.0f;


+ 2
- 0
src/PluginContext.hpp View File

@@ -31,6 +31,8 @@ START_NAMESPACE_DISTRHO


// ----------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------


static constexpr const uint kModuleParameters = 24;

class CardinalBasePlugin : public Plugin { class CardinalBasePlugin : public Plugin {
public: public:
CardinalBasePlugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCount) CardinalBasePlugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCount)


Loading…
Cancel
Save