demux_sh

demultiplexer with sample and hold.connect inlet in to outlet number s. the output value of output number s will be held until the value of inlet in changes. when s changes,the output value of the previous outlet number s will be held.
Author: robert schirmer
License: who cares
Github: rbrt/control/demux_sh.axo

Inlets

frac32 in

int32.positive s

Outlets

frac32 o0

frac32 o1

frac32 o2

frac32 o3

Declaration
int32_t hold0;
int32_t hold1;
int32_t hold2;
int32_t hold3;
int32_t prev;
Init
hold0 = 0;
hold1 = 0;
hold2 = 0;
hold3 = 0;
prev = 0;
Control Rate
if ((inlet_s == 0) && (inlet_in != prev)) {
  hold0 = inlet_in;
  outlet_o0 = inlet_in;
} else {
  outlet_o0 = hold0;
}

if ((inlet_s == 1) && (inlet_in != prev)) {
  hold1 = inlet_in;
  outlet_o1 = inlet_in;
} else {
  outlet_o1 = hold1;
}

if ((inlet_s == 2) && (inlet_in != prev)) {
  hold2 = inlet_in;
  outlet_o2 = inlet_in;
} else {
  outlet_o2 = hold2;
}

if ((inlet_s == 3) && (inlet_in != prev)) {
  hold3 = inlet_in;
  outlet_o3 = inlet_in;
} else {
  outlet_o3 = hold3;
}

prev = inlet_in;

Privacy

© 2024 Zrna Research