aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-22 10:51:10 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-22 10:51:10 +0100
commita1d39643fd1826af7feb25d5198ee9c144e1d449 (patch)
tree570a7f974e4a7f7d8816cef7d7aabdc1b98e86f8
parentd4bae1987d3ff01ef291cd2bf667616a8f6116e3 (diff)
downloadvm.lv2-a1d39643fd1826af7feb25d5198ee9c144e1d449.tar.xz
remove long and double type handling.
-rw-r--r--VERSION2
-rw-r--r--vm.c10
-rw-r--r--vm.h19
-rw-r--r--vm_ui.c46
4 files changed, 27 insertions, 50 deletions
diff --git a/VERSION b/VERSION
index db239dc..2b8f51c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.2859
+0.1.2861
diff --git a/vm.c b/vm.c
index 3e57462..8cfb07b 100644
--- a/vm.c
+++ b/vm.c
@@ -335,21 +335,11 @@ run(LV2_Handle instance, uint32_t nsamples)
const num_t c = cmd->i32;
_stack_push(&handle->stack, c);
} break;
- case COMMAND_LONG:
- {
- const num_t c = cmd->i64;
- _stack_push(&handle->stack, c);
- } break;
case COMMAND_FLOAT:
{
const num_t c = cmd->f32;
_stack_push(&handle->stack, c);
} break;
- case COMMAND_DOUBLE:
- {
- const num_t c = cmd->f64;
- _stack_push(&handle->stack, c);
- } break;
case COMMAND_OPCODE:
{
switch(cmd->op)
diff --git a/vm.h b/vm.h
index 113b926..144a631 100644
--- a/vm.h
+++ b/vm.h
@@ -52,6 +52,7 @@
#define VM_MIN -1.f
#define VM_MAX 1.f
+#define VM_STP 0.01f
#define VM_RNG (VM_MAX - VM_MIN)
#define VM_VIS (VM_RNG * 1.1f)
@@ -130,9 +131,7 @@ enum _vm_command_enum_t {
COMMAND_OPCODE,
COMMAND_BOOL,
COMMAND_INT,
- COMMAND_LONG,
COMMAND_FLOAT,
- COMMAND_DOUBLE,
COMMAND_MAX,
};
@@ -170,9 +169,7 @@ static const char *command_labels [COMMAND_MAX] = {
[COMMAND_OPCODE] = "Op Code" ,
[COMMAND_BOOL] = "Boolean" ,
[COMMAND_INT] = "Integer" ,
- [COMMAND_LONG] = "Long" ,
[COMMAND_FLOAT] = "Float" ,
- [COMMAND_DOUBLE] = "Double"
};
static const vm_api_def_t vm_api_def [OP_MAX] = {
@@ -557,21 +554,11 @@ vm_serialize(vm_api_impl_t *impl, LV2_Atom_Forge *forge, const vm_command_t *cmd
if(ref)
ref = lv2_atom_forge_int(forge, cmd->i32);
} break;
- case COMMAND_LONG:
- {
- if(ref)
- ref = lv2_atom_forge_long(forge, cmd->i64);
- } break;
case COMMAND_FLOAT:
{
if(ref)
ref = lv2_atom_forge_float(forge, cmd->f32);
} break;
- case COMMAND_DOUBLE:
- {
- if(ref)
- ref = lv2_atom_forge_double(forge, cmd->f64);
- } break;
case COMMAND_OPCODE:
{
const LV2_URID otype = vm_api_map(impl, cmd->op);
@@ -621,7 +608,7 @@ vm_deserialize(vm_api_impl_t *impl, LV2_Atom_Forge *forge,
}
else if(item->type == forge->Long)
{
- cmd->type = COMMAND_LONG;
+ cmd->type = COMMAND_INT;
cmd->i64 = ((const LV2_Atom_Long *)item)->body;
}
else if(item->type == forge->Float)
@@ -631,7 +618,7 @@ vm_deserialize(vm_api_impl_t *impl, LV2_Atom_Forge *forge,
}
else if(item->type == forge->Double)
{
- cmd->type = COMMAND_DOUBLE;
+ cmd->type = COMMAND_FLOAT;
cmd->f64 = ((const LV2_Atom_Double *)item)->body;
}
else if(item->type == forge->URID)
diff --git a/vm_ui.c b/vm_ui.c
index c63dcbe..041681e 100644
--- a/vm_ui.c
+++ b/vm_ui.c
@@ -249,6 +249,15 @@ _expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
handle->dy = 20.f * nk_pugl_get_scale(&handle->win);
const float dy = handle->dy;
+ // mouse sensitivity for dragable property widgets
+ const bool has_control = nk_input_is_key_down(&ctx->input, NK_KEY_CTRL);
+ const bool has_shift = nk_input_is_key_down(&ctx->input, NK_KEY_SHIFT);
+ float scl = 1.f;
+ if(has_control)
+ scl /= 4;
+ if(has_shift)
+ scl /= 4;
+
if(nk_begin(ctx, "Vm", wbounds, NK_WINDOW_NO_SCROLLBAR))
{
nk_window_set_bounds(ctx, wbounds);
@@ -263,14 +272,22 @@ _expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
if(nk_group_begin(ctx, "Inputs", NK_WINDOW_TITLE | NK_WINDOW_BORDER))
{
+ float stp;
+ float fpp;
+
for(unsigned i = 0; i < CTRL_MAX; i++)
{
nk_layout_row_dynamic(ctx, dy*4, 1);
_draw_plot(ctx, handle->inp[i].vals, PLOT_MAX);
nk_layout_row_dynamic(ctx, dy, 1);
+ if(i == 0) // calculate only once
+ {
+ stp = scl * VM_STP;
+ fpp = scl * VM_RNG / nk_widget_width(ctx);
+ }
const float old_val = handle->in0[i];
- nk_property_float(ctx, input_labels[i], VM_MIN, &handle->in0[i], VM_MAX, 1.f, 1.f);
+ nk_property_float(ctx, input_labels[i], VM_MIN, &handle->in0[i], VM_MAX, stp, fpp);
if(old_val != handle->in0[i])
handle->writer(handle->controller, i + 2, sizeof(float), 0, &handle->in0[i]);
}
@@ -283,6 +300,9 @@ _expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
nk_layout_row_dynamic(ctx, dy, 2);
bool sync = false;
+ const float stp = scl * VM_STP;
+ const float fpp = scl * VM_RNG / nk_widget_width(ctx);
+
for(unsigned i = 0; i < ITEMS_MAX; i++)
{
vm_command_t *cmd = &handle->cmds[i];
@@ -314,43 +334,23 @@ _expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
case COMMAND_INT:
{
int i32 = cmd->i32;
- nk_property_int(ctx, "#", VM_MIN, &i32, VM_MAX, 1, 1.f);
+ nk_property_int(ctx, "#", INT32_MIN, &i32, INT32_MAX, 1, 1.f);
if(i32 != cmd->i32)
{
cmd->i32 = i32;
sync = true;
}
} break;
- case COMMAND_LONG:
- {
- int i64 = cmd->i64;
- nk_property_int(ctx, "#", VM_MIN, &i64, VM_MAX, 1, 1.f);
- if(i64 != cmd->i64)
- {
- cmd->i64 = i64;
- sync = true;
- }
- } break;
case COMMAND_FLOAT:
{
float f32 = cmd->f32;
- nk_property_float(ctx, "#", VM_MIN, &f32, VM_MAX, 1.f, 1.f);
+ nk_property_float(ctx, "#", -HUGE, &f32, HUGE, stp, fpp);
if(f32 != cmd->f32)
{
cmd->f32 = f32;
sync = true;
}
} break;
- case COMMAND_DOUBLE:
- {
- double f64 = cmd->f64;
- nk_property_double(ctx, "#", VM_MIN, &f64, VM_MAX, 1.f, 1.f);
- if(f64 != cmd->f64)
- {
- cmd->f64 = f64;
- sync = true;
- }
- } break;
case COMMAND_OPCODE:
{
const bool show_mnemo = true; //FIXME