Skip to content

Commit

Permalink
graph! shouldn't rely on play! for offsetting time.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctford committed Nov 8, 2012
1 parent 0ac4128 commit 89c3964
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/goldberg/variations/canone_alla_quarta.clj
Expand Up @@ -123,10 +123,10 @@
(defn from [base] (partial + base))

(defn play! [notes]
(let [scheduled-notes (->> notes (where :time (from (now))))]
(doseq [{ms :time midi :pitch} scheduled-notes]
(at ms (ding! midi)))
scheduled-notes))
(let [start (now)]
(doseq [{ms :time midi :pitch} notes]
(at (+ ms start) (ding! midi)))
notes))

(defn even-melody [pitches]
(let [times (reductions + (repeat 400))
Expand Down Expand Up @@ -274,8 +274,7 @@
; (canon (simple 4))
; (where :pitch (comp C major))
; (where :time (bpm 90))
; play!
; (graph! "Row row row your boat"))
; play!)

; canone alla quarta, by johann sebastian bach
(defn canone-alla-quarta [notes]
Expand All @@ -284,12 +283,13 @@
notes))

(defn graph! [title notes]
(let [highlow (fn [k points]
(let [points (where :time (from (now)) notes)
highlow (fn [k]
(let [values (map k points)]
[(apply max values)
(apply min values)]))
[max-x min-x] (highlow :time notes)
[max-y min-y] (highlow :pitch notes)
[max-x min-x] (highlow :time)
[max-y min-y] (highlow :pitch)

adjust (fn [k high low points]
(->> points
Expand All @@ -311,7 +311,7 @@
:bass 150}
:leader)]
(doseq [{x :time y :pitch voice :part}
(normalise notes)]
(normalise points)]
(stroke-weight 5)
(fill 50)
(stroke (colours voice))
Expand All @@ -327,5 +327,5 @@
; (concat (arrange :bass bass))
; (where :pitch (comp G major))
; (where :time (bpm 90))
; play!
; (graph! "Time vs pitch"))
; (graph! "Time vs pitch")
; play!)

0 comments on commit 89c3964

Please sign in to comment.