Commit 7311a1b6 authored by Hanspeter Portner's avatar Hanspeter Portner

api: always return params:sampleRate.

* even if not part of host's options array
parent 44444e5d
Pipeline #26036418 passed with stages
in 3 minutes and 43 seconds
......@@ -322,6 +322,12 @@ _lopts__index(lua_State *L)
}
}
if(key == moony->uris.param_sampleRate)
{
_latom_body_new(L, &moony->sample_rate.atom, &moony->sample_rate.body, false);
return 1;
}
lua_pushnil(L); // not found
return 1;
}
......@@ -1168,8 +1174,6 @@ __non_realtime int
moony_init(moony_t *moony, const char *subject, double sample_rate,
const LV2_Feature *const *features, size_t mem_size, bool testing)
{
moony->sample_rate = sample_rate;
atomic_init(&moony->state_atom_new, 0);
atomic_init(&moony->vm_new, 0);
atomic_init(&moony->err_new, 0);
......@@ -1325,6 +1329,10 @@ moony_init(moony_t *moony, const char *subject, double sample_rate,
if(moony->log)
lv2_log_logger_init(&moony->logger, moony->map, moony->log);
moony->sample_rate.atom.size = sizeof(float);
moony->sample_rate.atom.type = moony->forge.Float;
moony->sample_rate.body = sample_rate;
latom_driver_hash_t *latom_driver_hash = moony->atom_driver_hash;
unsigned pos = 0;
......@@ -1786,7 +1794,7 @@ moony_open(moony_t *moony, moony_vm_t *vm, lua_State *L)
lua_newtable(L);
{
SET_MAP(L, LV2_PARAMETERS__, sampleRate);
moony->uris.param_sampleRate = SET_MAP(L, LV2_PARAMETERS__, sampleRate);
//TODO more
}
lua_setglobal(L, "Param");
......
......@@ -304,7 +304,7 @@ _ltimeresponder(lua_State *L)
// TODO do we want to cache/reuse this, too?
timely_t *timely = lua_newuserdata(L, sizeof(timely_t)); // userdata
timely_init(timely, moony->map, moony->sample_rate, mask,
timely_init(timely, moony->map, moony->sample_rate.body, mask,
_ltimeresponder_cb, L);
timely_set_multiplier(timely, multiplier);
......
......@@ -206,7 +206,7 @@ struct _moony_t {
LV2_Atom_Forge_Ref notify_ref;
LV2_Atom_Forge notify_snapshot;
double sample_rate;
LV2_Atom_Float sample_rate;
struct {
LV2_URID moony_code;
......@@ -259,6 +259,8 @@ struct _moony_t {
LV2_URID xpress_dPitch;
LV2_URID xpress_dPressure;
LV2_URID xpress_dTimbre;
LV2_URID param_sampleRate;
} uris;
LV2_OSC_URID osc_urid;
......
......@@ -222,17 +222,8 @@ main(int argc, char **argv)
.frames2osc = _frames2osc
};
const LV2_URID param_sampleRate = map.map(map.handle, LV2_PARAMETERS__sampleRate);
const LV2_URID atom_Float = map.map(map.handle, LV2_ATOM__Float);
const float srate = 48000.f;
LV2_Options_Option opts [] = {
{
.key = param_sampleRate,
.size = sizeof(float),
.type = atom_Float,
.value = &srate
},
{
.key = 0,
.value =NULL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment