summaryrefslogtreecommitdiff
path: root/src/unheard/time_object.clj
diff options
context:
space:
mode:
authorJake Zerrer <him@jakezerrer.com>2025-11-25 14:53:20 -0500
committerJake Zerrer <him@jakezerrer.com>2025-11-25 15:24:39 -0500
commit20ce2f424552a6124575c79c1ce5476addbaba95 (patch)
tree3230c1c7efd7a212cbcdb0b17b0dad1f622a69b1 /src/unheard/time_object.clj
parent1a3fefa99bc49f0cbedf0318b802ac334a6be16b (diff)
Implement interval tree logic
Diffstat (limited to 'src/unheard/time_object.clj')
-rw-r--r--src/unheard/time_object.clj22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/unheard/time_object.clj b/src/unheard/time_object.clj
index d2e888f..eea950b 100644
--- a/src/unheard/time_object.clj
+++ b/src/unheard/time_object.clj
@@ -19,6 +19,7 @@
;; BUG c9be408
(defn phrase
+ ;; TODO: Description
[& children]
(fn [start]
{:start start,
@@ -27,19 +28,20 @@
(update time-object :start (partial + start)))}))
(comment
- (def a (phrase (lift (time-object 0 4 :x))))
+ (def a (phrase (lift (time-object 0 4 :x)) (lift (time-object 0 4 :a))))
(def b
(phrase (a 0)
(a 1)
- (lift (time-object 10 2 :x))
+ (lift (time-object 10 2 :x) (time-object 10 2 :b))
(lift (time-object 0 2 :y))))
(def c (phrase (b 0) (b 3)))
(c 0))
(defn timeline
"Primary timeline bookkeeping mehanism."
- [{:keys [time-objects]}]
- (let [m imap/empty]
+ [phrase]
+ (let [{:keys [time-objects]} (phrase 0)
+ m imap/empty]
(if (seq? time-objects)
(loop [time-objects time-objects
m m]
@@ -50,18 +52,20 @@
m)))
(comment
- (def t (timeline (a 0)))
- (def t (timeline (c 0)))
- (get t 2))
+ (def t (timeline a))
+ (def t (timeline c))
+ (get t 1))
(defn point-query
"Query a timeline. Returns a flow of time objects."
[timeline >at]
- (m/ap (let [at (m/?< >at)] (get timeline at))))
+ (m/stream (m/ap (let [at (m/?< >at)] (get timeline at)))))
+
(comment
(def at (atom 0))
(def >at (m/watch at))
(def cancel ((m/reduce prn nil (point-query t >at)) prn prn))
- (reset! at 0)
+ (reset! at 1)
+ (reset! at 14)
(cancel))