24ppq2click

Metronome object. Provides a click when connected to 24ppq input.
Author: Sputnki
License: BSD
Github: sptnk/sequencer/24ppq2click.axo

Inlets

int32 24ppq

Outlets

frac32buffer o

Declaration
bool ptrig = 0;

int32_t phasor1 = 0;
int32_t phasor2 = 0;
int32_t ramp = 0;
int stage = 0;
Control Rate
int factor = 24;
int ppq = inlet_24ppq;

int32_t factor4 = factor << 2;

if (factor4 * (ppq / (factor4)) == ppq && !ptrig) {
  ptrig = 1;
  stage = 1;
  ramp = 1 << 27;
} else if (factor * (ppq / factor) == ppq && !ptrig) {
  ptrig = 1;
  stage = 2;
  ramp = 0b00001000000000000000000000000000;
} else if (!((factor * (ppq / factor)) == ppq))
  ptrig = 0;

if (stage)
  ;
ramp -= 0b00000000000110000000000000000000;

if (ramp < 0) {
  ramp = 0;
  stage = 0;
}
Audio Rate
phasor1 += 0b000000010100000000000000000000000;
phasor2 += 0b000000001010000000000000000000000;

outlet_o = ___SMMUL(ramp, stage == 0 ? 0 : (stage == 1 ? phasor1 : phasor2));

Privacy

© 2024 Zrna Research