Skip to content

Commit

Permalink
Build framework to synch metronome snapshots.
Browse files Browse the repository at this point in the history
Allow a metronome snapshot to be created to match the time of a
different metronome's snapshot, so that oscillated parameters running
off alternate metronomes can be properly synchronized with the frame,
issue #19
  • Loading branch information
brunchboy committed Dec 10, 2015
1 parent 4e52425 commit b74b035
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/afterglow/rhythm.clj
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
"Get the current bars per phrase, or change it to new-bpp")
(metro-bpm [metro] [metro new-bpm]
"Get the current bpm or change the bpm to new-bpm.")
(metro-snapshot [metro] [metro offset]
(metro-snapshot [metro] [metro instant]
"Take a snapshot of the current beat, bar, phrase, and phase state.
If an offset is supplied, calculates a snapshot based on adding that
many milliseconds to the current time.")
If an instant is supplied, calculates a snapshot for the corresponding
time rather than the current time.")
(metro-marker [metro]
"Returns the current time as phrase.bar.beat")
(metro-add-bpm-watch [metro key f]
Expand Down Expand Up @@ -343,15 +343,14 @@
(ref-set bpp new-bpp))))

(metro-snapshot [metro]
(metro-snapshot metro 0))
(metro-snapshot [metro offset]
(metro-snapshot metro (now)))
(metro-snapshot [metro instant]
(dosync
(ensure start)
(ensure bpm)
(ensure bpb)
(ensure bpp)
(let [instant (+ (now) offset)
beat (marker-number instant @start (metro-tick metro))
(let [beat (marker-number instant @start (metro-tick metro))
bar (marker-number instant @start (metro-tock metro))
phrase (marker-number instant @start (metro-ding metro))
beat-phase (marker-phase instant @start (metro-tick metro))
Expand Down

0 comments on commit b74b035

Please sign in to comment.