diff options
| author | Jake Zerrer <him@jakezerrer.com> | 2025-10-16 08:54:19 -0400 |
|---|---|---|
| committer | Jake Zerrer <him@jakezerrer.com> | 2025-10-16 09:25:05 -0400 |
| commit | 9b1b81e5097f05fe879bb67605fa839e2d00bfd1 (patch) | |
| tree | eb694c85f3d6d6b20ba3bc2fa7c0d28ff022ef46 /src/notation.clj | |
| parent | 3454235122b8208af7a30e6fdd374ebe15e9b777 (diff) | |
Added chords
Diffstat (limited to 'src/notation.clj')
| -rw-r--r-- | src/notation.clj | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/src/notation.clj b/src/notation.clj index 6ec09f8..a4b9488 100644 --- a/src/notation.clj +++ b/src/notation.clj @@ -77,17 +77,17 @@ (def pulse (m/signal (m/watch ctr))) (defn note [value duration] - #_ - (m/eduction (take-while #(not= ::done %))) - (m/ap - (m/amb #{value} - (let [c (atom 0) - dxfn (case (m/?< pulse) :inc inc :dec dec)] - (println "AT" (swap! c dxfn)) - (if (< 0 @c duration) - (m/amb #{value}) - (m/amb #{}) - ))))) + (m/eduction (take-while #(not= ::done %)) + (m/ap + (m/amb #{value} + (let [c (atom 0)] + (m/?< pulse) + (swap! c inc) + (if (> @c duration) + (m/amb + #{} + ::done) + (m/amb))))))) (defmacro chord [& notes] @@ -101,12 +101,6 @@ (m/amb= ~@reset-forms) ~union-form))))) -;; We have something pretty cool going. I think chord is actually correct. -;; Line isn't working quite corectly, though. -;; The idea of note storing its internal state is clever, but isn't behaving -;; quite corectly when you try to sequence two chords back to back. Think through -;; how this will work with pulses. You are close! -;; (defmacro line [& notes] `(m/ap (m/amb ~@(map (fn [note] `(m/?< ~note)) notes)))) @@ -125,5 +119,4 @@ (cancel) -(reset! ctr :dec) -(reset! ctr :inc) +(reset! ctr nil) |
