DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 86bd8079cd3bd665d75edbb986d0c9dbecb1570d
parent d6d1d3b55c2737a9a0c13f69ee76238917ad62e3
Author: grejppi <grejppi@users.noreply.github.com>
Date:   Sun,  7 Jan 2018 20:17:40 +0200

Explicitly state supported LV2 options & use param:sampleRate (#29)

* Explicitly state supported options and use the correct sampleRate

* Accept lv2:sampleRate too just in case

* Typo

* Style fix

* Remove lv2:sampleRate

* Remove unnecessary newlines

* Missing semicolon

Diffstat:
Mdistrho/src/DistrhoPluginLV2.cpp | 11++++++-----
Mdistrho/src/DistrhoPluginLV2export.cpp | 16+++++++++++++---
2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/distrho/src/DistrhoPluginLV2.cpp b/distrho/src/DistrhoPluginLV2.cpp @@ -23,6 +23,7 @@ #include "lv2/instance-access.h" #include "lv2/midi.h" #include "lv2/options.h" +#include "lv2/parameters.h" #include "lv2/state.h" #include "lv2/time.h" #include "lv2/urid.h" @@ -685,7 +686,7 @@ public: { if (options[i].type == fURIDs.atomInt) { - const int bufferSize(*(const int*)options[i].value); + const int32_t bufferSize(*(const int32_t*)options[i].value); fPlugin.setBufferSize(bufferSize); } else @@ -697,7 +698,7 @@ public: { if (options[i].type == fURIDs.atomInt) { - const int bufferSize(*(const int*)options[i].value); + const int32_t bufferSize(*(const int32_t*)options[i].value); fPlugin.setBufferSize(bufferSize); } else @@ -705,11 +706,11 @@ public: d_stderr("Host changed maxBlockLength but with wrong value type"); } } - else if (options[i].key == fUridMap->map(fUridMap->handle, LV2_CORE__sampleRate)) + else if (options[i].key == fUridMap->map(fUridMap->handle, LV2_PARAMETERS__sampleRate)) { - if (options[i].type == fURIDs.atomDouble) + if (options[i].type == fURIDs.atomFloat) { - const double sampleRate(*(const double*)options[i].value); + const float sampleRate(*(const float*)options[i].value); fSampleRate = sampleRate; fPlugin.setSampleRate(sampleRate); } diff --git a/distrho/src/DistrhoPluginLV2export.cpp b/distrho/src/DistrhoPluginLV2export.cpp @@ -201,6 +201,7 @@ void lv2_generate_ttl(const char* const basename) #ifdef DISTRHO_PLUGIN_BRAND pluginString += "@prefix mod: <http://moddevices.com/ns/mod#> .\n"; #endif + pluginString += "@prefix opts: <" LV2_OPTIONS_PREFIX "> .\n"; pluginString += "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"; pluginString += "@prefix rsz: <" LV2_RESIZE_PORT_PREFIX "> .\n"; #if DISTRHO_PLUGIN_HAS_UI @@ -254,6 +255,12 @@ void lv2_generate_ttl(const char* const basename) #endif pluginString += ";\n\n"; + // supportedOptions + pluginString += " opts:supportedOption <" LV2_BUF_SIZE__nominalBlockLength "> ,\n"; + pluginString += " <" LV2_BUF_SIZE__maxBlockLength "> ,\n"; + pluginString += " <" LV2_PARAMETERS__sampleRate "> ;\n"; + pluginString += "\n"; + // UI #if DISTRHO_PLUGIN_HAS_UI pluginString += " ui:ui <" DISTRHO_UI_URI "> ;\n"; @@ -583,8 +590,9 @@ void lv2_generate_ttl(const char* const basename) std::fstream uiFile(uiTTL, std::ios::out); String uiString; - uiString += "@prefix lv2: <" LV2_CORE_PREFIX "> .\n"; - uiString += "@prefix ui: <" LV2_UI_PREFIX "> .\n"; + uiString += "@prefix lv2: <" LV2_CORE_PREFIX "> .\n"; + uiString += "@prefix ui: <" LV2_UI_PREFIX "> .\n"; + uiString += "@prefix opts: <" LV2_OPTIONS_PREFIX "> .\n"; uiString += "\n"; uiString += "<" DISTRHO_UI_URI ">\n"; @@ -603,7 +611,9 @@ void lv2_generate_ttl(const char* const basename) uiString += "\n"; # endif uiString += " lv2:requiredFeature <" LV2_OPTIONS__options "> ,\n"; - uiString += " <" LV2_URID__map "> .\n"; + uiString += " <" LV2_URID__map "> ;\n"; + + uiString += " opts:supportedOption <" LV2_PARAMETERS__sampleRate "> .\n"; uiFile << uiString << std::endl; uiFile.close();