aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-05-08 07:57:46 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-05-08 07:57:46 +0200
commitd1185a38c9b36e3e4f832146ed75d936c79c5ed9 (patch)
treea3b10e2ec3457dbfeccccf1ac033a8886433a2c1
parentee75edc7c175023f4de6aac921352536d189e772 (diff)
downloadsynthpod-d1185a38c9b36e3e4f832146ed75d936c79c5ed9.tar.xz
app/nk: improve parameter automation.
* supported types: atom:Bool/Int/Long/Float/Double.
-rw-r--r--VERSION2
-rw-r--r--app/synthpod_app.c37
-rw-r--r--app/synthpod_app_private.h1
-rw-r--r--app/synthpod_app_state.c4
-rw-r--r--app/synthpod_app_ui.c9
-rw-r--r--plugins/synthpod_common_nk.c5
6 files changed, 51 insertions, 7 deletions
diff --git a/VERSION b/VERSION
index 69fb3b4b..b521b7c7 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.4915
+0.1.4917
diff --git a/app/synthpod_app.c b/app/synthpod_app.c
index 5c5dda4e..02429bc6 100644
--- a/app/synthpod_app.c
+++ b/app/synthpod_app.c
@@ -222,7 +222,7 @@ _sp_app_process_single_run(mod_t *mod, uint32_t nsamples)
}
else if( (port->type == PORT_TYPE_ATOM) && automation->property )
{
- const int32_t i32 = floorf(rel * 127.f); //FIXME use correct scaling
+ const float f32 = rel * 127.f; //FIXME use correct scaling
LV2_Atom_Sequence *control = PORT_BASE_ALIGNED(port);
LV2_Atom_Event *dst = lv2_atom_sequence_end(&control->body, control->atom.size);
@@ -230,14 +230,41 @@ _sp_app_process_single_run(mod_t *mod, uint32_t nsamples)
lv2_atom_forge_set_buffer(&app->forge, (uint8_t *)dst, PORT_SIZE(port) - control->atom.size - sizeof(LV2_Atom));
- if( lv2_atom_forge_frame_time(&app->forge, nsamples - 1)
+ LV2_Atom_Forge_Ref ref;
+ ref = lv2_atom_forge_frame_time(&app->forge, nsamples - 1)
&& lv2_atom_forge_object(&app->forge, &obj_frame, 0, app->regs.patch.set.urid)
&& lv2_atom_forge_key(&app->forge, app->regs.patch.property.urid)
&& lv2_atom_forge_urid(&app->forge, automation->property)
- && lv2_atom_forge_key(&app->forge, app->regs.patch.value.urid)
- && lv2_atom_forge_int(&app->forge, i32) ) //FIXME use correct type
+ && lv2_atom_forge_key(&app->forge, app->regs.patch.value.urid);
+ if(ref)
{
- lv2_atom_forge_pop(&app->forge, &obj_frame);
+ if(automation->range == app->forge.Bool)
+ {
+ const int32_t i32 = (f32 != 0.f);
+ ref = lv2_atom_forge_bool(&app->forge, i32);
+ }
+ else if(automation->range == app->forge.Int)
+ {
+ const int32_t i32 = floorf(f32);
+ ref = lv2_atom_forge_int(&app->forge, i32);
+ }
+ else if(automation->range == app->forge.Long)
+ {
+ const int64_t i64 = floorf(f32);
+ ref = lv2_atom_forge_long(&app->forge, i64);
+ }
+ else if(automation->range == app->forge.Float)
+ {
+ ref = lv2_atom_forge_float(&app->forge, f32);
+ }
+ else if(automation->range == app->forge.Double)
+ {
+ ref = lv2_atom_forge_double(&app->forge, f32);
+ }
+ //FIXME support more types
+
+ if(ref)
+ lv2_atom_forge_pop(&app->forge, &obj_frame);
control->atom.size += sizeof(LV2_Atom_Event) + dst->body.size;
}
diff --git a/app/synthpod_app_private.h b/app/synthpod_app_private.h
index 087daed2..d238dc81 100644
--- a/app/synthpod_app_private.h
+++ b/app/synthpod_app_private.h
@@ -226,6 +226,7 @@ struct _auto_t {
auto_type_t type;
uint32_t index;
LV2_URID property;
+ LV2_URID range;
union {
midi_auto_t midi;
diff --git a/app/synthpod_app_state.c b/app/synthpod_app_state.c
index 75d0cd96..70bdc916 100644
--- a/app/synthpod_app_state.c
+++ b/app/synthpod_app_state.c
@@ -1034,7 +1034,9 @@ sp_app_save(sp_app_t *app, LV2_State_Store_Function store,
if(automation->property)
{
ref = lv2_atom_forge_key(forge, app->regs.patch.property.urid)
- && lv2_atom_forge_urid(forge, automation->property);
+ && lv2_atom_forge_urid(forge, automation->property)
+ && lv2_atom_forge_key(forge, app->regs.rdfs.range.urid)
+ && lv2_atom_forge_urid(forge, automation->range);
}
else
{
diff --git a/app/synthpod_app_ui.c b/app/synthpod_app_ui.c
index 3eb4157e..22edfa57 100644
--- a/app/synthpod_app_ui.c
+++ b/app/synthpod_app_ui.c
@@ -1191,6 +1191,10 @@ _sp_app_from_ui_patch_get(sp_app_t *app, const LV2_Atom *atom)
ref = lv2_atom_forge_key(&app->forge, app->regs.patch.property.urid);
if(ref)
ref = lv2_atom_forge_urid(&app->forge, automation->property);
+ if(ref)
+ ref = lv2_atom_forge_key(&app->forge, app->regs.rdfs.range.urid);
+ if(ref)
+ ref = lv2_atom_forge_urid(&app->forge, automation->range);
}
else
{
@@ -1843,6 +1847,7 @@ _midi_automation_list_add(sp_app_t *app, const LV2_Atom_Object *obj)
const LV2_Atom_URID *src_module = NULL;
const LV2_Atom *src_symbol = NULL;
const LV2_Atom_URID *src_property = NULL;
+ const LV2_Atom_URID *src_range = NULL;
const LV2_Atom_Int *src_channel = NULL;
const LV2_Atom_Int *src_controller = NULL;
const LV2_Atom_Int *src_min = NULL;
@@ -1852,6 +1857,7 @@ _midi_automation_list_add(sp_app_t *app, const LV2_Atom_Object *obj)
app->regs.synthpod.sink_module.urid, &src_module,
app->regs.synthpod.sink_symbol.urid, &src_symbol,
app->regs.patch.property.urid, &src_property,
+ app->regs.rdfs.range.urid, &src_range,
app->regs.midi.channel.urid, &src_channel,
app->regs.midi.controller_number.urid, &src_controller,
app->regs.core.minimum.urid, &src_min,
@@ -1864,6 +1870,8 @@ _midi_automation_list_add(sp_app_t *app, const LV2_Atom_Object *obj)
? LV2_ATOM_BODY_CONST(src_symbol) : NULL;
const LV2_URID src_prop = src_property
? src_property->body : 0;
+ const LV2_URID src_ran = src_range
+ ? src_range->body : 0;
mod_t *mod = _mod_find_by_urn(app, src_urn);
if(mod)
@@ -1884,6 +1892,7 @@ _midi_automation_list_add(sp_app_t *app, const LV2_Atom_Object *obj)
automation->type = AUTO_TYPE_MIDI;
automation->index = port->index;
automation->property = src_prop;
+ automation->range = src_ran;
automation->midi.channel = src_channel ? src_channel->body : -1;
automation->midi.controller = src_controller ? src_controller->body : -1;
diff --git a/plugins/synthpod_common_nk.c b/plugins/synthpod_common_nk.c
index 87d49bd7..b63fffbd 100644
--- a/plugins/synthpod_common_nk.c
+++ b/plugins/synthpod_common_nk.c
@@ -903,6 +903,11 @@ _patch_param_automation_internal(plughandle_t *handle, param_t *source_param)
if(ref)
ref = lv2_atom_forge_urid(&handle->forge, source_param->property);
+ if(ref)
+ ref = lv2_atom_forge_key(&handle->forge, handle->regs.rdfs.range.urid);
+ if(ref)
+ ref = lv2_atom_forge_urid(&handle->forge, source_param->range);
+
return ref;
}