demux_sh 2

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 2.axo

Inlets

frac32 in

int32.positive s

Outlets

frac32 o0

frac32 o1

Declaration
int32_t hold0;
int32_t hold1;
int32_t prev;
Init
hold0 = 0;
hold1 = 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;
}

prev = inlet_in;

Privacy

© 2024 Zrna Research