 ;; Person/Sound Mapping ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defn inst-ns-old
-  "This is the instrument name with full namespace qualifiers. Useful becuase the 'sound name' is really the name of the 'definst' macro created by Overtone."
-    [instrument]
-    (eval (symbol "borderless.sound" instrument)))
-
-(defn inst-ns
-    [instrument]
-    (sound-maker instrument))
-
 (def person-sound (atom {}))
 
 (defn get-sound [pid]
   (if (contains? @person-sound pid)
-    (inst-ns (get @person-sound pid))))
+    ((get @person-sound pid))))
 
 (defn add-person-sound! [pid sound]
   (reset! person-sound (assoc @person-sound pid sound))

    (println pid " entered")

  (case number-of-people
    0 (add-person-sound! pid "drone-aw")
    1 (add-person-sound! pid "drone-ae")
    2 (add-person-sound! pid "drone-eh")
    3 (add-person-sound! pid "drone-oo")
    "atom full: four people are tracked")))

  ;; (case number-of-people
  ;;   0 (add-person-sound! pid "drone-aw-sus")
  ;;   1 (add-person-sound! pid "drone-ae-sus")
  ;;   2 (add-person-sound! pid "drone-eh-sus")
  ;;   3 (add-person-sound! pid "drone-oo-sus")
  ;;   "atom full: four people are tracked")))

(defn control-sound
  "I take a val between 0 and 1000+, map the value, and send it to the instrument's controller."
  [pid val]
  (let [verb-val  (o/scale-range val 0 1000 1 0.3)
        kr-val    (o/scale-range val 0 1000 25 0)
        amp-val   (amplitude-mul val)]
    (if (contains? @person-sound pid)
      (o/ctl (get-sound pid)
           :amp amp-val
           :verb verb-val
           :mod-rate-ctl kr-val))))


;; TODO -

    :else 1))

(defn end-sound! [pid]
  (let [instrument (get @person-sound pid)
        instrument-symbol (inst-name-getter instrument)
        gate-name (ctl-names instrument :gate)]
    (when (contains? (deref person-sound) pid) (o/ctl (eval instrument-symbol) gate-name 0)
          (println "Left: " pid)
          (remove-person-sound! pid))))

(defn reset-atom [current-people]
  (when (seq current-people) (end-sound! (ffirst current-people)) (reset-atom (rest current-people))))
