      (start-scopes-runner)
      (ref-set scopes-running?* true))))
 
+(defn- reset-data-arrays
+  [scope]
+  (let [width     (scope :width)
+        x-array   (scope :x-array)
+        height    (scope :height)
+        [y-a y-b] @(scope :y-arrays)]
+
+    (dotimes [i width]
+      (aset x-array i i))
+
+    (dotimes [i width]
+      (aset y-a i (/ height 2))
+      (aset y-b i (/ height 2)))))
+
+(defn- empty-scope-data
+  []
+  (doall (map reset-data-arrays (vals @scopes*))))
+
 (defn scopes-stop
   []
   (dosync
    (stop-and-reset-pool! scope-pool*)
+   (empty-scope-data)
    (ref-set scopes-running?* false)))
 
 (defn- start-bus-synth


(defn- mk-scope
  [num kind keep-on-top width height]
  (let [id      (uuid)
        name    (str kind ": " num)
        panel   (scope-panel id width height)
        frame   (scope-frame panel name keep-on-top width height)
        x-array (int-array width)
        _x-init (dotimes [i width]
                  (aset x-array i i))
        y-a     (int-array width)
        y-b     (int-array width)
        _y-init (dotimes [i width]
                  (aset y-a i (/ height 2))
                  (aset y-b i (/ height 2)))
        scope   {:id id
                 :name name
                 :size 0
                 :num num
                 :panel panel
                 :kind kind
                 :color (Color. 0 130 226)
                 :background (Color. 50 50 50)
                 :frame frame
                 :width width
                 :height height
                 :x-array x-array
                 :y-arrays (atom [y-a y-b])}]
    (case kind
          :bus (scope-bus scope)
          :buf (scope-buf scope))))

                                        v)]
                        (assoc new-scopes k new-scope)))
                    {}
                    @scopes*))
   (scopes-start)))


(on-deps #{:synthdefs-loaded :scope-group-created} ::reset-scopes reset-scopes)
(on-sync-event :shutdown ::stop-scopes scopes-stop)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Testing
