Browse Source

Set range of LV2 and native CV plugin ports

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.1-rc1
falkTX 5 years ago
parent
commit
c2c422a8ef
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
18 changed files with 115 additions and 49 deletions
  1. +16
    -8
      source/backend/engine/CarlaEngineNative.cpp
  2. +17
    -0
      source/backend/plugin/CarlaPluginLV2.cpp
  3. +26
    -0
      source/backend/plugin/CarlaPluginNative.cpp
  4. +5
    -0
      source/includes/CarlaNative.h
  5. +1
    -1
      source/includes/CarlaNative.hpp
  6. +9
    -7
      source/native-plugins/_data.cpp
  7. +1
    -3
      source/native-plugins/audio-gain.c
  8. +1
    -3
      source/native-plugins/bypass.c
  9. +1
    -3
      source/native-plugins/lfo.c
  10. +1
    -3
      source/native-plugins/midi-channel-ab.c
  11. +1
    -3
      source/native-plugins/midi-channel-filter.c
  12. +1
    -3
      source/native-plugins/midi-channelize.c
  13. +1
    -3
      source/native-plugins/midi-gain.c
  14. +1
    -3
      source/native-plugins/midi-join.c
  15. +1
    -3
      source/native-plugins/midi-split.c
  16. +1
    -3
      source/native-plugins/midi-through.c
  17. +30
    -0
      source/native-plugins/midi-to-cv.c
  18. +1
    -3
      source/native-plugins/midi-transpose.c

+ 16
- 8
source/backend/engine/CarlaEngineNative.cpp View File

@@ -2343,7 +2343,8 @@ static const NativePluginDescriptor carlaRackDesc = {
/* _render_inline_dsplay */ nullptr,
/* cvIns */ 0,
/* cvOuts */ 0,
/* _get_buffer_port_name */ nullptr
/* _get_buffer_port_name */ nullptr,
/* _get_buffer_port_range */ nullptr
};

