import std/[logging, os, strutils] import signal import jacket var jclient: ClientP var event: MidiEvent var midiPort: PortP var status: cint var exitSignalled: bool = false var log = newConsoleLogger(when defined(release): lvlInfo else: lvlDebug) proc cleanup() = debug "Cleaning up..." if jclient != nil: discard jclient.deactivate() discard jclient.clientClose() jclient = nil proc errorCb(msg: cstring) {.cdecl.} = # Suppress verbose JACK error messages when server is not available by # default. Pass ``lvlAll`` when creating the logger to enable them. debug "JACK error: " & $msg proc signalCb(sig: cint) {.noconv.} = debug "Received signal: " & $sig exitSignalled = true proc shutdownCb(arg: pointer = nil) {.cdecl.} = warn "JACK server has shut down." exitSignalled = true proc printMidiEvent(event: var MidiEvent) = if event.size <= 3: for i in 0..