comparator Doepfer A167

Doepfer A167 like comparator. Compares two inlets after scaling + offsetting them (remember to set gain 1 and gain 2 to some number, otherwise you'll get no output! outlet 1 outputs a bool signal if signal 1>signal 2 (+all subsequent offsetting and hysteresing) Outlet 2 is the inverted of outlet 1
Author: Sputnki
License: BSD
Github: sptnk/logic/comparator Doepfer A167.axo

Inlets

frac32 in1

frac32 in2

Outlets

frac32 sum

bool32 out

bool32 inv

Parameters

frac32.u.map.gain Gain1

frac32.u.map.gain Gain2

frac32.s.map Offset

frac32.u.map Hysteresis

Displays

bool32 cmp

Declaration
int32_t diff;
int32_t hyst;
bool prevstate;
bool state;
Init
prevstate = 0;
state = 0;
Control Rate
diff = (___SMMUL(param_Gain1, inlet_in1) << 1) -
       (___SMMUL(param_Gain2, inlet_in2) << 1) + param_Offset;

if (!prevstate)            // if previous state is zero (signal1<signal2)
  hyst = param_Hysteresis; // set the comparation term to the positive value
else
  hyst = -param_Hysteresis; // set te comparation term to the negative value

prevstate = state;

if (diff > hyst)
  state = 1;
else
  state = 0;

disp_cmp = state;
outlet_out = state;
outlet_inv = !state;
outlet_sum = diff;

Privacy

© 2024 Zrna Research