static const NativePluginDescriptor carlaRackNoMidiOutDesc = {
@@ -2388,7 +2389,8 @@ static const NativePluginDescriptor carlaRackNoMidiOutDesc = {
/* _render_inline_dsplay */ nullptr,
/* cvIns */ 0,
/* cvOuts */ 0,
/* _get_buffer_port_name */ nullptr
/* _get_buffer_port_name */ nullptr,
/* _get_buffer_port_range */ nullptr
};

static const NativePluginDescriptor carlaPatchbayDesc = {
@@ -2433,7 +2435,8 @@ static const NativePluginDescriptor carlaPatchbayDesc = {
/* _render_inline_dsplay */ nullptr,
/* cvIns */ 0,
/* cvOuts */ 0,
/* _get_buffer_port_name */ nullptr
/* _get_buffer_port_name */ nullptr,
/* _get_buffer_port_range */ nullptr
};

static const NativePluginDescriptor carlaPatchbay3sDesc = {
@@ -2478,7 +2481,8 @@ static const NativePluginDescriptor carlaPatchbay3sDesc = {
/* _render_inline_dsplay */ nullptr,
/* cvIns */ 0,
/* cvOuts */ 0,
/* _get_buffer_port_name */ nullptr
/* _get_buffer_port_name */ nullptr,
/* _get_buffer_port_range */ nullptr
};

static const NativePluginDescriptor carlaPatchbay16Desc = {
@@ -2523,7 +2527,8 @@ static const NativePluginDescriptor carlaPatchbay16Desc = {
/* _render_inline_dsplay */ nullptr,
/* cvIns */ 0,
/* cvOuts */ 0,
/* _get_buffer_port_name */ nullptr
/* _get_buffer_port_name */ nullptr,
/* _get_buffer_port_range */ nullptr
};

static const NativePluginDescriptor carlaPatchbay32Desc = {
@@ -2568,7 +2573,8 @@ static const NativePluginDescriptor carlaPatchbay32Desc = {
/* _render_inline_dsplay */ nullptr,
/* cvIns */ 0,
/* cvOuts */ 0,
/* _get_buffer_port_name */ nullptr
/* _get_buffer_port_name */ nullptr,
/* _get_buffer_port_range */ nullptr
};

static const NativePluginDescriptor carlaPatchbay64Desc = {
@@ -2613,7 +2619,8 @@ static const NativePluginDescriptor carlaPatchbay64Desc = {
/* _render_inline_dsplay */ nullptr,
/* cvIns */ 0,
/* cvOuts */ 0,
/* _get_buffer_port_name */ nullptr
/* _get_buffer_port_name */ nullptr,
/* _get_buffer_port_range */ nullptr
};

static const NativePluginDescriptor carlaPatchbayCVDesc = {
@@ -2659,7 +2666,8 @@ static const NativePluginDescriptor carlaPatchbayCVDesc = {
/* _render_inline_dsplay */ nullptr,
/* cvIns */ 5,
/* cvOuts */ 5,
/* _get_buffer_port_name */ nullptr
/* _get_buffer_port_name */ nullptr,
/* _get_buffer_port_range */ nullptr
};

CARLA_BACKEND_END_NAMESPACE


+ 17
- 0
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -2211,17 +2211,34 @@ public:
}
else if (LV2_IS_PORT_CV(portTypes))
{
const LV2_RDF_PortPoints portPoints(fRdfDescriptor->Ports[i].Points);
float min, max;

// min value
if (LV2_HAVE_MINIMUM_PORT_POINT(portPoints.Hints))
min = portPoints.Minimum;
else
min = -1.0f;

// max value
if (LV2_HAVE_MAXIMUM_PORT_POINT(portPoints.Hints))
max = portPoints.Maximum;
else
max = 1.0f;

if (LV2_IS_PORT_INPUT(portTypes))
{
const uint32_t j = iCvIn++;
pData->cvIn.ports[j].port = (CarlaEngineCVPort*)pData->client->addPort(kEnginePortTypeCV, portName, true, j);
pData->cvIn.ports[j].rindex = i;
pData->cvIn.ports[j].port->setRange(min, max);
}
else if (LV2_IS_PORT_OUTPUT(portTypes))
{
const uint32_t j = iCvOut++;
pData->cvOut.ports[j].port = (CarlaEngineCVPort*)pData->client->addPort(kEnginePortTypeCV, portName, false, j);
pData->cvOut.ports[j].rindex = i;
pData->cvOut.ports[j].port->setRange(min, max);
}
else
carla_stderr("WARNING - Got a broken Port (CV, but not input or output)");


+ 26
- 0
source/backend/plugin/CarlaPluginNative.cpp View File

@@ -1213,8 +1213,21 @@ public:

portName.truncate(portNameSize);

float min = -1.0f, max = 1.0f;
if (fDescriptor->get_buffer_port_range != nullptr)
{
if (const NativePortRange* const range = fDescriptor->get_buffer_port_range(fHandle,
fDescriptor->audioIns + j,
false))
{
min = range->minimum;
max = range->maximum;
}
}

pData->cvIn.ports[j].port = (CarlaEngineCVPort*)pData->client->addPort(kEnginePortTypeCV, portName, true, j);
pData->cvIn.ports[j].rindex = j;
pData->cvIn.ports[j].port->setRange(min, max);
}

// CV Outs
@@ -1242,8 +1255,21 @@ public:

portName.truncate(portNameSize);

float min = -1.0f, max = 1.0f;
if (fDescriptor->get_buffer_port_range != nullptr)
{
if (const NativePortRange* const range = fDescriptor->get_buffer_port_range(fHandle,
fDescriptor->audioOuts + j,
true))
{
min = range->minimum;
max = range->maximum;
}
}

pData->cvOut.ports[j].port = (CarlaEngineCVPort*)pData->client->addPort(kEnginePortTypeCV, portName, false, j);
pData->cvOut.ports[j].rindex = j;
pData->cvOut.ports[j].port->setRange(min, max);
}

// MIDI Input (only if multiple)


+ 5
- 0
source/includes/CarlaNative.h View File

@@ -193,6 +193,10 @@ typedef struct {
int stride;
} NativeInlineDisplayImageSurface;

typedef struct {
float minimum, maximum;
} NativePortRange;

/* ------------------------------------------------------------------------------------------------------------
* HostDescriptor */

@@ -283,6 +287,7 @@ typedef struct _NativePluginDescriptor {
const uint32_t cvIns;
const uint32_t cvOuts;
const char* (*get_buffer_port_name)(NativePluginHandle handle, uint32_t index, bool isOutput);
const NativePortRange* (*get_buffer_port_range)(NativePluginHandle handle, uint32_t index, bool isOutput);

} NativePluginDescriptor;



+ 1
- 1
source/includes/CarlaNative.hpp View File

@@ -619,7 +619,7 @@ public: \
ClassName::_set_state, \
ClassName::_dispatcher, \
ClassName::_render_inline_display, \
0, 0, nullptr
0, 0, nullptr, nullptr

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



+ 9
- 7
source/native-plugins/_data.cpp View File

@@ -28,7 +28,7 @@
nullptr, nullptr, nullptr, nullptr, nullptr, \
nullptr, nullptr
#define DESCFUNCS_WITHOUTCV \
DESCFUNCS_WITHCV, 0, 0, nullptr
DESCFUNCS_WITHCV, 0, 0, nullptr, nullptr

static const NativePluginDescriptor sNativePluginDescriptors[] = {

@@ -194,9 +194,10 @@ static const NativePluginDescriptor sNativePluginDescriptors[] = {
/* maker */ "falkTX, Bram Giesen, Jarno Verheesen",
/* copyright */ "GNU GPL v2+",
DESCFUNCS_WITHCV,
/* cvIns */ 0,
/* cvOuts */ 3,
/* bufnamefn */ nullptr
/* cvIns */ 0,
/* cvOuts */ 3,
/* bufnamefn */ nullptr,
/* bufrangefn */ nullptr
},
{
/* category */ NATIVE_PLUGIN_CATEGORY_UTILITY,
@@ -482,9 +483,10 @@ static const NativePluginDescriptor sNativePluginDescriptors[] = {
/* maker */ "falkTX",
/* copyright */ "GNU GPL v2+",
DESCFUNCS_WITHCV,
/* cvIns */ 5,
/* cvOuts */ 5,
/* bufnamefn */ nullptr
/* cvIns */ 5,
/* cvOuts */ 5,
/* bufnamefn */ nullptr,
/* bufrangefn */ nullptr
},
#endif



+ 1
- 3
source/native-plugins/audio-gain.c View File

@@ -338,9 +338,7 @@ static const NativePluginDescriptor audiogainStereoDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = audiogain_dispatcher,

.render_inline_display = NULL
.dispatcher = audiogain_dispatcher
};

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


+ 1
- 3
source/native-plugins/bypass.c View File

@@ -92,9 +92,7 @@ static const NativePluginDescriptor bypassDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL,

.render_inline_display = NULL
.dispatcher = NULL
};

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


+ 1
- 3
source/native-plugins/lfo.c View File

@@ -312,9 +312,7 @@ static const NativePluginDescriptor lfoDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL,

.render_inline_display = NULL
.dispatcher = NULL
};

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


+ 1
- 3
source/native-plugins/midi-channel-ab.c View File

@@ -201,9 +201,7 @@ static const NativePluginDescriptor midichanabDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL,

.render_inline_display = NULL
.dispatcher = NULL
};

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


+ 1
- 3
source/native-plugins/midi-channel-filter.c View File

@@ -192,9 +192,7 @@ static const NativePluginDescriptor midichanfilterDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL,

.render_inline_display = NULL
.dispatcher = NULL
};

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


+ 1
- 3
source/native-plugins/midi-channelize.c View File

@@ -200,9 +200,7 @@ static const NativePluginDescriptor midichannelizeDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL,

.render_inline_display = NULL
.dispatcher = NULL
};

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


+ 1
- 3
source/native-plugins/midi-gain.c View File

@@ -262,9 +262,7 @@ static const NativePluginDescriptor midigainDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL,

.render_inline_display = NULL
.dispatcher = NULL
};

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


