|
31 | 31 | (ref-set scope-group* (group :tail ROOT-GROUP))
|
32 | 32 | (satisfy-deps :scope-group-created)))
|
33 | 33 |
|
34 |
| -(defn- update-scope-data [s] |
| 34 | +(defn- update-scope-data |
| 35 | + "Updates the scope by reading the current status of the buffer and repainting. |
| 36 | + Currently only updates bus scope as there's a bug in scsynth-jna which crashes |
| 37 | + the server after too many calls to buffer-data for a large buffer. As buffers |
| 38 | + tend to be large, updating the scope frequently will cause the crash to happen |
| 39 | + sooner. Need to remove this limitation when scsynth-jna is fixed." |
| 40 | + [s] |
35 | 41 | (let [{:keys [buf size width height panel y-arrays x-array panel]} s
|
36 |
| - frames (buffer-data buf) |
| 42 | + frames (if @(:update? s) (buffer-data buf) @(:frames s)) |
37 | 43 | step (int (/ (buffer-size buf) width))
|
38 | 44 | y-scale (- height (* 2 Y-PADDING))
|
39 | 45 | [y-a y-b] @y-arrays]
|
|
44 | 50 | (aget ^floats frames (unchecked-multiply x step)))))))
|
45 | 51 |
|
46 | 52 | (reset! y-arrays [y-b y-a])
|
47 |
| - (.repaint panel))) |
| 53 | + (.repaint panel) |
| 54 | + |
| 55 | + (when (and (not (:bus-synth s)) |
| 56 | + @(:update? s)) |
| 57 | + (reset! (:frames s) frames) |
| 58 | + (reset! (:update? s) false)))) |
48 | 59 |
|
49 | 60 | (defn- update-scopes []
|
50 |
| - (doall (map update-scope-data (vals @scopes*)))) |
| 61 | + (dorun (map update-scope-data (vals @scopes*)))) |
51 | 62 |
|
52 | 63 | (defn- paint-scope [^Graphics g id]
|
53 | 64 | (if-let [scope (get @scopes* id)]
|
|
176 | 187 | :width width
|
177 | 188 | :height height
|
178 | 189 | :x-array x-array
|
179 |
| - :y-arrays (atom [y-a y-b])} |
| 190 | + :y-arrays (atom [y-a y-b]) |
| 191 | + :update? (atom true) |
| 192 | + :frames (atom [])} |
180 | 193 |
|
181 | 194 | _ (reset-data-arrays scope)]
|
182 | 195 | (.addWindowListener frame
|
|
0 commit comments