24ppq to bpm

This object can be used to detect the bpm speed of a midi clock signal expressed in 24ppq. Outlets: -bpm - outputs the integer part of the bpm -mill - outputs the fractional part of the bpm -1000bpm - outputs bpm*100
Author: Sputnki
License: BSD
Github: sptnk/sequencer/24ppq to bpm.axo

Inlets

int32 24ppq

Outlets

int32 bpm

int32 mill

int32 1000bpm

Declaration
int counter;
int tcount;
bool ttrig;
int bpm;
int mill;
int _1000bpm;
int ppq_previous;
Init
counter = 0;
ttrig = 0;
tcount = 0;
bpm = 0;
mill = 0;
_1000bpm = 0;
Control Rate
counter += 1;

if (inlet_24ppq != ppq_previous) {
  ppq_previous = inlet_24ppq;
  tcount += 1;

  if (tcount > 23) {
    bpm = 180000 / counter;
    _1000bpm = 180000000 / counter;
    mill = _1000bpm - bpm * 1000;
    tcount = 0;
    counter = 0;
  }
}

outlet_mill = mill;
outlet_bpm = bpm;
outlet_1000bpm = _1000bpm;

Privacy

© 2024 Zrna Research