+ 1
- 3
source/native-plugins/midi-join.c View File

@@ -139,9 +139,7 @@ static const NativePluginDescriptor midijoinDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL,

.render_inline_display = NULL
.dispatcher = NULL
};

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


+ 1
- 3
source/native-plugins/midi-split.c View File

@@ -132,9 +132,7 @@ static const NativePluginDescriptor midisplitDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL,

.render_inline_display = NULL
.dispatcher = NULL
};

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


+ 1
- 3
source/native-plugins/midi-through.c View File

@@ -113,9 +113,7 @@ static const NativePluginDescriptor midithroughDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL,

.render_inline_display = NULL
.dispatcher = NULL
};

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


+ 30
- 0
source/native-plugins/midi-to-cv.c View File

@@ -179,6 +179,35 @@ static void midi2cv_set_parameter_value(NativePluginHandle handle, uint32_t inde
handlePtr->params[index] = value;
}

static const NativePortRange* midi2cv_get_buffer_port_range(NativePluginHandle handle, uint32_t index, bool isOutput)
{
if (! isOutput)
return NULL;

static NativePortRange npr;

switch (index)
{
case 0:
npr.minimum = 0.0f;
npr.maximum = 9.0f;
return &npr;
case 1:
npr.minimum = 0.0f;
npr.maximum = 10.5f;
return &npr;
case 2:
npr.minimum = 0.0f;
npr.maximum = 10.0f;
return &npr;
default:
return NULL;
}

// unused
(void)handle;
}

static const char* midi2cv_get_buffer_port_name(NativePluginHandle handle, uint32_t index, bool isOutput)
{
if (! isOutput)
@@ -357,6 +386,7 @@ static const NativePluginDescriptor midi2cvDesc = {
.set_custom_data = NULL,

.get_buffer_port_name = midi2cv_get_buffer_port_name,
.get_buffer_port_range = midi2cv_get_buffer_port_range,

.ui_show = NULL,
.ui_idle = NULL,


+ 1
- 3
source/native-plugins/midi-transpose.c View File

@@ -225,9 +225,7 @@ static const NativePluginDescriptor miditransposeDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL,

.render_inline_display = NULL
.dispatcher = NULL
};

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


Loading…
Cancel
Save