   (.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
+  (.call (aget (midi-dispatch-obj) "addMIDIMessageEventListener")
+         (midi-dispatch-obj)
          device
          token
          callback))
 
 (defn remove-midi-message-event-listener [device token]
-  (.call (aget js/Alder.MIDIDispatch "removeMIDIMessageEventListener")
-         js/Alder.MIDIDispatch
+  (.call (aget (midi-dispatch-obj) "removeMIDIMessageEventListener")
+         (midi-dispatch-obj)
          device
          token))
 
 (defn midi-master-device []
-  (aget js/Alder.MIDIDispatch "masterDevice"))
+  (aget (midi-dispatch-obj) "masterDevice"))
 
 (defn get-current-midi-master-device []
-  (.call (aget js/Alder.MIDIDispatch "currentMasterDevice")
-         js/Alder.MIDIDispatch))
+  (.call (aget (midi-dispatch-obj) "currentMasterDevice")
+         (midi-dispatch-obj)))
 
 (defn set-current-midi-master-device! [device]
-  (.call (aget js/Alder.MIDIDispatch "currentMasterDevice")
-         js/Alder.MIDIDispatch
+  (.call (aget (midi-dispatch-obj) "currentMasterDevice")
+         (midi-dispatch-obj)
          device))
 
 (defn node-device [node]

(ns alder.audio.midiapi)

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

  (aget event "data"))

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