[sdiy] Beat timing calculations
Joel B
onephatcat at earthlink.net
Wed Jul 27 23:48:18 CEST 2011
Thanks Andre, this was very helpful.
I replaced my:
persecond=60/tempo
interval=persecond*1000
with
interval=(60/ tempo) / 4 *1000
and things are working a lot better now. I'll try switching to double precision as well, see if that improves things.
I don't at the moment have access to the sample-clock, I only have a millisecond counter.
Thanks to the other posters as well!
- Joel
On Jul 27, 2011, at 1:49 AM, Andre Majorel wrote:
> On 2011-07-26 21:02 -0700, Joel B wrote:
>
>> I'm contemplating writing a drum machine like program and i'm
>> not sure how to calculate the timing to trigger a note, say a
>> 16th note pattern, for instance. Here is what I have so far:
>>
>> 130 bpm= bps=60/130=0.46153846
>
> Yes.
>
>> 1000ms per second * bps
>> ms =461.53846 per beat division
>
> Yes.
>
>> 16 beats=16*461.53846 =7,384.61536
>> Milliseconds per loop
>
> What ?
>
> If by "16th note pattern" you mean a whole 4/4 bar of 16
> semiquavers, a semiquaver is 1/4th of a quarter note so about 60
> / 130 / 4 = 0.115 s and a whole bar lasts about 60 / 130 * 4 =
> 1.846 s.
>
>> but there probably has to be something to handle things that
>> don't land on a proper digital boundary like 33.3333333333...
>> without throwing the tempo off with rounding or truncation
>> errors?
More information about the Synth-diy
mailing list