Browse Source

Correct use of LV2 UI sample rate

pull/32/head
falkTX 6 years ago
parent
commit
68b3ca4abe
1 changed files with 10 additions and 9 deletions
  1. +10
    -9
      distrho/src/DistrhoUILV2.cpp

+ 10
- 9
distrho/src/DistrhoUILV2.cpp View File

@@ -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;


Loading…
Cancel
Save