multiform

saw wave LFO, rising slope, frequency input
Author: Johannes Taelman
License: BSD
Github: sss/lfo/multiform.axo

Inlets

bool32.rising reset phase

int32 waveform

bool32 Bipolar

frac32 frequency

Outlets

frac32.positive saw wave

Declaration
uint32_t Phase;
uint32_t r;
uint32_t h;
Init
Phase = 0;
r = 1;
Control Rate
{
  if (inlet_reset && r) {
    Phase = 0;
    r = 0;
  } else {
    if (!inlet_reset)
      r = 1;
    Phase += ((inlet_Hz) / 44 * 30);
  }
  int32_t r;
  int32_t wave;
  switch (inlet_waveform > 0 ? inlet_waveform : 0) {
  case 0:
    SINE2TINTERP(Phase, r) wave = (r >> 5) + (1 << 26);
    break;
  case 1:
    wave =
        (((Phase >> 4) - (1 << 27)) > (1 << 27) ? ((Phase >> 4) - (1 << 27))
                                                : -((Phase >> 4) - (1 << 27))) +
        (1 << 27);
    break;
  case 2:
    wave = (Phase >> 5);
    break;
  case 3:
    wave = (1 << 27) - (Phase >> 5);
    break;
  default:
    wave = (((Phase >> 4) - (1 << 27)) > (1 << 27) ? (1 << 27) : 0);
    break;
  }
  switch (inlet_Bipolar > 0 ? inlet_Bipolar : 0) {
  case 0:
    outlet_wave = wave;
    break;
  default:
    outlet_wave = (wave << 1) - (1 << 27);
    break;
  }
}

;

Privacy

© 2024 Zrna Research