          trans (translate-seq del seq)]
      (reverse trans))))
 
+(defn transpose-seq
+  ([n] #(transpose-seq n %))
+  ([n seq]
+   (map #(+ n %) seq)))
+
+(defn transpose-names
+  ([n] #(transpose-names n %))
+  ([n seq]
+   (let [oldnotes (map str->midi seq)
+         newnotes (transpose-seq n oldnotes)]
+     (map midi->str newnotes))))
+
+(defn invert-about
+  ([center] #(invert-about center %))
+  ([center nt]
+   (let [diff (- nt center)]
+     (int (- center diff)))))
+      
+(defn invert-seq
+  ([center] #(invert-seq center %))
+  ([center seq]
+   (map (invert-about center) seq)))
+
+(defn invert-names
+  ([n] #(invert-names n %))
+  ([n seq]
+   (let [oldnotes (map str->midi seq)
+         newnotes (invert-seq n oldnotes)]
+     (map midi->str newnotes))))
+
 (defn transform-dict [dict trans]
   (let [kws (keys dict)
         oldvals (vals dict)

        oldmap (get @melody-map id)
        newmap (assoc oldmap :instr val)]
    (swap! melody-map assoc id newmap)))    
  
(defn tonic-chooser [e]
  (let [val (value (.getSource e))]
    (case val
      "A"       (reset! tonic :a3)
      "B\u266D" (reset! tonic :a#3)
      "B"       (reset! tonic :b3)
      "C"       (reset! tonic :c4)
      "C\u266F" (reset! tonic :c#4)
      "D"       (reset! tonic :d4)
      "E\u266D" (reset! tonic :d#4)
      "E"       (reset! tonic :e4)
      "F"       (reset! tonic :f4)
      "F\u266F" (reset! tonic :f#4)
      "G"       (reset! tonic :g4)
      "G\u266F" (reset! tonic :g#4))))

(defn str->midi [strnote]
  (let [oct (read-string (str (last strnote)))
        len (dec (count strnote))
        val (subs strnote 0 len)
        octch (* 12 (- oct 4))]
    (case val
      "C"       (+ 60 octch)
      "C\u266F" (+ 61 octch)
      "D"       (+ 62 octch)
      "E\u266D" (+ 63 octch)
      "E"       (+ 64 octch)
      "F"       (+ 65 octch)
      "F\u266F" (+ 66 octch)
      "G"       (+ 67 octch)
      "G\u266F" (+ 68 octch)
      "A"       (+ 69 octch)
      "B\u266D" (+ 70 octch)
      "B"       (+ 71 octch)
)))

(defn tuning-chooser [e]
  (let [val (value (.getSource e))]
    (case val

                                           (transform-necklace
                                                   (translate-seq (get-e-val e))
                                                   id typekw))])]
    (horizontal-panel :items [reflect-button translabel transbox])))

(defn make-rowops-panel [id]
  (let [reflect-button (button :text "Invert!"
                               :listen [:action
                                        (fn [e]
                                          (transform-necklace
                                           (invert-names (+ (o/note @tonic) 3.5))
                                           id :pitches))])
        translabel (label "Transpose: ")
        transbox (combobox :model (range -6 7)
                           :id (keyword (s/join ["kb-" id "-mel-transpose"]))
                           :listen [:action (fn [e]
                                           (transform-necklace
                                                   (transpose-names (get-e-val e))
                                                   id :pitches))])]
    (horizontal-panel :items [reflect-button translabel transbox])))

;;;;;;;;;;;;;; transforms end
