24ppq to phase 64

This object generates a phase signal that goes from 0 to 64 in 64 beats (16 bars) when fed with a 24ppq signal.
Author: Sputnki
License: BSD
Github: sptnk/sequencer/24ppq to phase 64.axo

Inlets

int32.positive 24ppq

Outlets

frac32.positive pos64q

Declaration
int ppq = 0;
int ppqprev = 0;
float counter = 0;
int ppqcount = 0;

float bpm = 0;

uint32_t phase = 0;
Control Rate
counter += 1;
phase += bpm * (2796202.6667);

ppq = inlet_24ppq - 1536 * (inlet_24ppq / 1536);

if (ppq != ppqprev) {
  phase = ppq * 2796202.6667f;

  bpm = 1.0f / counter;
  counter = 0;
}
ppqprev = ppq;

outlet_pos64q = phase >> 5;

// the bpm variable does not really contain bpm information..

Privacy

© 2024 Zrna Research