µClock is a dedicated library for generating highly accurate, stable BPM (Beats Per Minute) clock signals on microcontroller platforms like Arduino and PlatformIO. It leverages hardware timer interrupts, avoiding the inconsistencies of software-based timing, making it ideal for demanding real-time music applications.
Developed to address the need for robust real-time features in the open-source embedded ecosystem, µClock allows professional-grade timing by managing hardware interrupts and providing safe shared resource access. It supports a wide range of boards including AVR (ATmega168/328, ATmega16u4/32u4, ATmega2560) and various ARM platforms (Teensy, STM32XX, ESP32, Raspberry Pi Pico, Seeed Studio XIAO M0, RP2040).
Whether you're building a sequencer, drum machine, MIDI clock master/slave, or any device needing precise musical timing, µClock provides the reliable foundation.
Features
Hardware Timer Accuracy
Delivers exceptionally stable and precise timing by using dedicated microcontroller hardware timer, eliminating software loop variations.
Reliable Real-time Ops
Designed for demanding tasks like sequencing and synchronization. Provides resource-safe APIs for stable operation during live performance.
Flexible External Sync
Easily synchronize your project to external MIDI clock or other pulse signals. µClock can derive its internal timing from an incoming source.
Shuffle/Swing Templates
Built-in support for swing template build-up, emulate various classic groove machines swings using uClock.
Multi-Platform
Integrates seamlessly with both the Arduino IDE and PlatformIO build systems, fitting into your preferred development workflow.
Broad MCU Support
Works across popular architectures: AVR (Uno, Mega, Leonardo), ARM (Teensy, STM32, ESP32, RP2040, XIAO M0), with software fallback for others.
Concepts & Key points
- Callback-Driven API: Interact with the clock through simple callback functions triggered at specific timing events.
- Hardware Timer Interrupts: Ensures maximum timing precision (on supported boards).
- Multiple PPQN Resolutions: Supports various Pulses Per Quarter Note standards for broad compatibility.
- Internal/External Clock Modes: Operate as a master clock source or sync reliably to an external input.
- Software Timer Fallback: Provides basic timing functionality even on boards where hardware timer access is limited or unavailable.
Supported PPQN Resolutions
You can set the main output or input PPQN resolution using setOutputPPQN(value)
or setInputPPQN(value)
respectively. Available values (constants):
PPQN_1
,PPQN_2
,PPQN_4
(Common for Eurorack Modular Devices)PPQN_8
,PPQN_12
(Some unusual devices out there)PPQN_24
(Standard MIDI Clock)PPQN_48
,PPQN_96
(Common for old-school Sequencers)PPQN_384
,PPQN_480
,PPQN_960
(High Resolution modern Sequencers)
Applications Powered by µClock
µClock serves as the timing core for many DIY music projects:
Aciduino V2 Sequencer
The precise step sequencing and timing rely heavily on µClock's hardware-based clock generation for its Roland-inspired workflow - by Midilab.
XR-1 Groovebox
This full-featured groovebox showcases µClock's ability to provide a stable master clock for complex pattern playback - by James Gray.
MIDI Looper/Sequencer
µClock provides the essential real-time clock source needed for accurate MIDI event recording, looping, and playback in this custom sequencer - by ymnkmusic.
MIDI/DIN Sync Box
A perfect example of µClock used for synchronization tasks, generating or locking to MIDI and DIN Sync timing signals reliably - by ymnkmusic.
Support
For technical questions, bug reports, or contributions, please visit the Official µClock GitHub Repository.