Skip to content

Latest commit

 

History

History
117 lines (99 loc) · 4.51 KB

20220606083621-midi_clock.org

File metadata and controls

117 lines (99 loc) · 4.51 KB

MIDI clock

See also MIDI messages

Clock Message

  • 24 messages = 1 quarter note.
  • When 24 clock messages are received, the receiving MIDI device knows that 1 quarter note has passed.
  • To generate a MIDI clock signal, calculate the pulse rate based on the BPM and send a simple message at that rate.

Formula

Pulse per ms rate

1 minute = 60 seconds = 60,000 ms

60,000 ms / ppq * bpm

Example using 120 BPM:

ppq = 24.0
bpm = 120.0

ppms = 60_000 / (ppq * bpm)
"One pulse every #{ppms} ms"

Message Contents

Status

0xF8

There is no channel number.

Data

No data is required for this message, just the status byte

Sequencing

MIDI Start

MIDI Stop

MIDI Continue

Sending MIDI Clock from Mixxx

Existing Limitation

Mixxx only supports a 20ms resolution timer. This will work for BPMs under 100 so it’s not practical. See ControllerScriptInterfaceLegacy::beginTimer. It uses QObject startTimer which only supports using MS. This need microsecond precision.

🚨*See Arduino below*

Possible solution

See https://stackoverflow.com/a/21856299.

This would require adding a high resolution timer. Maybe an API like engine.beginHighResTimer.

Other references

RtMidi

https://www.music.mcgill.ca/~gary/rtmidi/

C++ Library for sending/receiving MIDI messages.

Needs jack2 development files

In order to develop stuff depending on RtMidi and compiling for JACK, you’ll need the jackd2 development files:

sudo apt-get install libjack-jackd2-dev

Arduino

The Mixxx midi clock thing ain’t gonna work unless I use an external device to generate the midi clock signal based on beat data from a controller mapping script running in Mixxx’s JS engine. Some data that would be helpful:

See also https://www.youtube.com/watch?v=hSNHhLqYp_o who appears to have accomplished this.

Libraries

TimerOne

https://www.pjrc.com/teensy/td_libs_TimerOne.html

uClock

https://github.com/midilab/uClock/tree/main

Examples

Conclusion

Resources