Skip to main content

µClock Library

Precision BPM Clock Generation for Arduino/PlatformIO using Hardware Timers.

µ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

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:

Support

For technical questions, bug reports, or contributions, please visit the Official µClock GitHub Repository.