]> Nishi Git Mirror - gwion.git/commitdiff
:bug: Fix dac and adc output
authorJérémie Astor <fennecdjay@gmail.com>
Wed, 7 Jul 2021 00:30:20 +0000 (02:30 +0200)
committerJérémie Astor <fennecdjay@gmail.com>
Wed, 7 Jul 2021 00:30:20 +0000 (02:30 +0200)
src/lib/ugen.c

index 51a42fc9aced97e9f1bd5f448b984dee5cf23eed..94aafb7257c2112ca4bd64924747826f57bda0ad 100644 (file)
 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)                                                             \