BPM

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/BPM.axo

Inlets

int32 BPM

bool32.rising reset phase

Outlets

bool32 square wave

bool32 trips

bool32 fours

bool32 vari

Parameters

int32 BPM

int32 vari

Declaration
int32_t Phase;
uint32_t r;
int rate1 = 3;
int rate2 = 4;
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;
    int32_t freq;
    freq = (1 << 31) / (45000 / 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_vari = ((Phase * param_vari) > 0) ? 1 : 0;
}

Privacy

© 2024 Zrna Research