Source code for jdxi_editor.midi.io.clock

"""clock test file"""

import time

import mido

try:
[docs] outport = mido.open_output()
except Exception as e: print(f"Error opening MIDI output port: {e}") exit()
[docs] clock_message = mido.Message("clock")
[docs] tempo = 120
[docs] time_per_pulse = (60 / tempo) / 24
try: while True: outport.send(clock_message) time.sleep(time_per_pulse) except KeyboardInterrupt: print("Stopping MIDI clock.") finally: outport.close()