tests and tunnings

pull/5/head
midilab 3 years ago
parent 59cd1c7e18
commit 16d0ea9804
  1. 47
      src/uClock.cpp
  2. 1
      src/uClock.h

@ -324,8 +324,7 @@ void uClockClass::handleExternalClock()
void uClockClass::handleTimerInt()
{
counter = interval;
if (mode == EXTERNAL_CLOCK) {
if ((internal_tick < external_tick) || (internal_tick > (external_tick + 1))) {
internal_tick = external_tick;
div32th_counter = indiv32th_counter;
@ -333,6 +332,28 @@ void uClockClass::handleTimerInt()
mod6_counter = inmod6_counter;
}
counter = interval;
uint32_t u_timer = micros();
sync_interval = clock_diff(external_clock, u_timer);
if (internal_tick <= external_tick) {
counter -= phase_mult(sync_interval);
} else {
if (counter > sync_interval) {
counter += phase_mult(counter - sync_interval);
}
}
// update internal clock timer frequency
float bpm = freqToBpm(counter);
if (bpm != tempo) {
if (bpm >= MIN_BPM && bpm <= MAX_BPM) {
tempo = bpm;
setTimerTempo(tempo);
}
}
}
if (onClock96PPQNCallback) {
onClock96PPQNCallback(&internal_tick);
}
@ -363,28 +384,6 @@ void uClockClass::handleTimerInt()
mod6_counter = 0;
}
if (mode == EXTERNAL_CLOCK) {
uint32_t u_timer = micros();
sync_interval = clock_diff(external_clock, u_timer);
if (internal_tick <= external_tick) {
counter -= phase_mult(sync_interval);
} else {
if (counter > sync_interval) {
counter += phase_mult(counter - sync_interval);
}
}
// update internal clock timer frequency
float bpm = freqToBpm(counter);
if (bpm != tempo) {
if (bpm >= MIN_BPM && bpm <= MAX_BPM) {
tempo = bpm;
setTimerTempo(tempo);
}
}
}
}
// elapsed time support

@ -63,7 +63,6 @@ class uClockClass {
void (*onClockStartCallback)();
void (*onClockStopCallback)();
volatile uint32_t interval;
volatile uint32_t external_clock;
uint32_t tick_us_interval;

Loading…
Cancel
Save