From 134c75166753e529eab95e2490d5addc658bb091 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Wed, 7 Jul 2021 02:30:20 +0200 Subject: [PATCH] :bug: Fix dac and adc output --- src/lib/ugen.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/ugen.c b/src/lib/ugen.c index 51a42fc9..94aafb72 100644 --- a/src/lib/ugen.c +++ b/src/lib/ugen.c @@ -16,15 +16,20 @@ static TICK(dac_tick) { m_float *out = ((VM *)u->module.gen.data)->bbq->out; uint i = 0; - do out[i] = UGEN(u->connect.multi->channel[i])->in; - while (++i < u->connect.multi->n_out); + m_float sum = 0; + do { + sum += out[i] = UGEN(u->connect.multi->channel[i])->in; + } while (++i < u->connect.multi->n_out); + u->out = sum / u->connect.multi->n_out; } static TICK(adc_tick) { const m_float *in = ((VM *)u->module.gen.data)->bbq->in; uint i = 0; - do UGEN(u->connect.multi->channel[i])->out = in[i]; + m_float sum = 0; + do sum += UGEN(u->connect.multi->channel[i])->out = in[i]; while (++i < u->connect.multi->n_out); + u->out = sum / u->connect.multi->n_out; } #define COMPUTE(a) \ -- 2.43.0