From e9729c343ca2e811c3d650476c002fa923cf9f27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 6 Dec 2019 16:18:58 +0100 Subject: [PATCH] :art: Add default_tick() --- src/lib/modules.c | 12 ++++++++++++ tests/UsrUgen/UsrUGen.gw | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/lib/modules.c b/src/lib/modules.c index 48d692a9..f96c0b9f 100644 --- a/src/lib/modules.c +++ b/src/lib/modules.c @@ -239,6 +239,16 @@ ANN static void code_prepare(const VM_Code code) { } } +static MFUN(default_tick) { + struct UUGen_ *uu = UGEN(o)->module.gen.data; + if(uu->shred) { + free_vm_shred(uu->shred); + uu->shred = NULL; + } + UGEN(o)->module.gen.tick = id_tick; + release(o, shred); +} + static INSTR(UsrUGenTick) { const m_uint offset = !instr->m_val ? SZ_INT : 0; shred->reg -= SZ_INT*2 - offset; @@ -270,6 +280,8 @@ static OP_EMIT(opem_usrugen) { static GWION_IMPORT(usrugen) { GWI_OB(gwi_class_ini(gwi, "UsrUGen", "UGen")) gwi_class_xtor(gwi, usrugen_ctor, usrugen_dtor); + GWI_BB(gwi_func_ini(gwi, "void", "default_tick")) + GWI_BB(gwi_func_end(gwi, default_tick, 0)) GWI_BB(gwi_class_end(gwi)) GWI_BB(gwi_oper_ini(gwi, "@function", "UsrUGen", "UsrUGen")) GWI_BB(gwi_oper_add(gwi, opck_usrugen)) diff --git a/tests/UsrUgen/UsrUGen.gw b/tests/UsrUgen/UsrUGen.gw index 4e989c0c..4c1792b0 100644 --- a/tests/UsrUgen/UsrUGen.gw +++ b/tests/UsrUgen/UsrUGen.gw @@ -24,3 +24,7 @@ samp => now; <<>>; samp => now; <<< u.last() >>>; + +u.default_tick(); +samp => now; +<<< u.last() >>>; -- 2.43.0