diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 3662c4009..7ffa81a8e 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -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 diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index f4b07a8e5..644af6002 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -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)"); diff --git a/source/backend/plugin/CarlaPluginNative.cpp b/source/backend/plugin/CarlaPluginNative.cpp index e1a367937..f799a4997 100644 --- a/source/backend/plugin/CarlaPluginNative.cpp +++ b/source/backend/plugin/CarlaPluginNative.cpp @@ -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) diff --git a/source/includes/CarlaNative.h b/source/includes/CarlaNative.h index 94d02efaa..54154d11e 100644 --- a/source/includes/CarlaNative.h +++ b/source/includes/CarlaNative.h @@ -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; diff --git a/source/includes/CarlaNative.hpp b/source/includes/CarlaNative.hpp index 6a63b6dbe..3c410c246 100644 --- a/source/includes/CarlaNative.hpp +++ b/source/includes/CarlaNative.hpp @@ -619,7 +619,7 @@ public: \ ClassName::_set_state, \ ClassName::_dispatcher, \ ClassName::_render_inline_display, \ - 0, 0, nullptr + 0, 0, nullptr, nullptr // -------------------------------------------------------------------------------------------------------------------- diff --git a/source/native-plugins/_data.cpp b/source/native-plugins/_data.cpp index 420ae8b70..68cd1d79d 100644 --- a/source/native-plugins/_data.cpp +++ b/source/native-plugins/_data.cpp @@ -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 diff --git a/source/native-plugins/audio-gain.c b/source/native-plugins/audio-gain.c index ce8503d0d..f0b4ced10 100644 --- a/source/native-plugins/audio-gain.c +++ b/source/native-plugins/audio-gain.c @@ -338,9 +338,7 @@ static const NativePluginDescriptor audiogainStereoDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = audiogain_dispatcher, - - .render_inline_display = NULL + .dispatcher = audiogain_dispatcher }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/bypass.c b/source/native-plugins/bypass.c index 1a50e210d..da09e4fd8 100644 --- a/source/native-plugins/bypass.c +++ b/source/native-plugins/bypass.c @@ -92,9 +92,7 @@ static const NativePluginDescriptor bypassDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL, - - .render_inline_display = NULL + .dispatcher = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/lfo.c b/source/native-plugins/lfo.c index fd7316382..bc931f3ba 100644 --- a/source/native-plugins/lfo.c +++ b/source/native-plugins/lfo.c @@ -312,9 +312,7 @@ static const NativePluginDescriptor lfoDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL, - - .render_inline_display = NULL + .dispatcher = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-channel-ab.c b/source/native-plugins/midi-channel-ab.c index 5cbfa7eb0..821e1345b 100644 --- a/source/native-plugins/midi-channel-ab.c +++ b/source/native-plugins/midi-channel-ab.c @@ -201,9 +201,7 @@ static const NativePluginDescriptor midichanabDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL, - - .render_inline_display = NULL + .dispatcher = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-channel-filter.c b/source/native-plugins/midi-channel-filter.c index eeab5a77e..11d1524b2 100644 --- a/source/native-plugins/midi-channel-filter.c +++ b/source/native-plugins/midi-channel-filter.c @@ -192,9 +192,7 @@ static const NativePluginDescriptor midichanfilterDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL, - - .render_inline_display = NULL + .dispatcher = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-channelize.c b/source/native-plugins/midi-channelize.c index a8280a6e1..9ad42cd39 100644 --- a/source/native-plugins/midi-channelize.c +++ b/source/native-plugins/midi-channelize.c @@ -200,9 +200,7 @@ static const NativePluginDescriptor midichannelizeDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL, - - .render_inline_display = NULL + .dispatcher = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-gain.c b/source/native-plugins/midi-gain.c index 5ee4a8af2..84a1351e4 100644 --- a/source/native-plugins/midi-gain.c +++ b/source/native-plugins/midi-gain.c @@ -262,9 +262,7 @@ static const NativePluginDescriptor midigainDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL, - - .render_inline_display = NULL + .dispatcher = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-join.c b/source/native-plugins/midi-join.c index e5329e946..08a33121e 100644 --- a/source/native-plugins/midi-join.c +++ b/source/native-plugins/midi-join.c @@ -139,9 +139,7 @@ static const NativePluginDescriptor midijoinDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL, - - .render_inline_display = NULL + .dispatcher = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-split.c b/source/native-plugins/midi-split.c index 15a2c6964..6488b7bb8 100644 --- a/source/native-plugins/midi-split.c +++ b/source/native-plugins/midi-split.c @@ -132,9 +132,7 @@ static const NativePluginDescriptor midisplitDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL, - - .render_inline_display = NULL + .dispatcher = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-through.c b/source/native-plugins/midi-through.c index 150fe3bc2..c1548ac2a 100644 --- a/source/native-plugins/midi-through.c +++ b/source/native-plugins/midi-through.c @@ -113,9 +113,7 @@ static const NativePluginDescriptor midithroughDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL, - - .render_inline_display = NULL + .dispatcher = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-to-cv.c b/source/native-plugins/midi-to-cv.c index d55e16f8c..e814858b5 100644 --- a/source/native-plugins/midi-to-cv.c +++ b/source/native-plugins/midi-to-cv.c @@ -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 ⊀ + case 1: + npr.minimum = 0.0f; + npr.maximum = 10.5f; + return ⊀ + case 2: + npr.minimum = 0.0f; + npr.maximum = 10.0f; + return ⊀ + 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, diff --git a/source/native-plugins/midi-transpose.c b/source/native-plugins/midi-transpose.c index 9a3ca81bf..3ff57abda 100644 --- a/source/native-plugins/midi-transpose.c +++ b/source/native-plugins/midi-transpose.c @@ -225,9 +225,7 @@ static const NativePluginDescriptor miditransposeDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL, - - .render_inline_display = NULL + .dispatcher = NULL }; // -----------------------------------------------------------------------