commit 68b3ca4abe46ee7386cc20574964d1c62c0c1e21
parent 965cae4fc554fd63af77d5757fa9d81c6b7f327d
Author: falkTX <falktx@gmail.com>
Date: Sun, 24 Dec 2017 18:21:29 +0000
Correct use of LV2 UI sample rate
Diffstat:
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/distrho/src/DistrhoUILV2.cpp b/distrho/src/DistrhoUILV2.cpp
@@ -23,6 +23,7 @@
#include "lv2/data-access.h"
#include "lv2/instance-access.h"
#include "lv2/options.h"
+#include "lv2/parameters.h"
#include "lv2/ui.h"
#include "lv2/urid.h"
#include "lv2/lv2_kxstudio_properties.h"
@@ -175,17 +176,17 @@ public:
{
for (int i=0; options[i].key != 0; ++i)
{
- if (options[i].key == fUridMap->map(fUridMap->handle, LV2_CORE__sampleRate))
+ if (options[i].key == fUridMap->map(fUridMap->handle, LV2_PARAMETERS__sampleRate))
{
- if (options[i].type == fUridMap->map(fUridMap->handle, LV2_ATOM__Double))
+ if (options[i].type == fUridMap->map(fUridMap->handle, LV2_ATOM__Float))
{
- const double sampleRate(*(const double*)options[i].value);
+ const float sampleRate(*(const float*)options[i].value);
fUI.setSampleRate(sampleRate);
continue;
}
else
{
- d_stderr("Host changed sampleRate but with wrong value type");
+ d_stderr("Host changed UI sample-rate but with wrong value type");
continue;
}
}
@@ -402,23 +403,23 @@ static LV2UI_Handle lv2ui_instantiate(const LV2UI_Descriptor*, const char* uri,
if (options != nullptr)
{
- const LV2_URID uridSampleRate(uridMap->map(uridMap->handle, LV2_CORE__sampleRate));
+ const LV2_URID uridSampleRate(uridMap->map(uridMap->handle, LV2_PARAMETERS__sampleRate));
for (int i=0; options[i].key != 0; ++i)
{
if (options[i].key == uridSampleRate)
{
- if (options[i].type == uridMap->map(uridMap->handle, LV2_ATOM__Double))
- d_lastUiSampleRate = *(const double*)options[i].value;
+ if (options[i].type == uridMap->map(uridMap->handle, LV2_ATOM__Float))
+ d_lastUiSampleRate = *(const float*)options[i].value;
else
- d_stderr("Host provides sampleRate but has wrong value type");
+ d_stderr("Host provides UI sample-rate but has wrong value type");
break;
}
}
}
- if (d_lastUiSampleRate == 0.0)
+ if (d_lastUiSampleRate < 1.0)
{
d_stdout("WARNING: this host does not send sample-rate information for LV2 UIs, using 44100 as fallback (this could be wrong)");
d_lastUiSampleRate = 44100.0;