   (aget event "data"))
 
 (defn emit-midi-master-device-event [e]
-  (.call (aget js/Alder.MIDIDispatch "onMIDIMessage")
-         js/Alder.MIDIDispatch
+  (.call (aget (midi-dispatch-obj) "onMIDIMessage")
+         (midi-dispatch-obj)
          (midi-master-device)
          (clj->js e)))

  (.call (aget js/navigator "requestMIDIAccess") js/navigator))

(defn add-midi-message-event-listener [device token callback]
  (.call (aget js/Alder.MIDIDispatch "addMIDIMessageEventListener")
         js/Alder.MIDIDispatch
         device
         token
         callback))

(defn remove-midi-message-event-listener [device token]
  (.call (aget js/Alder.MIDIDispatch "removeMIDIMessageEventListener")
         js/Alder.MIDIDispatch
         device
         token))

(defn midi-master-device []
  (aget js/Alder.MIDIDispatch "masterDevice"))

(defn get-current-midi-master-device []
  (.call (aget js/Alder.MIDIDispatch "currentMasterDevice")
         js/Alder.MIDIDispatch))

(defn set-current-midi-master-device! [device]
  (.call (aget js/Alder.MIDIDispatch "currentMasterDevice")
         js/Alder.MIDIDispatch
         device))

(defn node-device [node]

(ns alder.audio.midiapi)

(defn alder-ns-obj []
  (aget js/window "Alder"))

(defn midi-dispatch-obj []
  (aget (alder-ns-obj) "MIDIDispatch"))

(defn has-midi-access []
  (boolean (aget js/navigator "requestMIDIAccess")))
