leveler

turns any audio input signal into the level set by the "level" knob. eg. useful to level out oscillators with different volume per waveform
Author: Remco van der Most
License: BSD
Github: sss/dist/leveler.axo

Inlets

frac32buffer a

Outlets

frac32buffer output

Parameters

frac32.u.map level

frac32.s.map rate

int32 hold

Declaration
int32_t max;
int32_t val;
int cnt;
Control Rate
int32_t f;
MTOF(param_rate - (1 << 26), f)
f = f >> 6;
Audio Rate
val += (inlet_a - val) >> 11;
int32_t in = inlet_a - val;
int32_t IN = in;
in = in > 0 ? in : -in;
in = in < 1024 ? 1024 : in;
cnt = __USAT(cnt - 1, 28);
if (in >= max) {
  cnt = param_hold;
  max = in;
}

if (cnt == 0) {
  max -= ___SMMUL(max, f);
}
float32_t ratio = (float32_t)(param_level) / max;
outlet_result = IN * ratio;

Privacy

© 2024 Zrna Research