]> Nishi Git Mirror - gwion.git/commitdiff
:art: Add default_tick()
authorJérémie Astor <astor.jeremie@wanadoo.fr>
Fri, 6 Dec 2019 15:18:58 +0000 (16:18 +0100)
committerJérémie Astor <astor.jeremie@wanadoo.fr>
Fri, 6 Dec 2019 15:18:58 +0000 (16:18 +0100)
src/lib/modules.c
tests/UsrUgen/UsrUGen.gw

index 48d692a91ff8311882afe190cce039d61a300b3a..f96c0b9f15aeb05e4cc09cd3589e7269a7339870 100644 (file)
@@ -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))
index 4e989c0c3c1dc010029078ba9f6a391543bc6fb3..4c1792b0c6d56cc124645fd5c1990c5cabc44366 100644 (file)
@@ -24,3 +24,7 @@ samp => now;
 <<<t ~= u>>>;
 samp => now;
 <<< u.last() >>>;
+
+u.default_tick();
+samp => now;
+<<< u.last() >>>;