sloped8xlfo

8x saw-tri-ramp LFO each LFO has a different rate-division based on root frequency and set by the "time" parameter
Author: Remco van der Most
License: BSD
Github: sss/lfo/sloped8xlfo.axo

Inlets

bool32.rising reset phase

frac32.bipolar pitch

Outlets

frac32.positive saw wave

frac32 o2

frac32 o3

frac32 o4

frac32 o5

frac32 o6

frac32 o7

frac32 o8

Parameters

frac32.s.map.lfopitch pitch

bool32.tgl frqIN

frac32.u.map.gain slope

int32 time

Declaration
uint32_t Phase;
int32_t pPhase;
uint32_t r;
int32_t tri[8];
float32_t ratioA;
float32_t ratioB;
int32_t v27 = 1 << 27;
int32_t v28 = 1 << 28;
int32_t v29 = 1 << 29;
int32_t v30 = 1 << 30;
uint32_t v31 = (uint32_t)1 << 31;
int32_t SHAPE(uint32_t phs, int32_t slp) {
  phs = phs > slp ? v29 - (phs - slp) * ratioB : phs * ratioA;
  return phs = phs >> 2;
  // ri=(int32_t)(phs>slp?slp+(phs-slp)*ratioB:phs*ratioA)>>2;
  // tri=tri>v27?v28-tri:tri;
};
int i;
int tim[8][8] = {
    {1, 2, 3, 4, 5, 6, 7, 8},     {1, 2, 4, 8, 16, 32, 64, 128},
    {1, 2, 3, 4, 6, 8, 12, 16},   {1, 2, 3, 4, 8, 9, 16, 27},
    {1, 3, 6, 9, 12, 15, 18, 21}, {1, 3, 9, 27, 81, 243, 729, 2187},
    {1, 2, 4, 5, 8, 10, 15, 16},  {1, 2, 3, 4, 5, 6, 8, 10}};
Init
Phase = 0;
pPhase = 0;
r = 1;
Control Rate
{
  if (inlet_reset && r) {
    Phase = 0;
    r = 0;
  } else {
    if (!inlet_reset)
      r = 1;
    uint32_t freq;
    if (param_frqIN == 0) {
      MTOFEXTENDED(param_pitch + inlet_pitch, freq);
    } else {
      float32_t rt;
      uint32_t tmp;
      MTOFEXTENDED(0, tmp)
      MTOFEXTENDED(param_pitch, freq)
      rt = (float32_t)freq / tmp;
      freq = inlet_pitch * rt;
    }
    Phase += freq >> 8;
  }
}

ratioA = (float32_t)v30 / param_slope;
ratioB = (float32_t)v30 / (v31 - param_slope);
for (i = 0; i < 8; i++) {
  tri[i] = SHAPE(Phase * tim[param_time][7 - i] >> 2, param_slope >> 1);
}
outlet_o1 = tri[0];
outlet_o2 = tri[1];
outlet_o3 = tri[2];
outlet_o4 = tri[3];
outlet_o5 = tri[4];
outlet_o6 = tri[5];
outlet_o7 = tri[6];
outlet_o8 = tri[7];

Privacy

© 2024 Zrna Research