Browse Source

Fix build, add preset selector to generic UI

Signed-off-by: falkTX <falktx@falktx.com>
tags/v1.3
falkTX 2 years ago
parent
commit
1a60177cfa
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 76 additions and 12 deletions
  1. +1
    -1
      plugins/Common/IldaeilPlugin.cpp
  2. +69
    -5
      plugins/Common/IldaeilUI.cpp
  3. +6
    -6
      plugins/Common/Makefile.mk

+ 1
- 1
plugins/Common/IldaeilPlugin.cpp View File

@@ -431,7 +431,7 @@ protected:
break;
}
#else
static constexpr const* NativeMidiEvent fMidiEvents = nullptr;
static constexpr const NativeMidiEvent* fMidiEvents = nullptr;
static constexpr const uint32_t midiEventCount = 0;
#endif


+ 69
- 5
plugins/Common/IldaeilUI.cpp View File

@@ -104,11 +104,27 @@ class IldaeilUI : public UI,
}* parameters;
float* values;

uint presetCount;
struct Preset {
uint32_t index;
char* name;
~Preset()
{
std::free(name);
}
}* presets;
int currentPreset;
const char** presetStrings;

PluginGenericUI()
: title(nullptr),
parameterCount(0),
parameters(nullptr),
values(nullptr) {}
values(nullptr),
presetCount(0),
presets(nullptr),
currentPreset(-1),
presetStrings(nullptr) {}

~PluginGenericUI()
{
@@ -370,9 +386,9 @@ public:

void showPluginUI(const CarlaHostHandle handle, const bool showIfNotEmbed)
{
#ifndef DISTRHO_OS_WASM
const uint hints = carla_get_plugin_info(handle, fPluginId)->hints;

#ifndef DISTRHO_OS_WASM
if (hints & PLUGIN_HAS_CUSTOM_EMBED_UI)
{
fDrawingState = kDrawingPluginEmbedUI;
@@ -436,10 +452,10 @@ public:
title += info->maker;
ui->title = title.getAndReleaseBuffer();

const uint32_t pcount = ui->parameterCount = carla_get_parameter_count(handle, fPluginId);
const uint32_t parameterCount = ui->parameterCount = carla_get_parameter_count(handle, fPluginId);

// make count of valid parameters
for (uint32_t i=0; i < pcount; ++i)
for (uint32_t i=0; i < parameterCount; ++i)
{
const ParameterData* const pdata = carla_get_parameter_data(handle, fPluginId, i);

@@ -457,7 +473,7 @@ public:
ui->values = new float[ui->parameterCount];

// now safely fill in details
for (uint32_t i=0, j=0; i < pcount; ++i)
for (uint32_t i=0, j=0; i < parameterCount; ++i)
{
const ParameterData* const pdata = carla_get_parameter_data(handle, fPluginId, i);

@@ -496,6 +512,41 @@ public:
++j;
}

// handle presets too
const uint32_t presetCount = ui->presetCount = carla_get_program_count(handle, fPluginId);

for (uint32_t i=0; i < presetCount; ++i)
{
const char* const pname = carla_get_program_name(handle, fPluginId, i);

if (pname[0] == '\0')
{
--ui->presetCount;
continue;
}
}

ui->presets = new PluginGenericUI::Preset[ui->presetCount];
ui->presetStrings = new const char*[ui->presetCount];

for (uint32_t i=0, j=0; i < presetCount; ++i)
{
const char* const pname = carla_get_program_name(handle, fPluginId, i);

if (pname[0] == '\0')
continue;

PluginGenericUI::Preset& preset(ui->presets[j]);
preset.index = i;
preset.name = strdup(pname);

ui->presetStrings[j] = preset.name;

++j;
}

ui->currentPreset = -1;

fPluginGenericUI = ui;
}

@@ -1074,6 +1125,19 @@ protected:
{
const CarlaHostHandle handle = fPlugin->fCarlaHostHandle;

if (ui->presetCount != 0)
{
ImGui::Text("Preset:");
ImGui::SameLine();

if (ImGui::Combo("##presets", &ui->currentPreset, ui->presetStrings, ui->presetCount))
{
PluginGenericUI::Preset& preset(ui->presets[ui->currentPreset]);

carla_set_program(handle, fPluginId, preset.index);
}
}

for (uint32_t i=0; i < ui->parameterCount; ++i)
{
PluginGenericUI::Parameter& param(ui->parameters[i]);


+ 6
- 6
plugins/Common/Makefile.mk View File

@@ -79,15 +79,15 @@ USE_VST2_BUNDLE = true
include ../../dpf/Makefile.plugins.mk

ifeq ($(WASM),true)
# used for testing
LINK_FLAGS += -sALLOW_MEMORY_GROWTH
LINK_FLAGS += --use-preload-cache
LINK_FLAGS += --use-preload-plugins
# LINK_FLAGS += --preload-file=foolme.mp3
# LINK_FLAGS += --preload-file=furelise.mid
# LINK_FLAGS += --preload-file=./jsfx
LINK_FLAGS += -sLZ4=1
LINK_FLAGS += --preload-file=./jsfx
LINK_FLAGS += --preload-file=./lv2
# LV2_WASM_BINARIES = $(wildcard ./lv2/*.lv2/*.wasm)
# LINK_FLAGS += $(LV2_WASM_BINARIES:%=--preload-file=%)
LINK_FLAGS += --shell-file=./emscripten/shell.html
# LINK_FLAGS += --use-preload-cache
LINK_FLAGS += --use-preload-plugins
else ifneq ($(HAIKU),true)
BUILD_CXX_FLAGS += -pthread
endif


Loading…
Cancel
Save