   []
   (coll->chan (cycle [[0.5 false] [0.5 true]])))
 
+(defn frames-at-speed [frames speed]
+  (map (fn [[delay diff]] [(/ delay speed) diff]) frames))
+
 (defn start-playback
   "The heart of the player. Coordinates dispatching of state update events like
   terminal line updating, time reporting and cursor blinking.


(defn frames->chan
  "Returns a channel that emits frames from the given collection."
  [frames speed]
  (let [ch (chan)
        start (js/Date.)]
    (go

             virtual-time 0
             pending-diff {}]
        (when-let [[delay diff] (first frames)]
          (let [wall-time (elapsed-time-since start)
                new-virtual-time (+ virtual-time delay)
                ahead (- new-virtual-time wall-time)]
            (if (pos? ahead)
              (do
                (when-not (empty? pending-diff)
                  (>! ch pending-diff))
                (<! (timeout (* 1000 ahead)))
                (>! ch diff)
                (recur (rest frames) new-virtual-time {}))
              (recur (rest frames) new-virtual-time (merge-with merge pending-diff diff))))))
