From: Jérémie Astor Date: Fri, 6 Dec 2019 15:18:58 +0000 (+0100) Subject: :art: Add default_tick() X-Git-Tag: nightly~2069^2~5 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=e9729c343ca2e811c3d650476c002fa923cf9f27;p=gwion.git :art: Add default_tick() --- 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() >>>;