fix frme rte things
This commit is contained in:
parent
9af21c5d10
commit
a10d7b2d9f
44 changed files with 889 additions and 716 deletions
|
|
@ -34,10 +34,10 @@
|
|||
:features {:face-1/mouth {:id :face-1/mouth :subject :face-1
|
||||
:symbol :face-1 :area :mouth :nodes [:mouth] :params {}}}
|
||||
:groups {}
|
||||
:symbols {:main {:id :main :fps 30 :frames 10
|
||||
:symbols {:main {:id :main :frames 10
|
||||
:nodes {:face-1 {:id :face-1 :kind :instance :z "a1"
|
||||
:source {:symbol :face-1}}}}
|
||||
:face-1 {:id :face-1 :fps 30 :frames 10
|
||||
:face-1 {:id :face-1 :frames 10
|
||||
:nodes {:head {:id :head :kind :group :z "a1"
|
||||
:measured {[:xform :pos]
|
||||
{:animated? false :value [0 0]}}}
|
||||
|
|
|
|||
|
|
@ -1,284 +0,0 @@
|
|||
(ns arthur.domain.cadence-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[arthur.domain.bring :as bring]
|
||||
[arthur.domain.cadence :as cadence]
|
||||
[arthur.domain.channel :as ch]
|
||||
[arthur.domain.clip :as clip]
|
||||
[arthur.domain.leaf :as leaf]
|
||||
[arthur.domain.nest :as nest]
|
||||
[arthur.domain.node :as node]
|
||||
[arthur.domain.palette :as pal]
|
||||
[arthur.domain.pick :as pick]
|
||||
[arthur.domain.pose :as pose]
|
||||
[arthur.ui.timeline :as timeline]))
|
||||
|
||||
(def footage
|
||||
{:fps 30 :width 100 :height 100
|
||||
:symbols {:main {:id :main :fps 30 :frames 60
|
||||
:nodes {:mark {:id :mark :kind :rect :z "a" :pose-group :mouth
|
||||
:channels {[:geom :size] {:animated? true :pose-sampled? true
|
||||
:dense {:store "sizes" :offset 0 :stride 1 :frames 60}}
|
||||
[:style :color] (ch/framed :brow)}}}}}})
|
||||
(def store {"sizes" {:data (js/Float64Array. (clj->js (range 1 61)))}})
|
||||
|
||||
(deftest selection-is-integral-and-never-early
|
||||
(is (= [0 2 5 7 10 12] (mapv #(cadence/frame % 12 30) (range 6))))
|
||||
(doseq [grid [8 12 24 30 60] native [12 24 30 60] f (range 90)]
|
||||
(let [selected (cadence/frame f grid native)]
|
||||
(is (and (integer? selected) (<= selected (/ (* f native) grid))
|
||||
(< (- (/ (* f native) grid) selected) 1))))))
|
||||
|
||||
(deftest changing-output-fps-preserves-dense-content-and-seconds
|
||||
(let [doc (clip/set-fps footage 12)
|
||||
draw (clip/resolver doc :main store pal/index-of nil)]
|
||||
(is (= 24 (clip/output-frames doc :main)))
|
||||
(is (= (:symbols footage) (:symbols doc)))
|
||||
(is (= footage (clip/set-fps doc 30)))
|
||||
(is (= doc (leaf/clip "test" (leaf/leaves "test" doc))))
|
||||
(is (= [1 3 6 8 11 13] (mapv #(:size (first (draw %))) (range 6))))
|
||||
;; `nest/inside` and the timeline's rows are in the SYMBOL's own frames --
|
||||
;; see `docs/one-grid-plan.md`. Frame 7 of :main is frame 7 of :main; the
|
||||
;; output frame that shows it is 3, and `shown-frame` is the one function
|
||||
;; that crosses between the two.
|
||||
(is (= 7 (:frame (nest/inside doc store :main [:mark] 7))))
|
||||
(is (= 7 (clip/shown-frame doc :main 3)))
|
||||
(is (= 3 (clip/first-output-frame doc :main 7)))
|
||||
(is (= [0 60] (:span (first (timeline/rows doc :main #{})))))))
|
||||
|
||||
(deftest changing-fps-before-authoring-moves-the-empty-canvas-to-that-grid
|
||||
(let [doc (clip/set-fps (clip/blank) 12)]
|
||||
(is (= 12 (:fps doc)))
|
||||
(is (nil? (get-in doc [:symbols :main :fps])))
|
||||
(is (= 48 (clip/frames doc :main)))
|
||||
(is (= 48 (clip/output-frames doc :main)))
|
||||
(is (= 8 (clip/shown-frame doc :main 8)))
|
||||
(is (= 8 (clip/first-output-frame doc :main 8)))))
|
||||
|
||||
(deftest changing-fps-after-authoring-preserves-the-symbols-native-grid
|
||||
(let [started (assoc-in (clip/blank) [:symbols :main :nodes :mark]
|
||||
{:id :mark :kind :rect :z "a"})
|
||||
doc (clip/set-fps started 12)]
|
||||
(is (= 30 (get-in doc [:symbols :main :fps])))
|
||||
(is (= 120 (clip/frames doc :main)))
|
||||
(is (= 48 (clip/output-frames doc :main)))))
|
||||
|
||||
(deftest project-fps-is-the-root-symbols-editing-grid
|
||||
(let [doc (-> (clip/blank)
|
||||
(assoc-in [:symbols :main :nodes :child]
|
||||
{:id :child :kind :instance :z "a"
|
||||
:source {:symbol :nested}})
|
||||
(assoc-in [:symbols :nested]
|
||||
{:id :nested :fps 30 :frames 90 :nodes {}})
|
||||
(clip/set-root-fps 12))]
|
||||
(is (= 12 (:fps doc)) "the output grid")
|
||||
(is (= 12 (clip/fps doc :main)) "is also the root editing grid")
|
||||
(is (= 30 (clip/fps doc :nested)) "while a nested symbol keeps its own grid")
|
||||
(is (= 120 (clip/frames doc :main)) "frame positions are not rewritten")))
|
||||
|
||||
(deftest crossing-to-the-output-grid-and-back-lands-on-the-frame-it-names
|
||||
;; `first-output-frame` is the inverse of `shown-frame` as far as a floor has
|
||||
;; one: seeking to the output frame it names puts the playhead on a frame at or
|
||||
;; after the mark, never before it, and exactly on it whenever an output frame
|
||||
;; shows it at all.
|
||||
(doseq [project [8 12 24 30 60] native [12 24 30 60]]
|
||||
(let [doc (-> footage (assoc :fps project) (assoc-in [:symbols :main :fps] native))]
|
||||
(doseq [n (range 40)]
|
||||
(let [f (clip/first-output-frame doc :main n)]
|
||||
(is (integer? f))
|
||||
(is (>= (clip/shown-frame doc :main f) n)
|
||||
(str n " at " project "/" native))
|
||||
(is (or (zero? f) (< (clip/shown-frame doc :main (dec f)) n))))))))
|
||||
|
||||
(deftest imported-footage-uses-selection-for-picture-and-real-speed-for-audio
|
||||
(let [tracked (-> footage
|
||||
(assoc :analyses {"a" {:id "a"}}
|
||||
:subjects {:face-1 {:id :face-1 :analysis "a"
|
||||
:source-subject :face-1}}
|
||||
:features {} :groups {}
|
||||
:symbols {:main {:id :main :fps 30 :frames 60
|
||||
:nodes {:face-1 {:id :face-1 :kind :instance
|
||||
:z "a" :source {:symbol :face-1}}}}
|
||||
:face-1 (get-in footage [:symbols :main])}))
|
||||
{doc :clip sid :sid} (bring/take (clip/set-fps (clip/blank) 12)
|
||||
tracked "take" "video" [15 75])
|
||||
;; A host authored at 12, with a 30fps source starting half a second in.
|
||||
doc (-> doc (assoc-in [:symbols :main :fps] 12)
|
||||
(clip/place-symbol store :main sid 6 :insert nil))
|
||||
n (get-in doc [:symbols :main :nodes :insert])
|
||||
draw (clip/resolver doc :main store pal/index-of nil)
|
||||
[sound] (nest/audio-tracks doc :main)]
|
||||
(is (= 60 (clip/frames doc sid)))
|
||||
(is (= 1 (get-in doc [:symbols :take.face-1 :nodes :sound :time :rate])))
|
||||
(is (= [0 24] (:span n)))
|
||||
(is (empty? (draw 5)))
|
||||
(is (= 8 (:size (first (draw 9)))))
|
||||
(is (= 7 (:frame (nest/inside doc store :main [:insert :face-1 :mark] 9))))
|
||||
(is (= [-4 -4 4 4] ((pick/bounds-of doc store :main n) 3)))
|
||||
(is (= [6 30] (node/placed-span sound)))
|
||||
(is (= 15 (node/local-frame sound 6)))
|
||||
(is (= 1 (* (get-in sound [:time :rate]) (/ (:fps doc) (:fps sound)))))
|
||||
(is (= [6 30] (:span (first (timeline/rows doc :main #{[:insert]})))))
|
||||
(testing "a deliberate half speed still retimes audio"
|
||||
(let [slow (assoc-in doc [:symbols :main :nodes :insert :playback :speed] 0.5)
|
||||
[track] (nest/audio-tracks slow :main)]
|
||||
(is (= 0.5 (* (get-in track [:time :rate]) (/ (:fps slow) (:fps track)))))))))
|
||||
|
||||
(deftest generated-faces-own-their-footage-sound
|
||||
(let [face (fn [id] {:id id :fps 30 :frames 20 :nodes {}})
|
||||
frozen {:fps 30 :analyses {"a" {:id "a"}}
|
||||
:subjects {:face-1 {:id :face-1 :analysis "a" :source-subject :face-1}
|
||||
:face-2 {:id :face-2 :analysis "a" :source-subject :face-2}}
|
||||
:symbols {:main {:id :main :fps 30 :frames 20
|
||||
:nodes {:face-1 {:id :face-1 :kind :instance :z "a1"
|
||||
:source {:symbol :face-1}}
|
||||
:face-2 {:id :face-2 :kind :instance :z "a2"
|
||||
:source {:symbol :face-2}}}}
|
||||
:face-1 (face :face-1)
|
||||
:face-2 (face :face-2)}}
|
||||
{doc :clip take :sid} (bring/take (clip/blank) frozen "take" "video" [3 13])
|
||||
alone (clip/place-symbol doc nil :main :take.face-1 4 :placed-face nil)]
|
||||
(is (nil? (get-in doc [:symbols take :nodes :sound]))
|
||||
"the wrapper does not own a sound the face would lose")
|
||||
(is (= {:footage "video"}
|
||||
(get-in doc [:symbols :take.face-1 :nodes :sound :source])))
|
||||
(is (= 1 (count (nest/audio-tracks doc take)))
|
||||
"the same take recording is not mixed once per detected face")
|
||||
(is (= 1 (count (nest/audio-tracks alone :main)))
|
||||
"placing a generated face by itself brings its associated sound")))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; the preserve-snap
|
||||
;;
|
||||
;; `footage` above is the cadence with no opinion about content: at 12 out of 30
|
||||
;; it reads 0, 2, 5, 7, 10, 12, 15 … and the frames between those it shows to
|
||||
;; nobody. `closure` is the same take with something in one of those gaps worth
|
||||
;; seeing — docs/frame-selection.md's synthetic case, a mouth that shuts for ONE
|
||||
;; native frame, 13, which no 12-from-30 slot ever samples.
|
||||
|
||||
(defn- sized
|
||||
"A dense `[:geom :size]` over the whole take. The store holds 1..60, so a DRAWN
|
||||
SIZE NAMES THE NATIVE FRAME it was read from: size = frame + 1. That is the
|
||||
whole reason the fixture draws rects — the picture says which frame it is."
|
||||
[]
|
||||
{:animated? true :dense {:store "sizes" :offset 0 :stride 1 :frames 60}})
|
||||
|
||||
(def closure
|
||||
"A head that holds still and a mouth that shuts for one native frame.
|
||||
|
||||
The cut is the one `flow/freeze` already stores and nothing new: `[:vis]` keys
|
||||
on the interior, `:hold`, provenance `:roto/mouth-aperture`, hidden meaning
|
||||
shut. The head's size is NOT `:pose-sampled?` and carries no `:pose-group`,
|
||||
which is what makes it the control — a head reads the cadence whatever the
|
||||
mouth does."
|
||||
{:fps 30 :width 100 :height 100
|
||||
:symbols
|
||||
{:face
|
||||
{:id :face :fps 30 :frames 60
|
||||
:nodes
|
||||
{:head {:id :head :kind :rect :z "a"
|
||||
:channels {[:geom :size] (sized)
|
||||
[:style :color] (ch/framed :brow)}}
|
||||
:mouth-in {:id :mouth-in :kind :rect :parent :head :z "b"
|
||||
:pose-group :mouth
|
||||
:channels {[:geom :size] (assoc (sized) :pose-sampled? true)
|
||||
[:style :color] (ch/framed :mouth-dark)
|
||||
[:vis] (assoc (ch/keyed {0 true, 13 false, 14 true} :hold)
|
||||
:pose-sampled? true
|
||||
:generated {:by :roto/mouth-aperture})}}}}}})
|
||||
|
||||
(defn- drawn
|
||||
"What each node draws at output frame `f`, as `node -> size`. A node missing
|
||||
from the map was not drawn at all, which for the mouth interior IS the shut
|
||||
mouth: `[:vis]` false takes the part off the frame."
|
||||
[r f]
|
||||
(into {} (map (juxt :node :size)) (r f)))
|
||||
|
||||
(deftest a-dropped-closure-reaches-exactly-one-output-frame
|
||||
(let [doc (clip/set-fps closure 12)
|
||||
n (clip/output-frames doc :face)
|
||||
r (clip/resolver doc :face store pal/index-of {:snap #{:face}})
|
||||
fs (mapv #(drawn r %) (range n))]
|
||||
(is (= 24 n))
|
||||
(is (not-any? #{13} (map #(cadence/frame % 12 30) (range n)))
|
||||
"the cadence alone never samples the closure — that is the gap")
|
||||
(testing "off is the cadence alone, and is what an opts map saying nothing gets"
|
||||
(doseq [[what opts] [["no opts at all" nil]
|
||||
["another face switched on" {:snap #{:somebody-else}}]]]
|
||||
(let [off (clip/resolver doc :face store pal/index-of opts)]
|
||||
(is (every? #(contains? (drawn off %) :mouth-in) (range n))
|
||||
(str "with " what " the closure is never recovered"))
|
||||
(is (= (mapv #(inc (cadence/frame % 12 30)) (range n))
|
||||
(mapv #(:mouth-in (drawn off %)) (range n)))
|
||||
(str "with " what " every slot reads what the grid says")))))
|
||||
(is (= [6] (filterv #(not (contains? (nth fs %) :mouth-in)) (range n)))
|
||||
"the shut mouth reaches exactly one output frame")
|
||||
(is (= [1 3 6 8 11 13 nil 18] (mapv :mouth-in (take 8 fs)))
|
||||
"slot 6 snaps back from 15 to 13; no other slot moves")
|
||||
(is (= (mapv #(inc (cadence/frame % 12 30)) (range n)) (mapv :head fs))
|
||||
"and the head reads what the cadence says, on every frame including 6")
|
||||
(testing "through an instance, where the grid becomes native at the boundary"
|
||||
(let [host (-> doc
|
||||
(assoc-in [:symbols :stage] {:id :stage :fps 12 :frames 24 :nodes {}})
|
||||
(clip/place-symbol store :stage :face 0 :cel nil))
|
||||
hr (clip/resolver host :stage store pal/index-of {:snap #{:face}})
|
||||
hfs (mapv #(drawn hr %) (range 24))]
|
||||
(is (= [6] (filterv #(not (contains? (nth hfs %) [:cel :mouth-in])) (range 24))))
|
||||
(is (= [1 3 6 8 11 13 nil 18] (mapv #(get % [:cel :mouth-in]) (take 8 hfs))))
|
||||
(is (= (mapv #(inc (cadence/frame % 12 30)) (range 24))
|
||||
(mapv #(get % [:cel :head]) hfs)))
|
||||
(is (= (mapv #(inc (cadence/frame % 12 30)) (range 24))
|
||||
(let [hostly (clip/resolver host :stage store pal/index-of
|
||||
{:snap #{:stage}})]
|
||||
(mapv #(get (drawn hostly %) [:cel :mouth-in]) (range 24))))
|
||||
"the switch is the FACE's: naming the host that places it marks nothing")
|
||||
(testing "a hand cut beats a snap, always"
|
||||
(let [held (pose/put-cut host :stage :cel :mouth 0 0)
|
||||
kr (clip/resolver held :stage store pal/index-of {:snap #{:face}})
|
||||
kfs (mapv #(drawn kr %) (range 24))]
|
||||
(is (= (vec (repeat 24 1)) (mapv #(get % [:cel :mouth-in]) kfs))
|
||||
"the hand said hold frame 0, so the closure is never recovered")))))))
|
||||
|
||||
(deftest preserve-marks-are-the-frames-a-closure-cut-calls-shut
|
||||
(let [nodes (get-in closure [:symbols :face :nodes])
|
||||
vis (fn [ch] {:solo {:id :solo :kind :rect :pose-group :solo
|
||||
:channels {[:vis] ch}}})]
|
||||
(is (= {:mouth [13]} (pose/marks nodes 60 store))
|
||||
"one mark, per pose group, for the one frame the cut calls shut")
|
||||
(is (nil? (pose/marks (select-keys nodes [:head]) 60 store))
|
||||
"a node with no [:vis] has no closure and gets no marks")
|
||||
(is (nil? (pose/marks nodes nil store))
|
||||
"a symbol with no length has no frames to mark")
|
||||
(testing "a hidden feature is not a closure"
|
||||
(is (nil? (pose/marks (vis (assoc (ch/keyed {0 true, 13 false, 14 true} :hold)
|
||||
:generated {:by :pixels/teeth}))
|
||||
60 store))
|
||||
"the teeth being occluded says nothing about a mouth shutting")
|
||||
(is (nil? (pose/marks (vis (ch/keyed {0 true, 13 false, 14 true} :hold)) 60 store))
|
||||
"and a hand-keyed [:vis] with no provenance is not a cut either"))
|
||||
(testing "an absent measurement is not a closure"
|
||||
(is (nil? (pose/marks (vis (assoc (ch/keyed {} :hold)
|
||||
:generated {:by :roto/blink}))
|
||||
60 store))
|
||||
"no value on a frame is not the same fact as shut on it"))))
|
||||
|
||||
(deftest a-slot-snaps-back-to-a-mark-and-never-forward
|
||||
(let [m (pose/marks (get-in closure [:symbols :face :nodes]) 60 store)]
|
||||
(is (= 13 (pose/snapped-frame m :mouth 12 15))
|
||||
"slot 6, whose default is 15, reads 13")
|
||||
(is (= 12 (pose/snapped-frame m :mouth 10 12))
|
||||
"slot 5 does NOT reach forward from 12 to 13 — that would lead the cut")
|
||||
(is (= 17 (pose/snapped-frame m :mouth 15 17))
|
||||
"slot 7 cannot reach back past its own gap to a frame slot 6 showed")
|
||||
(is (= 13 (pose/snapped-frame m :mouth 12 13))
|
||||
"a mark that IS the default is simply the default")
|
||||
(is (= 15 (pose/snapped-frame m :mouth 15 15))
|
||||
"an empty interval — a slot reading what the one before it read — snaps nothing")
|
||||
(is (= 15 (pose/snapped-frame m :other 12 15))
|
||||
"marks are per group: another group's closure is not this one's")
|
||||
(is (= 15 (pose/snapped-frame nil :mouth 12 15))
|
||||
"and no marks at all is the cadence back again")
|
||||
(testing "never later than the slot's own instant, over every grid and native pair"
|
||||
(doseq [grid [8 12 24 30 60] native [12 24 30 60] f (range 90)]
|
||||
(let [hi (cadence/frame f grid native)
|
||||
lo (if (pos? f) (cadence/frame (dec f) grid native) -1)]
|
||||
(is (<= (pose/snapped-frame m :mouth lo hi) (/ (* f native) grid))))))))
|
||||
|
|
@ -250,10 +250,6 @@
|
|||
(is (seq (clip/problems (assoc c :root :gone)))))
|
||||
(testing "without a root, the longest symbol nothing places"
|
||||
(is (= :outer (clip/opens-on (dissoc c :root)))))
|
||||
(testing "a document saved before roots opens on :main, not a longer take"
|
||||
(is (= :main (:root (clip/pin-root (dissoc c :root)))))
|
||||
(is (= :outer (:root (clip/pin-root (-> c (dissoc :root) (update :symbols dissoc :main))))))
|
||||
(is (= :loose (:root (clip/pin-root (assoc c :root :loose))))))
|
||||
(testing "an instance can go into any symbol, and spans that symbol's frames"
|
||||
(let [[n] (vals (get-in c [:symbols :outer :nodes]))]
|
||||
(is (= #{:inner} (node/sources n)))
|
||||
|
|
@ -323,7 +319,7 @@
|
|||
made (clip/new-symbol c :outer id 20 u)]
|
||||
(is (= :symbol-1 id))
|
||||
(is (= :symbol-2 (clip/fresh-id made)) "the next one does not collide")
|
||||
(is (= {:id :symbol-1 :name "symbol-1" :fps 30 :frames 180 :nodes {}}
|
||||
(is (= {:id :symbol-1 :name "symbol-1" :frames 180 :nodes {}}
|
||||
(clip/symbol made :symbol-1))
|
||||
"empty, ordinary, and as long as the rest of what it was placed in")
|
||||
(is (= {:span [0 180] :time {:mode :map :at 20 :rate 1}}
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@
|
|||
;; A TIMELINE ID IS A SEGMENT, which is what lets a symbol's nodes be
|
||||
;; addressed by the same path shape as the clip's own. `main` is the root.
|
||||
(is (contains? ls "clip/c7/symbol/main"))
|
||||
(is (= {:frames 229 :fps 30} (get ls "clip/c7/symbol/main"))
|
||||
"a symbol persists its native grid separately from the output grid")
|
||||
(is (= {:frames 229} (get ls "clip/c7/symbol/main"))
|
||||
"a symbol persists its frames and no rate: the rate is the document's")
|
||||
;; Nodes are local to the face timeline; feature and group ids are clip-wide.
|
||||
(is (contains? ls "clip/c7/symbol/face-1/node/mouth"))
|
||||
(is (contains? ls "clip/c7/symbol/face-1/channel/mouth/geom.pts"))
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
(defn- nested
|
||||
"Three symbols: :outer places :inner, and :loose is placed by nothing."
|
||||
[]
|
||||
(-> (clip/blank)
|
||||
(-> (clip/blank {:seconds 10})
|
||||
(assoc-in [:symbols :outer] {:id :outer :frames 200 :nodes {}})
|
||||
(assoc-in [:symbols :inner] {:id :inner :frames 10 :nodes {}})
|
||||
(assoc-in [:symbols :loose] {:id :loose :frames 30 :nodes {}})
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
(let [n {:id :insert :kind :instance :source {:symbol :inner}
|
||||
:time {:at 5 :rate 1} :span [0 100]
|
||||
:playback {:in 5 :speed speed :end end}}
|
||||
c (-> (clip/blank)
|
||||
(assoc-in [:symbols :inner] {:id :inner :frames 10 :fps 30 :nodes {}})
|
||||
c (-> (clip/blank {:seconds 10})
|
||||
(assoc-in [:symbols :inner] {:id :inner :frames 10 :nodes {}})
|
||||
(assoc-in [:symbols :main :nodes :insert] n))
|
||||
frame (:frame (nest/placement c nil :main [:insert] 29))
|
||||
keyed (node/set-keyed-channel n [:xform :rot] frame 1)]
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
(deftest a-shape-drawn-into-an-instance-lands-where-it-was-drawn
|
||||
(let [u #uuid "00000000-0000-4000-8000-0000000000dd"
|
||||
c (-> (clip/blank)
|
||||
c (-> (clip/blank {:seconds 10})
|
||||
(assoc-in [:symbols :box] {:id :box :frames 30 :nodes {}})
|
||||
(clip/place-symbol nil :main :box 10 u nil)
|
||||
;; moved, turned and doubled, so nothing lines up by accident
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
{[:xform :pos] (ch/framed pos)
|
||||
[:xform :rot] (ch/framed rot)
|
||||
[:xform :scale] (ch/framed [k k])}))
|
||||
c (-> (clip/blank)
|
||||
c (-> (clip/blank {:seconds 10})
|
||||
(assoc-in [:symbols :mid] {:id :mid :frames 40 :nodes {}})
|
||||
(assoc-in [:symbols :box] {:id :box :frames 30 :nodes {}})
|
||||
(clip/place-symbol nil :main :mid 10 u nil)
|
||||
|
|
@ -108,7 +108,7 @@
|
|||
(let [voice {:id :v :kind :audio :source {:footage "f"} :z "a1"
|
||||
:span [10 40] :time {:mode :map :at -10 :rate 1}
|
||||
:channels {[:audio :gain] (ch/keyed {0 0.0 5 1.0} :hold)}}
|
||||
c (-> (clip/blank)
|
||||
c (-> (clip/blank {:seconds 10})
|
||||
(assoc-in [:symbols :talk] {:id :talk :frames 30 :nodes {:v voice}})
|
||||
(clip/place-symbol nil :main :talk 50 #uuid "00000000-0000-4000-8000-0000000000bb" nil))
|
||||
[t] (nest/audio-tracks c :main)]
|
||||
|
|
@ -145,7 +145,7 @@
|
|||
{:id id :kind :poly :z "a1" :paint? true :span [4 60]
|
||||
:channels {[:geom :pts] (ch/keyed (into {} (map (fn [[f dx]] [f [x 10 (+ x dx) 10 x 40]])) keyed) :hold)
|
||||
[:style :color] (ch/framed :brow)}})]
|
||||
(-> (clip/blank)
|
||||
(-> (clip/blank {:seconds 10})
|
||||
(assoc-in [:symbols :main :nodes :tri] (tri :tri 100 {4 20 30 40}))
|
||||
(assoc-in [:symbols :box] {:id :box :frames 50 :nodes {:inner (tri :inner 5 {0 10})}})
|
||||
(clip/place-symbol nil :main :box 10 a-uuid nil)
|
||||
|
|
@ -245,7 +245,7 @@
|
|||
"but through a loop one frame outside is many inside")))
|
||||
|
||||
(deftest linked-audio-follows-picture-moves-but-keeps-independent-edges
|
||||
(let [c (-> (clip/blank)
|
||||
(let [c (-> (clip/blank {:seconds 10})
|
||||
(assoc-in [:symbols :drawing] {:id :drawing :frames 8 :nodes {}})
|
||||
(clip/place-symbol nil :main :drawing 2 :picture nil)
|
||||
(clip/place-sound :main {:sound "voice"} "voice" 8 1 2 :voice)
|
||||
|
|
@ -265,7 +265,7 @@
|
|||
|
||||
(deftest restacking-is-one-write-to-z
|
||||
(let [shape (fn [z] {:kind :poly :z z :channels {}})
|
||||
c (-> (clip/blank)
|
||||
c (-> (clip/blank {:seconds 10})
|
||||
(assoc-in [:symbols :main :nodes] {:a (shape "a1") :b (shape "a2") :c (shape "a3")}))
|
||||
order (fn [c] (map key (sort-by (comp :z val) (get-in c [:symbols :main :nodes]))))
|
||||
front (:clip (nest/restack c :main [:a] [:c] true))
|
||||
|
|
@ -316,10 +316,10 @@
|
|||
;; `node/time-of` reads an absent one as `:map`.
|
||||
:time {:at at :rate 1}
|
||||
:source {:symbol :draw} :playback {:in 0 :speed 0 :end :stop}})]
|
||||
(-> (clip/blank)
|
||||
(-> (clip/blank {:seconds 10})
|
||||
(assoc :fps 12)
|
||||
(assoc-in [:symbols :draw] {:id :draw :fps 30 :frames 1 :nodes {}})
|
||||
(assoc-in [:symbols :lane] {:id :lane :fps 30 :frames 60 :display :lane
|
||||
(assoc-in [:symbols :draw] {:id :draw :frames 1 :nodes {}})
|
||||
(assoc-in [:symbols :lane] {:id :lane :frames 60 :display :lane
|
||||
:nodes {:a (held :a 5) :b (held :b 19)}}))))
|
||||
|
||||
(deftest a-drag-in-the-open-symbol-is-frame-for-frame
|
||||
|
|
@ -352,7 +352,7 @@
|
|||
(let [inner (fn [rate]
|
||||
(-> (on-twos)
|
||||
(assoc-in [:symbols :outer]
|
||||
{:id :outer :fps 30 :frames 60
|
||||
{:id :outer :frames 60
|
||||
:nodes {:ins {:id :ins :kind :instance :z "a" :span [0 60]
|
||||
:time {:mode :map :at 0 :rate rate}
|
||||
:source {:symbol :lane}
|
||||
|
|
@ -403,7 +403,7 @@
|
|||
"A shape at a known place, turned and scaled, so that `:pinv` has real work to
|
||||
do rather than cancelling against an identity."
|
||||
[]
|
||||
(-> (clip/blank)
|
||||
(-> (clip/blank {:seconds 10})
|
||||
(paint/new-shape :main :shape 0 [0 0 10 0 5 10] :brow)
|
||||
(update-in [:symbols :main :nodes :shape :channels] merge
|
||||
{[:xform :pos] (ch/framed [40 25])
|
||||
|
|
|
|||
285
frontend/test/arthur/domain/rate_test.cljs
Normal file
285
frontend/test/arthur/domain/rate_test.cljs
Normal file
|
|
@ -0,0 +1,285 @@
|
|||
(ns arthur.domain.rate-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[arthur.domain.bring :as bring]
|
||||
[arthur.domain.channel :as ch]
|
||||
[arthur.domain.clip :as clip]
|
||||
[arthur.domain.leaf :as leaf]
|
||||
[arthur.domain.nest :as nest]
|
||||
[arthur.domain.node :as node]
|
||||
[arthur.domain.palette :as pal]
|
||||
[arthur.domain.pick :as pick]
|
||||
[arthur.domain.pose :as pose]
|
||||
[arthur.domain.retime :as retime]
|
||||
[arthur.domain.span :as span]
|
||||
[arthur.ui.timeline :as timeline]))
|
||||
|
||||
(defn- sampled
|
||||
"The frame of 30fps footage a 12fps output frame `f` shows: the latest at or
|
||||
before its instant."
|
||||
[f]
|
||||
(js/Math.floor (* f 2.5)))
|
||||
|
||||
(def footage
|
||||
{:fps 30 :width 100 :height 100
|
||||
:symbols {:main {:id :main :frames 60
|
||||
:nodes {:mark {:id :mark :kind :rect :z "a" :pose-group :mouth
|
||||
:channels {[:geom :size] {:animated? true :pose-sampled? true
|
||||
:dense {:store "sizes" :offset 0 :stride 1 :frames 60}}
|
||||
[:style :color] (ch/framed :brow)}}}}}})
|
||||
(def store {"sizes" {:data (js/Float64Array. (clj->js (range 1 61)))}})
|
||||
|
||||
(defn- placed
|
||||
"`doc` with symbol `sid` placed in a new 12fps `:stage` at `speed`."
|
||||
[doc sid speed]
|
||||
(-> doc
|
||||
(assoc :fps 12)
|
||||
(assoc-in [:symbols :stage] {:id :stage :frames 24 :nodes {}})
|
||||
(clip/place-symbol store :stage sid 0 :cel nil speed)))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; one rate
|
||||
|
||||
(deftest a-symbol-is-a-bag-of-frames
|
||||
(testing "a new document is 12fps, four seconds of it"
|
||||
(let [doc (clip/blank)]
|
||||
(is (= 12 (:fps doc)))
|
||||
(is (= 48 (clip/frames doc :main)))
|
||||
(is (nil? (get-in doc [:symbols :main :fps])))))
|
||||
(testing "and takes what it is told"
|
||||
(let [doc (clip/blank {:fps 15 :width 640 :height 360 :palette :arthur/pico-8})]
|
||||
(is (= [15 60 640 360 :arthur/pico-8]
|
||||
[(:fps doc) (clip/frames doc :main) (:width doc) (:height doc) (:default-palette doc)]))
|
||||
(is (every? pal/valid-palette? (vals (:palettes doc))))
|
||||
(is (= (count pal/presets) (count (:palettes doc))))))
|
||||
(testing "a drawing made in a nested lane is one project frame long"
|
||||
;; The bug that started this: a lane made at 30 in a project then set to
|
||||
;; 12 got drawings a thirtieth of a second long, which the output either
|
||||
;; skipped or showed for a sliver.
|
||||
(let [doc (-> (clip/blank)
|
||||
(clip/new-symbol :main :lane 0 :lane-cel))
|
||||
{made :clip} (span/append-drawing doc :lane :cel :drawing {:at 3})
|
||||
cel (get-in made [:symbols :lane :nodes :cel])]
|
||||
(is (nil? (get-in made [:symbols :drawing :fps])))
|
||||
(is (= [3 4] (node/placed-span cel)))
|
||||
(is (= {:symbol :drawing :frame 0}
|
||||
(clip/placed-frame made cel (first (node/placed-span cel))))))))
|
||||
|
||||
(deftest footage-is-played-in-real-time-by-its-placement
|
||||
(let [doc (placed footage :main 2.5)
|
||||
cel (get-in doc [:symbols :stage :nodes :cel])
|
||||
draw (clip/resolver doc :stage store pal/index-of nil)]
|
||||
(is (= [0 24] (:span cel)) "60 frames of 30fps footage are 24 of 12fps")
|
||||
(is (= (mapv #(inc (sampled %)) (range 6))
|
||||
(mapv #(:size (first (draw %))) (range 6))))
|
||||
(is (= 7 (:frame (nest/inside doc store :stage [:cel :mark] 3)))
|
||||
"inside the footage is the footage's own frame")
|
||||
(is (= doc (leaf/clip "test" (leaf/leaves "test" doc))))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; changing the rate
|
||||
|
||||
(def authored
|
||||
{:fps 24 :width 100 :height 100
|
||||
:symbols {:main {:id :main :frames 48
|
||||
:nodes {:box {:id :box :kind :rect :z "a" :span [0 48]
|
||||
:channels {[:geom :size] (ch/keyed {0 1, 1 2, 2 3, 12 4, 24 5} :hold)
|
||||
[:style :color] (ch/framed :brow)}}
|
||||
:cel {:id :cel :kind :instance :z "b" :source {:symbol :drawing}
|
||||
:span [0 4] :time {:mode :map :at 6 :rate 1}}
|
||||
:take {:id :take :kind :instance :z "c" :source {:symbol :footage}
|
||||
:span [0 48] :time {:mode :map :at 0 :rate 1}
|
||||
:playback {:in 0 :speed 1.25 :end :stop}}
|
||||
:voice {:id :voice :kind :audio :z "d" :source {:sound "s" :fps 30}
|
||||
:span [0 60] :time {:mode :map :at 12 :rate 1}}}}
|
||||
:drawing {:id :drawing :frames 4 :nodes {}}
|
||||
:footage (assoc (get-in footage [:symbols :main]) :id :footage)}})
|
||||
|
||||
(deftest keeping-time-moves-every-authored-frame
|
||||
(let [doc (retime/scale-spans authored 12)
|
||||
main (get-in doc [:symbols :main])]
|
||||
(is (= 12 (:fps doc)))
|
||||
(is (= 24 (:frames main)))
|
||||
(is (= {0 1, 1 3, 6 4, 12 5} (get-in main [:nodes :box :channels [:geom :size] :keys]))
|
||||
"keys that land on one frame keep the later one, which was showing")
|
||||
(is (= [0 24] (get-in main [:nodes :box :span])))
|
||||
(is (= [3 5] (node/placed-span (get-in main [:nodes :cel]))))
|
||||
(is (= 2 (clip/frames doc :drawing)) "a symbol's own frames move too")
|
||||
(testing "footage keeps its frames, and its placement plays them in time"
|
||||
(is (= 60 (clip/frames doc :footage)))
|
||||
(is (= 2.5 (get-in main [:nodes :take :playback :speed])))
|
||||
(is (= [0 24] (get-in main [:nodes :take :span]))))
|
||||
(testing "a sound moves to the same moment and stays in seconds"
|
||||
(is (= 6 (get-in main [:nodes :voice :time :at])))
|
||||
(is (= [0 60] (get-in main [:nodes :voice :span])))
|
||||
(is (= 1 (get-in main [:nodes :voice :time :rate]))))
|
||||
(testing "going back up returns every frame that survived"
|
||||
(let [back (retime/scale-spans doc 24)]
|
||||
(is (= (get-in authored [:symbols :main :nodes :cel])
|
||||
(get-in back [:symbols :main :nodes :cel])))
|
||||
(is (= (get-in authored [:symbols :main :nodes :take :playback])
|
||||
(get-in back [:symbols :main :nodes :take :playback])))
|
||||
(is (= 48 (clip/frames back :main)))))))
|
||||
|
||||
(deftest a-symbol-of-footage-scales-what-it-places
|
||||
;; A measured symbol keeps its frames, so an authored symbol it places has to
|
||||
;; be played faster or slower by it: the same rule read the other way round.
|
||||
(let [doc (-> footage
|
||||
(assoc-in [:symbols :main :nodes :drawn]
|
||||
{:id :drawn :kind :instance :z "b" :source {:symbol :d} :span [0 30]})
|
||||
(assoc-in [:symbols :d] {:id :d :frames 30 :nodes {}})
|
||||
(retime/scale-spans 12))]
|
||||
(is (= 60 (clip/frames doc :main)))
|
||||
(is (= 12 (clip/frames doc :d)))
|
||||
(is (= 0.4 (get-in doc [:symbols :main :nodes :drawn :playback :speed])))
|
||||
(is (= [0 30] (get-in doc [:symbols :main :nodes :drawn :span])))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; footage brought in
|
||||
|
||||
(deftest imported-footage-keeps-its-timing
|
||||
(let [tracked (-> footage
|
||||
(assoc :analyses {"a" {:id "a"}}
|
||||
:subjects {:face-1 {:id :face-1 :analysis "a"
|
||||
:source-subject :face-1}}
|
||||
:features {} :groups {}
|
||||
:symbols {:main {:id :main :frames 60
|
||||
:nodes {:face-1 {:id :face-1 :kind :instance
|
||||
:z "a" :source {:symbol :face-1}}}}
|
||||
:face-1 (get-in footage [:symbols :main])}))
|
||||
{doc :clip sid :sid} (bring/take (clip/blank) tracked "take" "video" [15 75])
|
||||
doc (clip/place-symbol doc store :main sid 6 :insert nil)
|
||||
n (get-in doc [:symbols :main :nodes :insert])
|
||||
draw (clip/resolver doc :main store pal/index-of nil)
|
||||
[sound] (nest/audio-tracks doc :main)]
|
||||
(is (= 24 (clip/frames doc sid)) "the take is moved onto the project's rate")
|
||||
(is (= 60 (clip/frames doc :take.face-1)) "and the measured face keeps its frames")
|
||||
(is (= 2.5 (get-in doc [:symbols sid :nodes :face-1 :playback :speed])))
|
||||
(is (= [0 24] (:span n)))
|
||||
(is (empty? (draw 5)))
|
||||
(is (= 8 (:size (first (draw 9)))))
|
||||
(is (= 7 (:frame (nest/inside doc store :main [:insert :face-1 :mark] 9))))
|
||||
(is (= [-4 -4 4 4] ((pick/bounds-of doc store :main n) 3)))
|
||||
(is (= [6 30] (node/placed-span sound)))
|
||||
(is (= 15 (node/local-frame sound 6)))
|
||||
(is (= 1 (* (get-in sound [:time :rate]) (/ (:fps doc) (:fps sound))))
|
||||
"the sound plays at its own speed")
|
||||
(is (= [6 30] (:span (first (timeline/rows doc :main #{[:insert]})))))
|
||||
(testing "a deliberate half speed still retimes audio"
|
||||
(let [slow (assoc-in doc [:symbols :main :nodes :insert :playback :speed] 0.5)
|
||||
[track] (nest/audio-tracks slow :main)]
|
||||
(is (= 0.5 (* (get-in track [:time :rate]) (/ (:fps slow) (:fps track)))))))))
|
||||
|
||||
(deftest generated-faces-own-their-footage-sound
|
||||
(let [face (fn [id] {:id id :frames 20 :nodes {}})
|
||||
frozen {:fps 30 :analyses {"a" {:id "a"}}
|
||||
:subjects {:face-1 {:id :face-1 :analysis "a" :source-subject :face-1}
|
||||
:face-2 {:id :face-2 :analysis "a" :source-subject :face-2}}
|
||||
:symbols {:main {:id :main :frames 20
|
||||
:nodes {:face-1 {:id :face-1 :kind :instance :z "a1"
|
||||
:source {:symbol :face-1}}
|
||||
:face-2 {:id :face-2 :kind :instance :z "a2"
|
||||
:source {:symbol :face-2}}}}
|
||||
:face-1 (face :face-1)
|
||||
:face-2 (face :face-2)}}
|
||||
{doc :clip take :sid} (bring/take (clip/blank) frozen "take" "video" [3 13])
|
||||
alone (clip/place-symbol doc nil :main :take.face-1 4 :placed-face nil)]
|
||||
(is (nil? (get-in doc [:symbols take :nodes :sound]))
|
||||
"the wrapper does not own a sound the face would lose")
|
||||
(is (= {:footage "video" :fps 30}
|
||||
(get-in doc [:symbols :take.face-1 :nodes :sound :source])))
|
||||
(is (= 1 (count (nest/audio-tracks doc take)))
|
||||
"the same take recording is not mixed once per detected face")
|
||||
(is (= 1 (count (nest/audio-tracks alone :main)))
|
||||
"placing a generated face by itself brings its associated sound")))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; the preserve-snap
|
||||
;;
|
||||
;; Footage at speed 2.5 reads 0, 2, 5, 7, 10, 12, 15 … and the frames between
|
||||
;; those it shows to nobody. `closure` is a take with something in one of those
|
||||
;; gaps worth seeing — docs/frame-selection.md's synthetic case, a mouth that
|
||||
;; shuts for ONE native frame, 13, which no 12-from-30 slot ever samples.
|
||||
|
||||
(defn- sized
|
||||
"A dense `[:geom :size]` over the whole take. The store holds 1..60, so a DRAWN
|
||||
SIZE NAMES THE NATIVE FRAME it was read from: size = frame + 1."
|
||||
[]
|
||||
{:animated? true :dense {:store "sizes" :offset 0 :stride 1 :frames 60}})
|
||||
|
||||
(def closure
|
||||
"A head that holds still and a mouth that shuts for one native frame. The
|
||||
head's size is NOT `:pose-sampled?`, which is what makes it the control."
|
||||
{:fps 30 :width 100 :height 100
|
||||
:symbols
|
||||
{:face
|
||||
{:id :face :frames 60
|
||||
:nodes
|
||||
{:head {:id :head :kind :rect :z "a"
|
||||
:channels {[:geom :size] (sized)
|
||||
[:style :color] (ch/framed :brow)}}
|
||||
:mouth-in {:id :mouth-in :kind :rect :parent :head :z "b"
|
||||
:pose-group :mouth
|
||||
:channels {[:geom :size] (assoc (sized) :pose-sampled? true)
|
||||
[:style :color] (ch/framed :mouth-dark)
|
||||
[:vis] (assoc (ch/keyed {0 true, 13 false, 14 true} :hold)
|
||||
:pose-sampled? true
|
||||
:generated {:by :roto/mouth-aperture})}}}}}})
|
||||
|
||||
(defn- drawn [r f] (into {} (map (juxt :node :size)) (r f)))
|
||||
|
||||
(deftest a-dropped-closure-reaches-exactly-one-output-frame
|
||||
(let [host (placed closure :face 2.5)
|
||||
hr (clip/resolver host :stage store pal/index-of {:snap #{:face}})
|
||||
hfs (mapv #(drawn hr %) (range 24))]
|
||||
(is (not-any? #{13} (map sampled (range 24)))
|
||||
"the speed alone never samples the closure — that is the gap")
|
||||
(testing "off is the speed alone"
|
||||
(let [off (clip/resolver host :stage store pal/index-of nil)]
|
||||
(is (= (mapv #(inc (sampled %)) (range 24))
|
||||
(mapv #(get (drawn off %) [:cel :mouth-in]) (range 24))))))
|
||||
(is (= [6] (filterv #(not (contains? (nth hfs %) [:cel :mouth-in])) (range 24)))
|
||||
"the shut mouth reaches exactly one output frame")
|
||||
(is (= [1 3 6 8 11 13 nil 18] (mapv #(get % [:cel :mouth-in]) (take 8 hfs)))
|
||||
"slot 6 snaps back from 15 to 13; no other slot moves")
|
||||
(is (= (mapv #(inc (sampled %)) (range 24)) (mapv #(get % [:cel :head]) hfs))
|
||||
"and the head reads what the speed says, on every frame including 6")
|
||||
(is (= (mapv #(inc (sampled %)) (range 24))
|
||||
(let [hostly (clip/resolver host :stage store pal/index-of {:snap #{:stage}})]
|
||||
(mapv #(get (drawn hostly %) [:cel :mouth-in]) (range 24))))
|
||||
"the switch is the FACE's: naming the host that places it marks nothing")
|
||||
(testing "a hand cut beats a snap, always"
|
||||
(let [held (pose/put-cut host :stage :cel :mouth 0 0)
|
||||
kr (clip/resolver held :stage store pal/index-of {:snap #{:face}})]
|
||||
(is (= (vec (repeat 24 1)) (mapv #(get (drawn kr %) [:cel :mouth-in]) (range 24))))))))
|
||||
|
||||
(deftest preserve-marks-are-the-frames-a-closure-cut-calls-shut
|
||||
(let [nodes (get-in closure [:symbols :face :nodes])
|
||||
vis (fn [ch] {:solo {:id :solo :kind :rect :pose-group :solo
|
||||
:channels {[:vis] ch}}})]
|
||||
(is (= {:mouth [13]} (pose/marks nodes 60 store)))
|
||||
(is (nil? (pose/marks (select-keys nodes [:head]) 60 store)))
|
||||
(is (nil? (pose/marks nodes nil store)))
|
||||
(testing "a hidden feature is not a closure"
|
||||
(is (nil? (pose/marks (vis (assoc (ch/keyed {0 true, 13 false, 14 true} :hold)
|
||||
:generated {:by :pixels/teeth}))
|
||||
60 store)))
|
||||
(is (nil? (pose/marks (vis (ch/keyed {0 true, 13 false, 14 true} :hold)) 60 store))))
|
||||
(testing "an absent measurement is not a closure"
|
||||
(is (nil? (pose/marks (vis (assoc (ch/keyed {} :hold) :generated {:by :roto/blink}))
|
||||
60 store))))))
|
||||
|
||||
(deftest a-slot-snaps-back-to-a-mark-and-never-forward
|
||||
(let [m (pose/marks (get-in closure [:symbols :face :nodes]) 60 store)]
|
||||
(is (= 13 (pose/snapped-frame m :mouth 12 15)))
|
||||
(is (= 12 (pose/snapped-frame m :mouth 10 12)))
|
||||
(is (= 17 (pose/snapped-frame m :mouth 15 17)))
|
||||
(is (= 13 (pose/snapped-frame m :mouth 12 13)))
|
||||
(is (= 15 (pose/snapped-frame m :mouth 15 15)))
|
||||
(is (= 15 (pose/snapped-frame m :other 12 15)))
|
||||
(is (= 15 (pose/snapped-frame nil :mouth 12 15)))
|
||||
(testing "never later than the slot's own instant, at any speed"
|
||||
(doseq [speed [0.4 0.5 1 1.25 2 2.5 5] f (range 90)]
|
||||
(let [frame #(js/Math.floor (* % speed))
|
||||
hi (frame f)
|
||||
lo (if (pos? f) (frame (dec f)) -1)]
|
||||
(is (<= (pose/snapped-frame m :mouth lo hi) (* f speed))))))))
|
||||
|
|
@ -7,7 +7,6 @@
|
|||
a clip or an output grid: `select` is handed a vector of numbers."
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[clojure.set :as set]
|
||||
[arthur.domain.cadence :as cadence]
|
||||
[arthur.domain.pose :as pose]
|
||||
[arthur.domain.select :as select]))
|
||||
|
||||
|
|
@ -42,7 +41,7 @@
|
|||
(range (count signal))))
|
||||
|
||||
(deftest a-one-frame-closure-survives-only-because-it-is-protected
|
||||
(let [grid (mapv #(cadence/frame % 12 30) (range 12))
|
||||
(let [grid (mapv #(js/Math.floor (* % 2.5)) (range 12))
|
||||
walk (select/propose 30 aperture {:tolerance tol})
|
||||
kept (select/propose 30 aperture {:tolerance tol :protect :extrema})]
|
||||
(testing "a uniform 12-from-30 cadence drops it"
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
(-> doc
|
||||
(update-in [:symbols :main :nodes] dissoc :plate)
|
||||
(assoc-in [:symbols :shot]
|
||||
{:id :shot :frames 12 :fps 24
|
||||
{:id :shot :frames 12
|
||||
:nodes {:girl {:id :girl :kind :instance :z "b" :span [0 12]
|
||||
:time {:mode :map :at 0 :rate 1}
|
||||
:source {:symbol :main}
|
||||
|
|
@ -818,7 +818,7 @@
|
|||
;; "wherever the symbol is placed it is heard". A sequence is one of the places
|
||||
;; it can be placed, and must not be the one place that goes silent.
|
||||
(let [doc (assoc-in (document) [:symbols :take]
|
||||
{:id :take :frames 10 :fps 24
|
||||
{:id :take :frames 10
|
||||
:nodes {:pic {:id :pic :kind :instance :z "a"
|
||||
:source {:symbol :wave} :span [0 10]
|
||||
:time {:mode :map :at 0 :rate 1}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@
|
|||
|
||||
(def ^:private still
|
||||
{:id :still :name "ref" :type :trace :media {:image "abc"}
|
||||
:frames 1 :fps 30 :width 400 :height 200 :nodes {}})
|
||||
:frames 1 :width 400 :height 200 :nodes {}})
|
||||
|
||||
(defn- with-still []
|
||||
(-> (clip/blank)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
:span [0 240] :playback {:in 0 :speed 2 :end :stop
|
||||
:tracks {:mouth []}}}
|
||||
document (-> (clip/blank)
|
||||
(assoc-in [:symbols :spin] {:frames 24 :fps 30 :nodes {}})
|
||||
(assoc-in [:symbols :spin] {:frames 24 :nodes {}})
|
||||
(assoc-in [:symbols :main :nodes :wheel] n)
|
||||
(assoc-in [:symbols :main :nodes :other] (assoc n :id :other)))
|
||||
id (store/install! {:clip document :store {}} "instance-playback-controls")
|
||||
|
|
@ -19,14 +19,14 @@
|
|||
[:symbols :main :nodes :wheel])]
|
||||
(reset! rf-db/app-db {:clip/current id :paint/revision 0})
|
||||
(rf/dispatch-sync [::project/instance-playback :main :wheel :mode :loop])
|
||||
(is (= 0 (:frame (clip/placed-frame document :main (current) 24))))
|
||||
(is (= 0 (:frame (clip/placed-frame document (current) 24))))
|
||||
(is (= :loop (get-in (current) [:playback :end])))
|
||||
(is (= 2 (get-in (current) [:playback :speed])))
|
||||
(rf/dispatch-sync [::project/instance-playback :main :wheel :in 5])
|
||||
(rf/dispatch-sync [::project/instance-playback :main :wheel :mode :frame])
|
||||
(is (= 5 (:frame (clip/placed-frame document :main (current) 100))))
|
||||
(is (= 5 (:frame (clip/placed-frame document (current) 100))))
|
||||
(rf/dispatch-sync [::project/instance-playback :main :wheel :mode :once])
|
||||
(is (nil? (clip/placed-frame document :main (current) 100)))
|
||||
(is (nil? (clip/placed-frame document (current) 100)))
|
||||
(is (= [0 240] (:span (current))))
|
||||
(is (= {:mouth []} (get-in (current) [:playback :tracks])))
|
||||
(let [before (current)]
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@
|
|||
[:node :main :insert [:insert]]]
|
||||
(mapv :select (:cels lane))))))
|
||||
|
||||
(deftest a-nested-lane-is-drawn-in-the-open-symbols-frame-rate
|
||||
(deftest a-nested-lane-at-a-speed-is-drawn-in-the-open-symbols-frames
|
||||
(let [child {:id :cel :kind :instance :z "a" :span [0 2]
|
||||
:time {:at 4 :rate 1}
|
||||
:source {:symbol :drawing}
|
||||
|
|
@ -189,20 +189,18 @@
|
|||
placed {:id :take :kind :instance :z "a" :span [0 12]
|
||||
:time {:at 0 :rate 1}
|
||||
:source {:symbol :lane}
|
||||
:playback {:in 0 :speed 1 :end :stop}}
|
||||
:playback {:in 0 :speed 2 :end :stop}}
|
||||
doc (-> (clip/blank)
|
||||
(assoc :fps 12)
|
||||
(assoc-in [:symbols :main :fps] 12)
|
||||
(assoc-in [:symbols :main :frames] 12)
|
||||
(assoc-in [:symbols :main :nodes] {:take placed})
|
||||
(assoc-in [:symbols :lane]
|
||||
{:id :lane :fps 24 :frames 24 :display :lane
|
||||
{:id :lane :frames 24 :display :lane
|
||||
:nodes {:cel child}})
|
||||
(assoc-in [:symbols :drawing]
|
||||
{:id :drawing :fps 24 :frames 1 :nodes {}}))
|
||||
{:id :drawing :frames 1 :nodes {}}))
|
||||
lane (first (filter :lane? (timeline/rows doc :main #{})))]
|
||||
(is (= [[2 3]] (mapv :span (:cels lane)))
|
||||
"native frames 4–6 occupy ruler frames 2–3 at twice the frame rate")))
|
||||
"a lane placed at twice the speed draws its frames 4–6 on ruler frames 2–3")))
|
||||
|
||||
(deftest an-ordinary-symbol-keeps-a-row-per-node
|
||||
(let [doc (update-in (fixture/document) [:symbols :main] dissoc :display)
|
||||
|
|
@ -225,13 +223,13 @@
|
|||
(deftest creation-walks-to-the-nearest-valid-parent-at-the-playhead
|
||||
(let [doc (-> (fixture/document)
|
||||
(assoc-in [:symbols :shot]
|
||||
{:id :shot :frames 12 :fps 24
|
||||
{:id :shot :frames 12
|
||||
:nodes {:girl {:id :girl :kind :instance :z "a"
|
||||
:span [0 12] :time {:mode :map :at 0 :rate 1}
|
||||
:source {:symbol :main}
|
||||
:playback {:in 0 :speed 1 :end :stop}}}})
|
||||
(assoc-in [:symbols :outer]
|
||||
{:id :outer :frames 30 :fps 24
|
||||
{:id :outer :frames 30
|
||||
:nodes {:take {:id :take :kind :instance :z "a"
|
||||
:span [0 12] :time {:mode :map :at 10 :rate 1}
|
||||
:source {:symbol :shot}
|
||||
|
|
@ -468,7 +466,7 @@
|
|||
;; was missing rather than landing in one that is there.
|
||||
(update-in [:symbols :main :nodes] dissoc :insert)
|
||||
(assoc-in [:symbols :shot]
|
||||
{:id :shot :fps 24 :frames 12
|
||||
{:id :shot :frames 12
|
||||
:nodes {:girl {:id :girl :kind :instance :z "b" :span [0 12]
|
||||
:time {:mode :map :at 0 :rate 1}
|
||||
:source {:symbol :main}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
(:require [cljs.test :refer [deftest is testing async]]
|
||||
[arthur.domain.channel :as ch]
|
||||
[arthur.domain.clip :as clip]
|
||||
[arthur.domain.retime :as retime]
|
||||
[arthur.domain.palette :as pal]
|
||||
[arthur.export :as export]))
|
||||
|
||||
|
|
@ -71,9 +72,8 @@
|
|||
(is (= 1 (zoom-of nil)) "an absent zoom is 1:1")
|
||||
(is (= 1 (zoom-of 1.9)))))
|
||||
|
||||
(deftest a-lower-output-rate-keeps-native-duration
|
||||
(let [doc (assoc-in (a-clip {:frames 48 :fps 24}) [:symbols :main :fps] 24)
|
||||
p (export/plan {:clip (clip/set-fps doc 12) :symbol :main})]
|
||||
(deftest a-lower-rate-keeping-time-keeps-the-duration
|
||||
(let [p (export/plan {:clip (retime/scale-spans (a-clip {:frames 48 :fps 24}) 12) :symbol :main})]
|
||||
(is (= 24 (:frames p)))
|
||||
(is (= 12 (:fps p)))
|
||||
(is (= 2 (:seconds p)))))
|
||||
|
|
@ -92,9 +92,9 @@
|
|||
(done)))
|
||||
(.catch (fn [e] (is false (str "threw: " e)) (done))))))
|
||||
|
||||
(deftest a-lower-output-rate-emits-the-selected-grid
|
||||
(deftest a-lower-rate-keeping-time-emits-the-new-grid
|
||||
(async done
|
||||
(-> (run!* (clip/set-fps (a-clip {:frames 12 :fps 24}) 8))
|
||||
(-> (run!* (retime/scale-spans (a-clip {:frames 12 :fps 24}) 8))
|
||||
(.then (fn [{:keys [frames spec]}]
|
||||
(is (= (range 4) (map :i frames)))
|
||||
(is (= 8 (:fps spec)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue