 (defmethod notes :blues [{:keys [pitch]}]
   (let [minor-pentatonic (pentatonic-scale pitch :minor)
         extra-note       (augment (nth minor-pentatonic 2))]
-    (set (concat (take 3 minor-pentatonic) 
+    (set (concat (take 3 minor-pentatonic)
                  [extra-note]
                  (drop 3 minor-pentatonic)))))

        letter->number (zipmap "abcdefg" (range 8))
        number->letter (zipmap (range 8) "ABCDEFG")
        base-number    (->> pitch name first letter->number)
        base-notes     (take 7 (map number->letter 
                                    (iterate #(rem (inc %) 7) base-number)))
        {:keys [sharps flats]} (key-signature pitch major-or-minor)]
    (map (fn [letter] 
           (str letter (when (and sharps (sharps letter)) \#) 
                       (when (and flats (flats letter)) \b)))
         base-notes)))



(defn sanitize [pitch scale]
  "For the sake of simplicity, Riffmuse does not support the use of more than
   one accidental; e.g., double sharps and double flats. For this reason,
   scales like E# major (E# Fx Gx A# B# Cx Dx) are not supported. This function
   is used to ensure that such scales will be spelled enharmonically, e.g.
   E# major -> F major (F G A Bb C D E)."
  (get (condp contains? scale
         #{:major :major-pentatonic}
         {:d-sharp :e-flat, :e-sharp :f, :f-flat :e,
          :g-sharp :a-flat, :a-sharp :b-flat, :b-sharp :c}

         #{:minor :minor-pentatonic :blues}
         {:c-flat :b, :d-flat :c-sharp, :e-sharp :f, :f-flat :e,
          :g-flat :f-sharp, :a-flat :g-sharp, :b-sharp :c})
       pitch
       pitch))

(defn scale-name [{:keys [pitch scale]}]
  "Converts a scale (a map) to a human-readable string version of its name."
  (let [pitch (when pitch
                (str/replace (name (sanitize pitch scale)) #"-flat|-sharp"
                             {"-flat" "b" "-sharp" "#"}))
        scale (str/replace (name scale) #"-" " ")]
    (-> (str pitch \space scale) str/trim str/capitalize)))

(defmulti notes
  "Takes the scale (a map) output by parse-cli-args and returns a set of
   notes representing the appropriate scale."
   :scale)

