       (-> f pack! show!)
       f)))
 
+
+(defn make-mono-panel [id]
+  (let [prefix (s/join ["monochord-" (str id) "-"])
+        tonic-kw (keyword (s/join [prefix "tonic"]))
+        tonic-box (combobox :model keyboard)
+        note-label (label "Ratio: ")
+        note-ratio (text :text "" :editable? true)
+        note-bar (horizontal-panel :items [note-label note-ratio])
+        mode-button (button :text "Consecutive"
+                            :listen [:action (fn [e]
+                                               (let [src (.getSource e)
+                                                     curval (value src)]
+                                                 (if (= curval "Consecutive")
+                                                   (config! src :text "Simultaneous")
+                                                   (config! src :text "Consecutive"))))])
+        play-button (button :text "Play"
+                            :listen [:action
+                                     (fn [e]
+                                       (let [ton (str->midi (value tonic-box))
+                                             tonfreq (midi->freq ton)
+                                             ratiostr (value note-ratio)
+                                             ratio (read-string ratiostr)
+                                             notefreq (* tonfreq ratio)
+                                             tonvec [tonfreq 1]
+                                             notevec [notefreq 1]
+                                             simul (= "Simultaneous"
+                                                      (value mode-button))
+                                             score (if simul
+                                                     [["Default" tonvec]
+                                                      ["Default" notevec]]
+                                                     [["Default" tonvec
+                                                       notevec]])
+                                             metro (o/metronome @tempo)]
+                                         (play-score score false)))])
+        pan (vertical-panel :id :monochord
+                            :size [100 :by 200]
+                            :items [tonic-box note-bar mode-button play-button])
+        f (frame :title (s/join ["Monochord " (str id)])
+                 :id (s/join ["mono-" (str id)])
+                 :content pan)]
+    (-> f pack! show!)))
+                                     
+(defn new-mono [e]
+  (swap! counter inc)
+  (make-mono-panel @counter))
+
+                                        
 (defn make-circles-hash [id]
   (let [root (get-in @melody-map [id :root])
         panel (select root [:#kb])

                           (button :id :newPanel
                                   :text "New Panel"
                                   :listen [:action new-panel])
                           (button :id :saveButt
                                   :text "Save"
                                   :listen [:action save-pattern])

;;   (o/connect-external-server 57110)
;; )
(if (not (o/server-connected?))
  (let [portstr (input "Which port should we try?"
                       :value 57110)
        port (read-string portstr)]
    (o/connect-external-server port)
