   (:import [java.io InputStream]
            [java.util.concurrent LinkedBlockingDeque]
            [java.util.regex Pattern]
-           [javax.sound.midi MidiDevice MidiDevice$Info]))
+           [javax.sound.midi MidiDevice MidiDevice$Info MidiUnavailableException]))
 
 (def ^:private max-clock-intervals
   "How many MIDI clock pulses and interval averages should be kept

  (swap! new-device-handlers disj f))

(defonce ^{:private true
          :doc "Functions to be called when a device disappears from
  the MIDI environment. Keys are the `javax.sound.midi.MidiDevice`
  whose departure is of interest, and values are a set of functions to
  be called if and when that device ceases to exist. They will be

  midi-outputs (atom {}))

(defonce ^{:private true
           :doc "Functions to be called when a new device appears in
  the MIDI environment. They will be passed a single argument, the
  `:midi-device` map from `overtone.midi` representing the new
  device."} new-device-handlers
  (atom #{}))

;; Originally I was using the `:device`, which worked fine with CoreMIDI4J, but turned out
;; to be a different object every time the standard MIDI SPI was asked to enumerate devices.
