added a drift voodo variable to make it easier to get better clock timming with PCs. Check README.md for more info

pull/7/head 0.8.2
midilab 4 years ago
parent 94fa429e26
commit 40aad3ff96
  1. 8
      README.md
  2. 14
      src/uClock.cpp
  3. 2
      src/uClock.h

@ -275,3 +275,11 @@ void loop()
//processYourPots(); //processYourPots();
} }
``` ```
## Troubleshooting
If you slave host are not showing correct of close bpm on sync, please try to use the drift variable to adjust. It normaly goes from value 4(good for clock over USB) to 11(good for common MIDI interfaces running at 31250 speed). The default value is 11.
To use MIDI via USB please start setting the drift to 4:
uClock.setDrift(4);

@ -53,6 +53,9 @@ static inline uint16_t clock_diff(uint16_t old_clock, uint16_t new_clock)
uClockClass::uClockClass() uClockClass::uClockClass()
{ {
// 4 is good for usb-to-midi hid
// 11 is good for native 31250bps midi interface
drift = 11;
pll_x = 220; pll_x = 220;
mode = INTERNAL_CLOCK; mode = INTERNAL_CLOCK;
resetCounters(); resetCounters();
@ -138,10 +141,8 @@ void uClockClass::setTempo(uint16_t bpm)
_tmpSREG = SREG; _tmpSREG = SREG;
cli(); cli();
tempo = bpm; tempo = bpm;
// 4 is good for usb-to-midi hid //interval = 62500 / (tempo * 24 / 60) - drift;
// 11 is good for native 31400bps midi interface interval = (uint16_t)(156250 / tempo) - drift;
//interval = 62500 / (tempo * 24 / 60) - 4;
interval = (uint16_t)(156250 / tempo) - 4;
SREG = _tmpSREG; SREG = _tmpSREG;
} }
@ -153,6 +154,11 @@ uint16_t uClockClass::getTempo()
return tempo; return tempo;
} }
void uClockClass::setDrift(uint8_t value)
{
drift = value;
}
uint8_t uClockClass::getMode() uint8_t uClockClass::getMode()
{ {
return mode; return mode;

@ -73,6 +73,7 @@ class uClockClass {
uint16_t last_interval; uint16_t last_interval;
uint32_t indiv96th_counter; uint32_t indiv96th_counter;
uint16_t pll_x; uint16_t pll_x;
uint8_t drift;
uint16_t tempo; uint16_t tempo;
uint32_t start_timer; uint32_t start_timer;
uint8_t mode; uint8_t mode;
@ -114,6 +115,7 @@ class uClockClass {
void pause(); void pause();
void setTempo(uint16_t bpm); void setTempo(uint16_t bpm);
uint16_t getTempo(); uint16_t getTempo();
void setDrift(uint8_t value);
// external timming control // external timming control
void setMode(uint8_t tempo_mode); void setMode(uint8_t tempo_mode);

Loading…
Cancel
Save