Skip to content

Commit

Permalink
extract unit-phase-sin from envelope-collapse to equations
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Dec 6, 2024
1 parent 9cf56b0 commit 04c4f24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/shimmers/math/equations.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
^double [^double r ^double t ^double phase]
(math/sin (* TAU (+ (* r t) phase))))

(defn unit-phase-sin
^double [^double r ^double t ^double phase]
(+ 0.5 (* 0.5 (math/sin (* TAU (+ (* r t) phase))))))

(defn sqr [x]
(* x x))

Expand Down
6 changes: 1 addition & 5 deletions src/shimmers/sketches/envelope_collapse.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@
(assoc state
:t (seconds)))

(defn utsin
^double [^double r ^double t ^double phase]
(+ 0.5 (* 0.5 (math/sin (* eq/TAU (+ (* r t) phase))))))

;; FIXME: amplitude modulation somewhere here slows down after too many frames
(defn graph [t]
(let [t (* 0.1 t)]
(fn [x]
(let [tx (+ (eq/phase-sin 0.05 t -0.1)
(utsin 1.15 t (* 0.2 x))
(eq/unit-phase-sin 1.15 t (* 0.2 x))
(* 0.1 x))
dtx
(* 1.5 (eq/phase-sin 0.23 t (* 0.5 x (eq/phase-sin 1.25 t (+ 0.001 x)))))]
Expand Down

0 comments on commit 04c4f24

Please sign in to comment.