diff --git a/examples/MidiClock/MidiClock.ino b/examples/MidiClock/MidiClock.ino new file mode 100755 index 0000000..eb05552 --- /dev/null +++ b/examples/MidiClock/MidiClock.ino @@ -0,0 +1,53 @@ +#include "Arduino.h" +#include + +// MIDI clock, start and stop byte definitions - based on MIDI 1.0 Standards. +#define MIDI_CLOCK 0xF8 +#define MIDI_START 0xFA +#define MIDI_STOP 0xFC + +// The callback function wich will be called by Clock each Pulse of 96PPQN clock resolution. +void ClockOut96PPQN(uint32_t * tick) +{ + // Send MIDI_CLOCK to external gears + Serial.write(MIDI_CLOCK); +} + +// The callback function wich will be called when clock starts by using Clock.start() method. +void onClockStart() +{ + Serial.write(MIDI_START); +} + +// The callback function wich will be called when clock stops by using Clock.stop() method. +void onClockStop() +{ + Serial.write(MIDI_STOP); +} + +void setup() +{ + + // Initialize serial communication at 31250 bits per second, the default MIDI serial speed communication: + Serial.begin(31250); + + // Inits the clock + uClock.init(); + // Set the callback function for the clock output to send MIDI Sync message. + uClock.setClock96PPQNOutput(ClockOut96PPQN); + // Set the callback function for MIDI Start and Stop messages. + uClock.setOnClockStartOutput(onClockStart); + uClock.setOnClockStopOutput(onClockStop); + // Set the clock BPM to 126 BPM + uClock.setTempo(126); + + // Starts the clock, tick-tac-tick-tac... + uClock.start(); + +} + +// Do it whatever to interface with Clock.stop(), Clock.start(), Clock.setTempo() and integrate your environment... +void loop() +{ + +} diff --git a/library.properties b/library.properties new file mode 100755 index 0000000..484b8bf --- /dev/null +++ b/library.properties @@ -0,0 +1,10 @@ +name=uClock +version=0.8 +author=Romulo Silva , Manuel Odendahl +maintainer=Romulo Silva +sentence=BPM clock generator for Arduino +paragraph=A Library to implement BPM clock tick calls using hardware timer1 interruption. Tested on ATmega168/328, ATmega16u4/32u4 and ATmega2560. +category=Uncategorized +url=https://github.com/midilab/uClock +architectures=avr +includes=uClock.h diff --git a/uClock.cpp b/src/uClock.cpp similarity index 100% rename from uClock.cpp rename to src/uClock.cpp diff --git a/uClock.h b/src/uClock.h similarity index 100% rename from uClock.h rename to src/uClock.h