change notes

pull/9/head
midilab 3 years ago
parent 197edd7888
commit 731bb41f49
  1. 12
      README.md
  2. 4
      library.properties
  3. 8
      src/uClock.cpp
  4. 24
      src/uClock.h

@ -1,6 +1,6 @@
# uClock # uClock
**BPM clock generator for Arduino and Teensy** is a library to implement BPM clock tick calls using **hardware interruption** for tight and solid timing clock ticks. Tested on ATmega168/328, ATmega16u4/32u4, ATmega2560 and Teensy LC. **BPM clock generator for Arduino and Teensy** is a library to implement BPM clock tick calls using **hardware interruption** for tight and solid timing clock ticks. Tested on ATmega168/328, ATmega16u4/32u4, ATmega2560, Teensy ARM boards and Seedstudio XIAO M0.
Generate your self tight BPM clock for music, audio/video productions, performances or installations. You can clock your MIDI setup or sync different protocols as you wish. Generate your self tight BPM clock for music, audio/video productions, performances or installations. You can clock your MIDI setup or sync different protocols as you wish.
@ -34,7 +34,7 @@ Here is an example on how to create a simple MIDI Sync Box on Arduino boards
#define MIDI_STOP 0xFC #define MIDI_STOP 0xFC
// The callback function wich will be called by Clock each Pulse of 96PPQN clock resolution. // The callback function wich will be called by Clock each Pulse of 96PPQN clock resolution.
void ClockOut96PPQN(uint32_t * tick) { void ClockOut96PPQN(uint32_t tick) {
// Send MIDI_CLOCK to external gears // Send MIDI_CLOCK to external gears
Serial.write(MIDI_CLOCK); Serial.write(MIDI_CLOCK);
} }
@ -81,7 +81,7 @@ An example on how to create a simple MIDI Sync Box on Teensy boards and USB Midi
#include <uClock.h> #include <uClock.h>
// The callback function wich will be called by Clock each Pulse of 96PPQN clock resolution. // The callback function wich will be called by Clock each Pulse of 96PPQN clock resolution.
void ClockOut96PPQN(uint32_t * tick) { void ClockOut96PPQN(uint32_t tick) {
// Send MIDI_CLOCK to external gears // Send MIDI_CLOCK to external gears
usbMIDI.sendRealTime(usbMIDI.Clock); usbMIDI.sendRealTime(usbMIDI.Clock);
} }
@ -185,13 +185,13 @@ void sendMidiMessage(uint8_t command, uint8_t byte1, uint8_t byte2)
} }
// The callback function wich will be called by uClock each Pulse of 16PPQN clock resolution. Each call represents exactly one step. // The callback function wich will be called by uClock each Pulse of 16PPQN clock resolution. Each call represents exactly one step.
void ClockOut16PPQN(uint32_t * tick) void ClockOut16PPQN(uint32_t tick)
{ {
uint16_t step; uint16_t step;
uint16_t length = NOTE_LENGTH; uint16_t length = NOTE_LENGTH;
// get actual step. // get actual step.
_step = *tick % _step_length; _step = tick % _step_length;
// send note on only if this step are not in rest mode // send note on only if this step are not in rest mode
if ( _sequencer[_step].rest == false ) { if ( _sequencer[_step].rest == false ) {
@ -223,7 +223,7 @@ void ClockOut16PPQN(uint32_t * tick)
} }
// The callback function wich will be called by uClock each Pulse of 96PPQN clock resolution. // The callback function wich will be called by uClock each Pulse of 96PPQN clock resolution.
void ClockOut96PPQN(uint32_t * tick) void ClockOut96PPQN(uint32_t tick)
{ {
// Send MIDI_CLOCK to external hardware // Send MIDI_CLOCK to external hardware
Serial.write(MIDI_CLOCK); Serial.write(MIDI_CLOCK);

@ -1,9 +1,9 @@
name=uClock name=uClock
version=1.0.0 version=1.1.0
author=Romulo Silva <contact@midilab.co> author=Romulo Silva <contact@midilab.co>
maintainer=Romulo Silva <contact@midilab.co> maintainer=Romulo Silva <contact@midilab.co>
sentence=BPM clock generator for Arduino and Teensy boards sentence=BPM clock generator for Arduino and Teensy boards
paragraph=A Library to implement BPM clock tick calls using hardware interruption. Tested on ATmega168/328, ATmega16u4/32u4, ATmega2560, Teensy ARM boards and Seedstudio XIAO M0 SAMD.. paragraph=A Library to implement BPM clock tick calls using hardware interruption. Tested on ATmega168/328, ATmega16u4/32u4, ATmega2560, Teensy ARM boards and Seedstudio XIAO M0
category=Timing category=Timing
url=https://github.com/midilab/uClock url=https://github.com/midilab/uClock
architectures=avr,arm,samd architectures=avr,arm,samd

@ -1,10 +1,10 @@
/*! /*!
* @file uClock.cpp * @file uClock.cpp
* Project BPM clock generator for Arduino * 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 and Teensy LC. * @brief A Library to implement BPM clock tick calls using hardware timer interruption. Tested on ATmega168/328, ATmega16u4/32u4, ATmega2560, Teensy ARM boards and Seedstudio XIAO M0
* @version 1.0.0 * @version 1.1.0
* @author Romulo Silva * @author Romulo Silva
* @date 01/04/2022 * @date 04/03/2022
* @license MIT - (c) 2022 - Romulo Silva - contact@midilab.co * @license MIT - (c) 2022 - Romulo Silva - contact@midilab.co
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -45,7 +45,7 @@ TimerTCC0 _uclockTimer;
void uclockInitTimer() void uclockInitTimer()
{ {
ATOMIC( ATOMIC(
// Timer1 init // 16bits Timer1 init
// begin at 120bpm (48.0007680122882 Hz) // begin at 120bpm (48.0007680122882 Hz)
TCCR1A = 0; // set entire TCCR1A register to 0 TCCR1A = 0; // set entire TCCR1A register to 0
TCCR1B = 0; // same for TCCR1B TCCR1B = 0; // same for TCCR1B

@ -1,10 +1,10 @@
/*! /*!
* @file uClock.h * @file uClock.h
* Project BPM clock generator for Arduino * 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 and Teensy LC. * @brief A Library to implement BPM clock tick calls using hardware timer interruption. Tested on ATmega168/328, ATmega16u4/32u4, ATmega2560, Teensy ARM boards and Seedstudio XIAO M0
* @version 1.0.0 * @version 1.1.0
* @author Romulo Silva * @author Romulo Silva
* @date 01/04/2022 * @date 04/03/2022
* @license MIT - (c) 2022 - Romulo Silva - contact@midilab.co * @license MIT - (c) 2022 - Romulo Silva - contact@midilab.co
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
@ -34,25 +34,25 @@
namespace umodular { namespace clock { namespace umodular { namespace clock {
#define AVR_CLOCK_FREQ 16000000
#define PHASE_FACTOR 16
#define PLL_X 220
// for smooth slave tempo calculate display you should raise this value // for smooth slave tempo calculate display you should raise this value
// in between 64 to 128. // in between 64 to 128.
// note: this doesn't impact on sync time, only display time getTempo() // 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 // if you dont want to use it, set it to 1 for memory save
#define EXT_INTERVAL_BUFFER_SIZE 24 #define EXT_INTERVAL_BUFFER_SIZE 24
#define MIN_BPM 1
#define MAX_BPM 300
// want a different avr clock support?
#define AVR_CLOCK_FREQ 16000000
#define PHASE_FACTOR 16
#define PLL_X 220
#define SECS_PER_MIN (60UL) #define SECS_PER_MIN (60UL)
#define SECS_PER_HOUR (3600UL) #define SECS_PER_HOUR (3600UL)
#define SECS_PER_DAY (SECS_PER_HOUR * 24L) #define SECS_PER_DAY (SECS_PER_HOUR * 24L)
#define MIN_BPM 1
#define MAX_BPM 300
#define ATOMIC(X) noInterrupts(); X; interrupts(); #define ATOMIC(X) noInterrupts(); X; interrupts();
class uClockClass { class uClockClass {

Loading…
Cancel
Save