Re: SOLVED! – Re:multiple h/w sequencers & timing

OS_CE Forums Octopus General multiple h/w sequencers & timing Re: SOLVED! – Re:multiple h/w sequencers & timing

Chris Henkel

…there is a – pretty easy solution available, which, however, does require someone to release a bugfix-update for the Octopus-OS…

how to solve the Octopus-timing problem

while reading the measurement results it was immediately clear to me that
the initial MIDI clock event is missing before the sequencer plays the first
step. Following calculation example proves this:
with 24 ppqn MIDI clock resolution, we expect a MIDI clock event with an
interval of: 60 / (bpm * 24)

Compare this with the measurement results:
100BPM 22mS -> expected 25.0 mS (+3.0 mS)
110BPM 20mS -> expected 22.7 mS (+2.7 mS)
120BPM 18mS -> expected 20.8 mS (+2.8 mS)
130BPM 16mS -> expected 19.2 mS (+3.2 mS)
140BPM 13mS -> expected 17.8 mS (+4.8 mS)
150BPM 11mS -> expected 16.6 mS (+5.6 mS)

The values don’t match exactly, but this could be related to a systematic
measurement error (e.g. latency caused by the MIDI router and/or sound source),
because the offset is usually around 3 mS). With BPM >= 140 the offset gets
longer, it seems that the whole chain is under heavy load.

However, looking into the source code: you will find the timer
which sends the MIDI clock under _OCT_interrupts/Intr_TMR.h, driveSequencer()

Genoqs uses the G_TTC_abs_value variable to count from 1..12 for
each 16th step:

// G_TTC_abs_value: The master time keeper between two matrix columns
// Generate the absolute value of TIMER_TICK_COUNTER – which is the master time keeper
G_TTC_abs_value = (G_TTC_abs_value % 12) + 1;

The MIDI Clock is sent with each second TTC (since MIDI clock is working
at half resolution)

// Send MIDI CLOCK on every other TTC starting at 1
if ( (G_TTC_abs_value) % 2 == 1) {

_OCT_exe_keys/key_functions.h, sequencer_START() initializes
G_TTC_abs_value with 0 – thats ok!

But: in Intr_TMR.h the clock is sent before G_TTC_abs_value will be
incremented, accordingly the first clock will be skipped, since:

G_TTC_abs_value == 0 -> (G_TTC_abs_value) % 2 != 1
(no clock)

Proposed change: in _OCT_interrupts/Intr_TMR.h there are two places
where G_TTC_abs_value is incremented (switch() case ON, OFF)
You can safely incremented this counter before the switch() statement,
and especially before MIDI clock should be sent.

Therefore: remove the two "G_TTC_abs_value = (G_TTC_abs_value % 12) + 1;"
lines inside the switch() statement, and add this line at the beginning
of the driveSequencer() function, e.g. after G_MIDI_timestamp has been

—-end of solution—-

…best wishes,