aboutsummaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-21 21:20:30 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-21 21:20:30 +0100
commite5530df06577e3bc454cb62371cc587dd68074a7 (patch)
treef7fa74f58b0fda55e1ffd32405dc8714c18d1971 /vm.c
parentd0f3a9ac228f5798a045f75376817b43666939bd (diff)
downloadvm.lv2-e5530df06577e3bc454cb62371cc587dd68074a7.tar.xz
add OP_RAND, read param:sampleRate from options.
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/vm.c b/vm.c
index 1fd989e..5540bb6 100644
--- a/vm.c
+++ b/vm.c
@@ -67,7 +67,7 @@ struct _plughandle_t {
vm_stack_t stack;
bool needs_recalc;
bool needs_sync;
- bool uses_time;
+ bool is_dynamic;
int64_t off;
@@ -134,7 +134,7 @@ _intercept_graph(void *data, LV2_Atom_Forge *forge, int64_t frames,
handle->graph_size = impl->value.size;
handle->needs_recalc = true;
- handle->uses_time = vm_deserialize(handle->api, &handle->forge, handle->cmds,
+ handle->is_dynamic = vm_deserialize(handle->api, &handle->forge, handle->cmds,
impl->value.size, impl->value.body);
handle->needs_sync = true;
@@ -157,7 +157,7 @@ _cb(timely_t *timely, int64_t frames, LV2_URID type, void *data)
{
plughandle_t *handle = data;
- if(handle->uses_time)
+ if(handle->is_dynamic)
handle->needs_recalc = true;
}
@@ -583,6 +583,11 @@ run(LV2_Handle instance, uint32_t nsamples)
const num_t c = handle->stack.regs[idx & REG_MASK];
_stack_push(&handle->stack, c);
} break;
+ case OP_RAND:
+ {
+ const num_t c = (num_t)rand() / RAND_MAX;
+ _stack_push(&handle->stack, c);
+ } break;
// time
case OP_BAR_BEAT: