envLFO

Tempo Synced LFO with multiple waveforms out Envelope-LFO creats a positive linear envelope-type LFO Automatically syncs tempo to the incoming clock on sync-input. Tempo can be multiplied and divided by integers to keep a tight ratio and can also be shifted up/down up to 8 octaves. Reset resets the phase to zero. Length controls the length of the "envelope", making it shorter then the looping time of the LFO att2dec controls the attack/decay length ratio. pairs well with the expCurveK module for creating (inverse) exponential enveloping Reset will hard-reset the phase of the internal LFO
Author: Remco van der Most
License: BSD
Github: sss/lfo/envLFO.axo

Inlets

frac32 att2dec

frac32 length

int32 multiply

int32.positive divide

int32.bipolar octave

bool32.rising sync

bool32.rising reset

Outlets

frac32 peak1

Parameters

int32 multiply

int32 divide

int32 octave

frac32.u.map att2dec

frac32.u.map length

Declaration
uint64_t timer;
uint64_t held;
uint64_t hold;
int ttrig;
int rtrig;
int strig;
int utrig;
int64_t phase;
int32_t count;
int64_t divide;
int32_t multiply;
int8_t octave;
uint32_t tomer;
uint32_t tamer;
int32_t peak1;
int32_t val;
int32_t length;
int32_t att2dec;
Control Rate
octave = param_octave + inlet_octave;
multiply = param_multiply + inlet_multiply;
divide = param_divide + inlet_divide;
length = __USAT(param_length + inlet_length, 27);
att2dec = __USAT(param_att2dec + inlet_att2dec, 27);
if ((inlet_reset > 0) && !utrig) {
  utrig = 1;
  timer = 0;
} else if (!(inlet_reset > 0)) {
  utrig = 0;
}

if ((inlet_sync > 0) && !ttrig) {
  ttrig = 1;
  held = tamer;
  tamer = 0;
} else if (!(inlet_sync > 0)) {
  ttrig = 0;
}
tamer += 1;
timer += 1;
if (param_octave >= 0) {
  timer = (timer - (timer / (held >> octave)) * (held >> octave));
  hold = ___SMMUL((held >> octave) << 3, length << 2);
} else {
  timer = (timer - (timer / (held << -octave)) * (held << -octave));
  hold = ___SMMUL((held << -octave) << 3, param_length << 2);
}
tomer =
    (timer * multiply / divide) - ((timer * multiply / divide) / hold) * hold;
tomer = timer >= hold ? hold : tomer;

int32_t attack;
int32_t decay;
attack = ___SMMUL(att2dec << 3, hold << 2);
decay = hold - attack;
peak1 = tomer > attack ? (1 << 27) - ((((tomer - attack) << 10) / decay) << 17)
                       : (((tomer << 10) / attack) << 17);
peak1 = ___SMMUL(peak1 << 3, peak1 << 2);
val = val + ((peak1 - val) >> 2);
outlet_peak1 = val;

Privacy

© 2024 Zrna Research