|
|
@ -104,6 +104,7 @@ uClockClass::uClockClass() |
|
|
|
// drift is used to sligth calibrate with your slave clock
|
|
|
|
// drift is used to sligth calibrate with your slave clock
|
|
|
|
drift = 1; |
|
|
|
drift = 1; |
|
|
|
slave_drift = 0; |
|
|
|
slave_drift = 0; |
|
|
|
|
|
|
|
pll_x = 220; |
|
|
|
tempo = 120; |
|
|
|
tempo = 120; |
|
|
|
start_timer = 0; |
|
|
|
start_timer = 0; |
|
|
|
last_interval = 0; |
|
|
|
last_interval = 0; |
|
|
@ -291,15 +292,12 @@ void uClockClass::handleExternalClock() |
|
|
|
last_interval = clock_diff(last_clock, _clock); |
|
|
|
last_interval = clock_diff(last_clock, _clock); |
|
|
|
last_clock = _clock; |
|
|
|
last_clock = _clock; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// accumulate interval incomming ticks data for getTempo() smooth reads on slave mode
|
|
|
|
|
|
|
|
ext_interval_buffer[ext_interval_idx++ % EXT_INTERVAL_BUFFER_SIZE] = last_interval; |
|
|
|
|
|
|
|
|
|
|
|
// slave tick me!
|
|
|
|
// slave tick me!
|
|
|
|
external_tick++; |
|
|
|
external_tick++; |
|
|
|
|
|
|
|
|
|
|
|
// callback counters
|
|
|
|
|
|
|
|
inmod6_counter++; |
|
|
|
|
|
|
|
if (inmod6_counter == 6) { |
|
|
|
|
|
|
|
inmod6_counter = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (state) { |
|
|
|
switch (state) { |
|
|
|
case PAUSED: |
|
|
|
case PAUSED: |
|
|
|
break; |
|
|
|
break; |
|
|
@ -309,9 +307,11 @@ void uClockClass::handleExternalClock() |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case STARTED: |
|
|
|
case STARTED: |
|
|
|
interval = last_interval + slave_drift; |
|
|
|
if (external_tick == 1) { |
|
|
|
// accumulate interval incomming ticks data for getTempo() smooth reads on slave mode
|
|
|
|
interval = last_interval; |
|
|
|
ext_interval_buffer[ext_interval_idx++ % EXT_INTERVAL_BUFFER_SIZE] = interval; |
|
|
|
} else { |
|
|
|
|
|
|
|
interval = (((uint32_t)interval * (uint32_t)pll_x) + (uint32_t)(256 - pll_x) * (uint32_t)last_interval) >> 8; |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|