BPMext

simple master clock source in BPM. outputs pulses for beat, triplets, fourths and a variable rate multiplier.
Author: Remco van der Most
License: BSD
Github: sss/lfo/BPMext.axo

Inlets

int32 BPM

int32 vari3

bool32.rising reset phase

Outlets

frac32 delaybase

frac32 ratebase

bool32 square wave

bool32 trips

bool32 fours

bool32 32

bool32 64

bool32 vari1

bool32 vari2

bool32 vari3

int32 rate3

int32.positive timing

Parameters

int32 BPM

int32 vari1

int32 vari2

int32 vari3

Declaration
int32_t Phase;
uint32_t r;
int rate1 = 3;
int rate2 = 4;
uint32_t freq;
Init
Phase = 0;
r = 1;
Control Rate
{
  int BPM = param_BPM + inlet_BPM;
  BPM = BPM > 0 ? BPM : 1;

  if (inlet_reset && r) {
    Phase = 0;
    r = 0;
  } else {
    if (!inlet_reset)
      r = 1;

    freq = (uint32_t)(1 << 30) / (22500 / BPM);
    Phase += freq >> 2;
  }
  outlet_beat = (Phase > 0) ? 1 : 0;
  outlet_trips = ((Phase * rate1) > 0) ? 1 : 0;
  outlet_fours = ((Phase * rate2) > 0) ? 1 : 0;
  outlet_32 = ((Phase << 5) > 0) ? 1 : 0;
  outlet_64 = ((Phase << 6) > 0) ? 1 : 0;
  outlet_vari1 = ((Phase * param_vari1) > 0) ? 1 : 0;
  outlet_vari2 = ((Phase * param_vari2) > 0) ? 1 : 0;
  outlet_vari3 = ((Phase * (inlet_vari3 + param_vari3)) > 0) ? 1 : 0;
  outlet_rate3 = inlet_vari3 << 4;
}
outlet_timing = (uint64_t)(1 << 30) * (1 << 17) / freq;
outlet_delaybase = (uint64_t)(1 << 30) * (1 << 17) / freq;
outlet_ratebase = freq >> 2;

Privacy

© 2024 Zrna Research