I’m hoping that typing out a question will help me to figure out what I’m doing wrong in my sums, but I might be clicking “Create topic” if I don’t get anywhere, rubber ducking.
Basically I’m trying to send a MIDI tick message out on the MIDI Out connector. The MIDI tick status message 0xF8, is transmitted 24 times per quarter note. Now for the maths:
- ModDwarf reports a sample rate of 48,000 which is samples per second I assume, (A Frequency)
- I’m trying to get 80 BPM which would be 80/60 Beats per second = 1.33333
- So I’d be expecting 48K * 1.3333 samples per beat (63,998.4)
- So if I want 24 ticks per beat I want 63,998.4 / 24) = 2,666.6 samples per MIDI Tick
So now my code, all those numbers check out, in my head anyhow. So my instance data keeps a count variable which is a float. I’ve also got a local_count in my run() method. All I do is:
local_count = self->count + n_samples; // n_samples is the number of samples sent to run() 128
if (local_count > 2,666.6) {
tx_midi_tick();
self->count = local_count - 2,666.6;
} else {
self->count = local_count;
}
All that looks right to me but the synth connected to the ModDwarf is reporting a BPM of 45. Sooo far out.