demux smooth 8

Smoothing Demultiplexer. Connects inlet i to outlet number s. Other outlets copy their corresponding default inlets. Output values are smoothed exponentially with adjustable rise and fall time.
Author: Johannes Taelman (add. Peter Witzel)
License: BSD
Github: cpwitz/demux/demux smooth 8.axo

Inlets

frac32 input

frac32 default 0

frac32 default 1

frac32 default 2

frac32 default 3

frac32 default 4

frac32 default 5

frac32 default 6

frac32 default 7

int32.positive select

Outlets

frac32 output 0

frac32 output 1

frac32 output 2

frac32 output 3

frac32 output 4

frac32 output 5

frac32 output 6

frac32 output 7

Parameters

frac32.u.map risetime

frac32.u.map falltime

Declaration
static const int outputs = 8;
int32_t val[outputs];
int32_t tval[outputs];
Init
int i;
for (i = 0; i < outputs; i++) {
  val[i] = 0;
  tval[i] = 0;
}
Control Rate
switch (inlet_s > 0 ? inlet_s : 0) {
case 0:
  tval[0] = inlet_i;
  tval[1] = inlet_d1;
  tval[2] = inlet_d2;
  tval[3] = inlet_d3;
  tval[4] = inlet_d4;
  tval[5] = inlet_d5;
  tval[6] = inlet_d6;
  tval[7] = inlet_d7;
  break;
case 1:
  tval[0] = inlet_d0;
  tval[1] = inlet_i;
  tval[2] = inlet_d2;
  tval[3] = inlet_d3;
  tval[4] = inlet_d4;
  tval[5] = inlet_d5;
  tval[6] = inlet_d6;
  tval[7] = inlet_d7;
  break;
case 2:
  tval[0] = inlet_d0;
  tval[1] = inlet_d1;
  tval[2] = inlet_i;
  tval[3] = inlet_d3;
  tval[4] = inlet_d4;
  tval[5] = inlet_d5;
  tval[6] = inlet_d6;
  tval[7] = inlet_d7;
  break;
case 3:
  tval[0] = inlet_d0;
  tval[1] = inlet_d1;
  tval[2] = inlet_d2;
  tval[3] = inlet_i;
  tval[4] = inlet_d4;
  tval[5] = inlet_d5;
  tval[6] = inlet_d6;
  tval[7] = inlet_d7;
  break;
case 4:
  tval[0] = inlet_d0;
  tval[1] = inlet_d1;
  tval[2] = inlet_d2;
  tval[3] = inlet_d3;
  tval[4] = inlet_i;
  tval[5] = inlet_d5;
  tval[6] = inlet_d6;
  tval[7] = inlet_d7;
  break;
case 5:
  tval[0] = inlet_d0;
  tval[1] = inlet_d1;
  tval[2] = inlet_d2;
  tval[3] = inlet_d3;
  tval[4] = inlet_d4;
  tval[5] = inlet_i;
  tval[6] = inlet_d6;
  tval[7] = inlet_d7;
  break;
case 6:
  tval[0] = inlet_d0;
  tval[1] = inlet_d1;
  tval[2] = inlet_d2;
  tval[3] = inlet_d3;
  tval[4] = inlet_d4;
  tval[5] = inlet_d5;
  tval[6] = inlet_i;
  tval[7] = inlet_d7;
  break;
case 7:
  tval[0] = inlet_d0;
  tval[1] = inlet_d1;
  tval[2] = inlet_d2;
  tval[3] = inlet_d3;
  tval[4] = inlet_d4;
  tval[5] = inlet_d5;
  tval[6] = inlet_d6;
  tval[7] = inlet_i;
  break;
default:
  tval[0] = inlet_d0;
  tval[1] = inlet_d1;
  tval[2] = inlet_d2;
  tval[3] = inlet_d3;
  tval[4] = inlet_d4;
  tval[5] = inlet_d5;
  tval[6] = inlet_d6;
  tval[7] = inlet_d7;
}
int i;
for (i = 0; i < outputs; i++) {
  // val[i]=___SMMLA(val[i]-tval[i],(-1<<26)+(param_time>>1),val[i]);
  if (tval[i] > val[i])
    val[i] =
        ___SMMLA(val[i] - tval[i], (-1 << 26) + (param_risetime >> 1), val[i]);
  else
    val[i] =
        ___SMMLA(val[i] - tval[i], (-1 << 26) + (param_falltime >> 1), val[i]);
}
outlet_o0 = val[0];
outlet_o1 = val[1];
outlet_o2 = val[2];
outlet_o3 = val[3];
outlet_o4 = val[4];
outlet_o5 = val[5];
outlet_o6 = val[6];
outlet_o7 = val[7];

Privacy

© 2024 Zrna Research