const m_bool);
ANN void ugen_connect(const UGen lhs, const UGen rhs);
ANN void ugen_disconnect(const UGen lhs, const UGen rhs);
+ANN void compute_mono(const UGen u);
#endif
ANN static inline void vm_run(const VM *vm) {
vm_prepare(vm, NULL);
}
+ANN void vm_run_audio(const VM *vm);
ANEW VM * new_vm(MemPool, const bool);
ANN void vm_lock(VM const *);
ANN void vm_unlock(VM const *);
#include "object.h" // fork_clean
#include "pass.h" // fork_clean
#include "shreduler_private.h"
+#include "ugen.h"
ANN m_bool gwion_audio(const Gwion gwion) {
Driver *const di = gwion->vm->bbq;
return shred;
}
+ANN void gwion_cpy_blackhole(const Gwion gwion) {
+ dummy_driver(gwion->vm->bbq->driver);
+ const M_Object o = new_M_UGen(gwion);
+ const UGen u = UGEN(o);
+ ugen_ini(gwion, u, 1, 1);
+ ugen_gen(gwion, u, compute_mono, o, 0);
+ vector_add(&gwion->vm->ugen, (vtype)u);
+}
+
ANN VM *gwion_cpy(const VM *src) {
const Gwion gwion = mp_calloc(src->gwion->mp, Gwion);
- gwion->vm = new_vm(src->gwion->mp, false);
+ gwion->vm = new_vm(src->gwion->mp, true);
gwion->vm->gwion = gwion;
gwion->vm->bbq->si = soundinfo_cpy(src->gwion->mp, src->bbq->si);
gwion->emit = src->gwion->emit;
gwion->st = src->gwion->st;
gwion->mp = src->gwion->mp;
gwion->type = src->gwion->type;
+ gwion_cpy_blackhole(gwion);
return gwion->vm;
}
ANN static inline void free_gwion_cpy(const Gwion gwion, const VM_Shred shred) {
gwion_end_child(shred, gwion);
+ const UGen u = (UGen)vector_front(&gwion->vm->ugen);
+ M_Object blackhole = u->module.gen.data;
+ release(blackhole, shred);
free_vm(gwion->vm);
free_gwiondata_cpy(gwion->mp, gwion->data);
mp_free(gwion->mp, Gwion, gwion);
#include "emit.h"
#include "specialid.h"
#include "gwi.h"
+#include "ugen.h"
static m_int o_fork_thread, o_shred_cancel,
o_fork_done, o_fork_ev;
MUTEX_UNLOCK(vm->shreduler->mutex);
}
+static MFUN(shred_blackhole) {
+ VM *vm = ME(o)->info->vm;
+ const UGen u = (UGen)vector_front(&vm->ugen);
+ M_Object blackhole = u->module.gen.data;
+ // adding ref for the moment
+ blackhole->ref++;
+ *(void**)RETURN = u->module.gen.data;
+}
+
struct ThreadLauncher {
MUTEX_TYPE mutex;
THREAD_COND_TYPE cond;
// THREAD_COND_CLEANUP(tl->cond);
// MUTEX_CLEANUP(tl->mutex);
while (fork_running(vm, me)) {
- vm_run(vm);
+ vm_run_audio(vm);
++vm->bbq->pos;
}
gwion_end_child(ME(me), vm->gwion);
GWI_BB(gwi_func_end(gwi, shred_unlock, ae_flag_none))
gwi_func_ini(gwi, "float", "get_now");
GWI_BB(gwi_func_end(gwi, shred_now, ae_flag_none))
+
+ gwi_func_ini(gwi, "UGen", "get_blackhole");
+ GWI_BB(gwi_func_end(gwi, shred_blackhole, ae_flag_none))
+
+
GWI_BB(gwi_class_end(gwi))
SET_FLAG(t_shred, abstract | ae_flag_final);
gwi->gwion->type[et_shred] = t_shred;
UGEN(rhs)->module.gen.trig,
TRIG_EX)
- static CTOR(ugen_ctor) {
+static CTOR(ugen_ctor) {
UGEN(o) = new_UGen(shred->info->mp);
vector_add(&shred->info->vm->ugen, (vtype)UGEN(o));
}
const M_Object o = new_M_UGen(gwi->gwion);
const UGen u = UGEN(o);
ugen_ini(vm->gwion, u, imp->nchan, imp->nchan);
- ugen_gen(vm->gwion, u, imp->tick, (void *)imp->vm, 0);
+// ugen_gen(vm->gwion, u, imp->tick, (void *)imp->vm, 0);
+ ugen_gen(vm->gwion, u, imp->tick, o, 0);
vector_add(&vm->ugen, (vtype)u);
gwi_item_ini(gwi, "UGen", imp->name);
gwi_item_end(gwi, ae_flag_const, obj, o);
MUTEX_UNLOCK(vm->shreduler->mutex);
}
-static void vm_run_audio(const VM *vm) {
+ANN void vm_run_audio(const VM *vm) {
vm_run(vm);
vm_ugen_init(vm);
}