sample and hold

Sample and hold module. Frequency adjust hold time (the higher the frequency, the finer the grain), while scaling routes the current sample amplitude to the hold time (unusual for a bitcrusher, but might add some character). Linear frequency scaling. The object is based on Johannes dist/samplehold cheap and osc/sine lin
Author: Sputnki
License: BSD
Github: sptnk/effect/sample and hold.axo

Inlets

frac32buffer in

frac32 freq

frac32 scaling

Outlets

frac32buffer.bipolar output

Parameters

frac32.s.map scaling

frac32.u.map freq

Declaration
int32_t phase;
int32_t phase_prev;
int32_t scaling;
uint32_t additional;
int32_t hold;
Init
phase = 0;
phase_prev = 0;
scaling = 0;
additional = 0;
hold = 0;
Control Rate
scaling = param_scaling + inlet_scaling << 4;
Audio Rate
phase += (param_freq + inlet_freq + additional) << 1;

if ((phase < 0) && (phase_prev > 0)) {
  hold = inlet_in >> 1;
  phase = 0;
  additional = ___SMMUL(hold > 0 ? hold : -hold, scaling);
}
outlet_out = hold;
phase_prev = phase;

Privacy

© 2024 Zrna Research