 (defn create-midi-port-filter
   "Return a filter which selects midi inputs and outputs we actually
   want to use. If this is a Mac, and the Humatic MIDI extension has
-  been installed, create a filter which will accept only its ports.
-  Otherwise, return a filter which accepts all ports."
+  been installed, create a filter which will accept only its versions
+  of ports which it offers in parallel with the standard
+  implementation. Otherwise, return a filter which accepts all ports."
   []
   (if (and (mac?) (mmj-installed?))
-    mmj-device?
+    (fn [device]
+      (let [mmj-descriptions (set (map :description (filter #(mmj-device? %)
+                                                            (overtone.midi/midi-sources))))]
+        (or (mmj-device? device)
+            ;; MMJ returns devices whose descriptions match the names of the
+            ;; broken devices returned by the broken Java MIDI implementation.
+            (not (mmj-descriptions (:name device))))))
     identity))
 
 ;; TODO: This and open-outputs will have to change once hot-plugging works.


         (throw (IllegalArgumentException. (str "More than one MIDI clock source " (describe-name-filter name-filter)
                                                "was found."))))))))

(defn identify-mapping
  "Report on the next MIDI control or note message received, to aid in

      (filter #(or (re-find pattern (:name %1))
                   (re-find pattern (:description %1)))
              devices))))

;; A simple object to help provide a user interface for selecting between available MIDI
;; clock sync sources
(defrecord ClockFinder [listener results]
  IClockFinder
  (finder-current-sources [this] @results)
  (finder-finished [this]
    (remove-global-handler! listener)
    (reset! results nil)))

(defn watch-for-clock-sources
  "Returns a clock finder that will watch for sources of MIDI clock
  pulses until you tell it to stop."
  []
  (open-inputs-if-needed!)
  (let [clock-sources (atom #{})
        clock-listener (fn [msg]
                         (when (= (:status msg) :timing-clock)
                           (swap! clock-sources conj (:device msg))))]
    (add-global-handler! clock-listener)
    (ClockFinder. clock-listener clock-sources)))

(defn sync-to-midi-clock
  "Returns a sync function that will cause the beats-per-minute
