bpm_gen

BPM generator, external inputs
Author: Are Leistad
License: BSD
Github: drj/seq/bpm_gen.axo

IO Variants: 2


Variant: 1

Inlets

bool32.rising Reset phase

int32.positive BPM, integer

int32.positive BPM, tenths

int32.positive BPM, hundredths

Outlets

bool32 BPM clock output

Declaration
uint32_t phase;
int32_t old_reset;
Init
phase = 0;
old_reset = 0;
Control Rate
float bpm;
uint32_t pacc;

bpm = inlet_bpm + inlet_tenth * 0.1f + inlet_hundredth * 0.01f;
// pacc = (uint32_t) ( bpm / 3000.0f / 60.0f * 4294967296 );
pacc = (uint32_t)(bpm * 23860.92942222222);

if (inlet_reset && !old_reset) {
  phase = 0;
} else {
  phase += pacc;
}
old_reset = inlet_reset;

if (phase > 0x80000000) {
  outlet_out = 1;
} else {
  outlet_out = 0;
}

Variant: 2

Inlets

bool32.rising Reset phase

Outlets

bool32 BPM clock output

Parameters

int32 bpm

int32 tenth

int32 hundredth

Declaration
uint32_t phase;
int32_t old_reset;
Init
phase = 0;
old_reset = 0;
Control Rate
float bpm;
uint32_t pacc;

bpm = param_bpm + param_tenth * 0.1f + param_hundredth * 0.01f;
// pacc = (uint32_t) ( bpm/3000.0f/60.0f * 4294967296 );
pacc = (uint32_t)(bpm * 23860.92942222222);

if (inlet_reset && !old_reset) {
  phase = 0;
} else {
  phase += pacc;
}
old_reset = inlet_reset;

if (phase > 0x80000000) {
  outlet_out = 1;
} else {
  outlet_out = 0;
}

Privacy

© 2024 Zrna Research