 (defonce midi-devices* (atom {}))
 (defonce midi-control-agents* (atom {}))
 (defonce poly-players* (atom {}))
-(defonce seen-midi-device-keys* (atom #{}))
 
 (def EXCLUDED-DEVICES #{"Real Time Sequencer" "Java Sound Synthesizer"})
 

        dev-event-key (midi-mk-full-device-event-key dev command)]
    (event [:midi command] msg)
    (event (midi-mk-full-control-event-key dev command (:data1 msg)) msg)
    (event dev-event-key msg)
    (when-not (get @seen-midi-device-keys* dev-key)
      (swap! seen-midi-device-keys* conj dev-key))))

(defn- detect-midi-devices
  "Designed to run periodically and update the midi-devices* atom with


(defn midi-player-stop
  ([]
     (remove-handler [::midi-poly-player :midi :note-on])
     (remove-handler [::midi-poly-player :midi :note-off]))
  ([player-or-key]
     (if (keyword? player-or-key)
       (midi-player-stop (get @poly-players* player-or-key))
       (let [player player-or-key]
         (when-not (= ::midi-poly-player (type player))
           (throw (IllegalArgumentException. (str "Expected a midi-poly-player. Got: " (prn-str (type player))))))
         (remove-handler (:on-key player))
         (remove-handler (:off-key player))
         (reset! (:playing? player) false)
         (swap! poly-players* dissoc (:player-key player))
         player))))


(defn midi-capture-next-control-input
