Skip to content

Commit 26efa58

Browse files
committed
Use 'bpm' instead of magic literal number
1 parent c85d767 commit 26efa58

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/joy/music.cljs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@
8282
(defn notes [tone-pairs]
8383
"Returns a sequence of note maps at moderate tempo for the given
8484
sequence of tone-pairs."
85-
(->> tone-pairs
86-
(map pair-to-note)
87-
consecutive-notes
88-
(map #(update-in % [:delay] / 6))
89-
(map #(update-in % [:duration] / 6))))
85+
(let [bpm 360
86+
bps (/ bpm 60)]
87+
(->> tone-pairs
88+
(map pair-to-note)
89+
consecutive-notes
90+
(map #(update-in % [:delay] / bps))
91+
(map #(update-in % [:duration] / bps)))))
9092

9193
(def magical-theme
9294
"A sequence of [tone duration] pairs for a magical theme"

0 commit comments

Comments
 (0)