Hi, everyone I'm working on a clock device for audio/midi/synth purposes, it is pretty accurate right now, but I think it can do better.
The code runs on a library, and gets refreshed on the loop. The code calculates how many micros should it wait until it must do something. and also Stores how many microseconds are lost every minutes.
This is the pice of code that determines the length of the steps:
if(PPQN[i] == 0){ PPQN[i] = 1; }
_TPM[x] =(BPM * PPQN[x]);
Tick[x] = (60000000 / _TPM[x]);
_ML[x] = (60000000 - (Tick[x] * _TPM[x]));
First the code makes sure that PPQN (Pulses per quarter note) are not equal to 0. Then it multiplies BPM times PPQN to know how many Pulses must send on a minute (TPM = Ticks per minute). Then it determines the length of the intervals, and then multiplies the Pulse length by TPM and then subtract that from 60000000 to know how many microseconds are lost.
So what do you think? Is there a way that I can divide the steps better, without getting extreme hardcore math?.
maybe you can think of something, or point me toward the right direction, Thanks