From 31e632ccda34b5e8827c765164d0478e2de41aa6 Mon Sep 17 00:00:00 2001 From: midilab Date: Fri, 1 Apr 2022 13:00:39 -0300 Subject: [PATCH] rewrite clock engine for more horse power process between clock calls --- README.md | 15 --------------- .../LeonardoUsbSlaveMidiClockMonitor.ino | 2 -- .../TeensyUsbMasterMidiClock.ino | 2 -- .../TeensyUsbSlaveMidiClock.ino | 2 -- .../TeensyUsbSlaveMidiClockMonitor.ino | 7 ------- src/uClock.cpp | 6 +++--- src/uClock.h | 10 +++++----- 7 files changed, 8 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index f0f4cc1..76b3d2c 100755 --- a/README.md +++ b/README.md @@ -97,8 +97,6 @@ void onClockStop() { } void setup() { - // drift for USB Teensy - uClock.setDrift(1); // Inits the clock uClock.init(); // Set the callback function for the clock output to send MIDI Sync message. @@ -317,16 +315,3 @@ void loop() //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 on Leonardo boards please start setting the drift to 4: -uClock.setDrift(4); - -For teensy boards and USB Midi try: -uClock.setDrift(1); - -Please use uClock.setDrift() before uClock.init(); - diff --git a/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino b/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino index 18a1013..1c0d0b4 100644 --- a/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino +++ b/examples/LeonardoUsbSlaveMidiClockMonitor/LeonardoUsbSlaveMidiClockMonitor.ino @@ -103,8 +103,6 @@ void setup() { // // uClock Setup // - // Drift for arudino leonardo over USB as MIDI HID - uClock.setSlaveDrift(10); uClock.init(); uClock.setClock96PPQNOutput(ClockOut96PPQN); // For MIDI Sync Start and Stop diff --git a/examples/TeensyUsbMasterMidiClock/TeensyUsbMasterMidiClock.ino b/examples/TeensyUsbMasterMidiClock/TeensyUsbMasterMidiClock.ino index 436a8dd..3c27364 100644 --- a/examples/TeensyUsbMasterMidiClock/TeensyUsbMasterMidiClock.ino +++ b/examples/TeensyUsbMasterMidiClock/TeensyUsbMasterMidiClock.ino @@ -55,8 +55,6 @@ void setup() { pinMode(LED_BUILTIN, OUTPUT); // Setup our clock system - // drift for USB Teensy - uClock.setDrift(1); // Inits the clock uClock.init(); // Set the callback function for the clock output to send MIDI Sync message. diff --git a/examples/TeensyUsbSlaveMidiClock/TeensyUsbSlaveMidiClock.ino b/examples/TeensyUsbSlaveMidiClock/TeensyUsbSlaveMidiClock.ino index 1fde0b8..a8aa6f0 100644 --- a/examples/TeensyUsbSlaveMidiClock/TeensyUsbSlaveMidiClock.ino +++ b/examples/TeensyUsbSlaveMidiClock/TeensyUsbSlaveMidiClock.ino @@ -76,8 +76,6 @@ void setup() { usbMIDI.setHandleStop(onExternalStop); // Setup our clock system - // drift for USB Teensy - uClock.setDrift(1); // Inits the clock uClock.init(); // Set the callback function for the clock output to send MIDI Sync message. diff --git a/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino b/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino index 533cb26..835b028 100644 --- a/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino +++ b/examples/TeensyUsbSlaveMidiClockMonitor/TeensyUsbSlaveMidiClockMonitor.ino @@ -11,11 +11,6 @@ * - u8g2 * - uClock * - * This example make use of drift values (6, 1) - * respectively for internal and external drift reference. - * This example was tested on a macbook - * running ableton live 9 as master clock - * * This example code is in the public domain. */ @@ -111,8 +106,6 @@ void setup() { // uClock Setup // // Setup our clock system - // drift for USB Teensy - uClock.setDrift(1); uClock.init(); uClock.setClock96PPQNOutput(ClockOut96PPQN); // For MIDI Sync Start and Stop diff --git a/src/uClock.cpp b/src/uClock.cpp index a6a11bf..43cde97 100755 --- a/src/uClock.cpp +++ b/src/uClock.cpp @@ -1,10 +1,10 @@ /*! * @file uClock.cpp * Project BPM clock generator for Arduino - * @brief A Library to implement BPM clock tick calls using hardware timer interruption. Tested on ATmega168/328, ATmega16u4/32u4 and ATmega2560. - * @version 0.10.6 + * @brief A Library to implement BPM clock tick calls using hardware timer interruption. Tested on ATmega168/328, ATmega16u4/32u4 and ATmega2560 and Teensy LC. + * @version 1.0.0 * @author Romulo Silva - * @date 13/03/2022 + * @date 01/04/2022 * @license MIT - (c) 2022 - Romulo Silva - contact@midilab.co * * Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/uClock.h b/src/uClock.h index 7f1a093..6a3c18f 100755 --- a/src/uClock.h +++ b/src/uClock.h @@ -1,11 +1,10 @@ /*! - * @file uClock.cpp + * @file uClock.h * Project BPM clock generator for Arduino - * @brief A Library to implement BPM clock tick calls using hardware timer1 interruption. Tested on ATmega168/328, ATmega16u4/32u4 and ATmega2560. - * Derived work from mididuino MidiClock class. (c) 2008 - 2011 - Manuel Odendahl - wesen@ruinwesen.com - * @version 0.10.6 + * @brief A Library to implement BPM clock tick calls using hardware timer interruption. Tested on ATmega168/328, ATmega16u4/32u4 and ATmega2560 and Teensy LC. + * @version 1.0.0 * @author Romulo Silva - * @date 13/03/2022 + * @date 01/04/2022 * @license MIT - (c) 2022 - Romulo Silva - contact@midilab.co * * Permission is hereby granted, free of charge, to any person obtaining a @@ -44,6 +43,7 @@ namespace umodular { namespace clock { // for smooth slave tempo calculate display you should raise this value // in between 64 to 128. // note: this doesn't impact on sync time, only display time getTempo() +// if you dont want to use it, set it to 1 for memory save #define EXT_INTERVAL_BUFFER_SIZE 24 #define SECS_PER_MIN (60UL)