diff options
author | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2017-03-22 08:36:32 +0100 |
---|---|---|
committer | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2017-03-22 08:36:32 +0100 |
commit | e524c7f5bd0994401a8bb0dd66fc30e88c84d727 (patch) | |
tree | c83a1bdddd5cfa59aebfcd5809c6565ad57d368b | |
parent | e5530df06577e3bc454cb62371cc587dd68074a7 (diff) | |
download | vm.lv2-e524c7f5bd0994401a8bb0dd66fc30e88c84d727.tar.xz |
handle rand separate from transport.
-rw-r--r-- | vm.c | 8 | ||||
-rw-r--r-- | vm.h | 22 |
2 files changed, 20 insertions, 10 deletions
@@ -67,7 +67,7 @@ struct _plughandle_t { vm_stack_t stack; bool needs_recalc; bool needs_sync; - bool is_dynamic; + vm_status_t status; 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->is_dynamic = vm_deserialize(handle->api, &handle->forge, handle->cmds, + handle->status = 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->is_dynamic) + if(handle->status & VM_STATUS_HAS_TIME) handle->needs_recalc = true; } @@ -297,7 +297,7 @@ run(LV2_Handle instance, uint32_t nsamples) } } - if(handle->needs_recalc) + if(handle->needs_recalc || (handle->status & VM_STATUS_HAS_RAND) ) { _stack_clear(&handle->stack); @@ -50,6 +50,7 @@ #include <props.lv2/props.h> +typedef enum _vm_status_t vm_status_t; typedef enum _opcode_enum_t opcode_enum_t; typedef enum _command_enum_t command_enum_t; typedef struct _command_t command_t; @@ -69,6 +70,12 @@ struct _vm_api_impl_t { LV2_URID urid; }; +enum _vm_status_t { + VM_STATUS_STATIC = (0 << 0), + VM_STATUS_HAS_TIME = (1 << 1), + VM_STATUS_HAS_RAND = (1 << 2), +}; + enum _opcode_enum_t{ OP_NOP = 0, @@ -582,14 +589,14 @@ vm_serialize(vm_api_impl_t *impl, LV2_Atom_Forge *forge, const command_t *cmds) return ref; } -static inline bool +static inline vm_status_t vm_deserialize(vm_api_impl_t *impl, LV2_Atom_Forge *forge, command_t *cmds, uint32_t size, const LV2_Atom *body) { command_t *cmd = cmds; memset(cmds, 0x0, sizeof(command_t)*ITEMS_MAX); - bool is_dynamic = false; + vm_status_t state = VM_STATUS_STATIC; LV2_ATOM_TUPLE_BODY_FOREACH(body, size, item) { @@ -633,10 +640,13 @@ vm_deserialize(vm_api_impl_t *impl, LV2_Atom_Forge *forge, || (cmd->op == OP_BPM) || (cmd->op == OP_FRAME) //|| (cmd->op == OP_FPS) // is constant - || (cmd->op == OP_SPEED) - || (cmd->op == OP_RAND) ) + || (cmd->op == OP_SPEED) ) + { + state |= VM_STATUS_HAS_TIME; + } + else if(cmd->op == OP_RAND) { - is_dynamic = true; + state |= VM_STATUS_HAS_RAND; } } else @@ -650,7 +660,7 @@ vm_deserialize(vm_api_impl_t *impl, LV2_Atom_Forge *forge, break; } - return is_dynamic; + return state; } #endif // _VM_LV2_H |