Skip to content

Commit 3171347

Browse files
authored
Merge pull request #220 from ClojureCivitas/norway-4
Norway meetup
2 parents 2139b26 + 4b92cdb commit 3171347

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

src/clojure_norway/meetup_2025_12/violin.clj

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -462,33 +462,38 @@ wav-format
462462

463463
(require '[tech.v3.libs.buffered-image :as bufimg])
464464

465-
(-> (tensor/compute-tensor
466-
(conj (dtype/shape spectrogram) 3)
467-
(fn [y x c]
468-
((palette (normalized-spectrogram y x))
469-
c)))
470-
bufimg/tensor->image)
465+
spectrogram
466+
467+
(let [[height width] (dtype/shape spectrogram)]
468+
(-> (tensor/compute-tensor
469+
[height width 3]
470+
(fn [y x c]
471+
((palette (normalized-spectrogram
472+
(- height y)
473+
x))
474+
c)))
475+
bufimg/tensor->image))
471476

472477
(defn animated-echarts [specs]
473-
[(kind/reagent
474-
['(fn [specs]
475-
(let [*i (reagent.core/atom 0)]
476-
(fn []
477-
^{:key @*i}
478-
[:div
479-
[:div {:style {:height "400px"}
480-
:ref (fn [el]
481-
(when el
482-
(let [chart (.init js/echarts el)]
483-
(.setOption chart
484-
(clj->js
485-
(specs (rem @*i (count specs))))))))}]
486-
(js/setInterval #(swap! *i inc) 1000)
487-
;; Include this to force component update:
488-
[:p {:style {:display :none}}
489-
(hash @*i)]])))
490-
specs]
491-
{:html/deps [:echarts]})])
478+
(kind/reagent
479+
['(fn [specs]
480+
(let [*i (reagent.core/atom 0)]
481+
(fn []
482+
^{:key @*i}
483+
[:div
484+
[:div {:style {:height "400px"}
485+
:ref (fn [el]
486+
(when el
487+
(let [chart (.init js/echarts el)]
488+
(.setOption chart
489+
(clj->js
490+
(specs (rem @*i (count specs))))))))}]
491+
(js/setInterval #(swap! *i inc) 1000)
492+
;; Include this to force component update:
493+
[:p {:style {:display :none}}
494+
(hash @*i)]])))
495+
specs]
496+
{:html/deps [:echarts]}))
492497

493498
(comment
494499
(let [n 100]

0 commit comments

Comments
 (0)