View difference between Paste ID: RAnWWySs and hMT9zsVd
SHOW: | | - or go back to the newest paste.
1
(defn update-spectrum [mesh]
2
  (s/>->> [:p] [:spectrum-data]
3
       #(if (and (:updated %2) (minim/playing? %1))
4
          (let
5
            [data (:data %2)
6
             l-data (:left data)
7
             r-data (:right data)
8-
             ; [ VARIANT-1 ] --------------------------------------
8+
             vertices (persistent! (reduce (fn [c d] (conj! c (spec-x d (nth l-data d)) (spec-y d (nth r-data d)) 0)) (transient []) (range 360)))
9-
             vertices (mapv (fn [x]
9+
10-
                             ; (println "r = " x " len =" (count l-data))
10+
11-
                             [(spec-x x (nth l-data x)) (spec-y x (nth r-data x)) 0]) (range 360)
11+
12-
                           ;[(spec-x x x) (spec-y x (nth r-data x)) (/ (- x) 5)]) (range 1000)
12+
13-
                           )
13+
14-
             ; [ VARIANT-2 ] --------------------------------------
14+
15-
;             f (fn [x]  [(spec-x x (nth l-data x)) (spec-y x (nth r-data x)) 0])
15+
16-
;             vertices (reduce (fn [c d] (into c [(spec-x d (nth l-data d)) (spec-y d (nth r-data d)) 0])) [] (range 360))
16+
17-
            ; _ (println vertices)
17+
18-
             ; [ VARIANT-3 ] --------------------------------------
18+
19-
;            max-x 360
19+
20-
;            vertices (doall (loop [acc [] x 0]
20+
21-
;                       (if (< max-x x) acc
21+
22-
;                         (let
22+
23-
;                           [v [(spec-x x (nth l-data x)) (spec-y x (nth r-data x)) 0]]
23+
24-
;                           (recur (concat acc v) (+ x 1))))))
24+
25
        (vertex-buffer! mesh vb-type 3 new-buffer))
26
      ; if the existing buffer length is enough for data, re-use the buffer
27
      (do
28
        (.rewind nio-buffer)
29
        (.updateData vb (create-float-buffer data)))))