Fix the bugs, fully implement performance
This commit is contained in:
parent
489741d3ed
commit
b1c47cbd73
@ -101,7 +101,7 @@
|
|||||||
:volume 50 ;; volume of performance
|
:volume 50 ;; volume of performance
|
||||||
:key [:C :major]}) ;; current key signature
|
:key [:C :major]}) ;; current key signature
|
||||||
|
|
||||||
(defn merge-perfs ;; TODO what if p1 and p2 are single notes?
|
(defn merge-perfs
|
||||||
"Merges two performances"
|
"Merges two performances"
|
||||||
[p1 p2]
|
[p1 p2]
|
||||||
(if (nil? (seq p1))
|
(if (nil? (seq p1))
|
||||||
@ -119,26 +119,33 @@
|
|||||||
(defn perf
|
(defn perf
|
||||||
"Implementation of perform, returns a tuple of (performance, duration)"
|
"Implementation of perform, returns a tuple of (performance, duration)"
|
||||||
[player-map context music]
|
[player-map context music]
|
||||||
(let [{:keys [player duration-t]} context]
|
(let [{:keys [player duration-t time]} context]
|
||||||
(match music
|
(match music
|
||||||
{:duration duration
|
{:duration duration
|
||||||
:pitch pitch} [((:play-note player)
|
:pitch pitch} [[((:play-note player)
|
||||||
context
|
context
|
||||||
music)
|
music)]
|
||||||
(* duration duration-t)]
|
(* duration duration-t)]
|
||||||
{:duration duration} [[] (* duration duration-t)]
|
{:duration duration} [[] (* duration duration-t)]
|
||||||
[:+ & ms] (reduce (fn [[events-acc dur-acc] m]
|
[:+ & ms] (let [[{events :events} dur]
|
||||||
(let [[events dur] (perf player-map
|
(reduce (fn [[{events-acc :events time-acc :time} dur-acc] m]
|
||||||
context
|
(let [[events dur]
|
||||||
m)]
|
(perf player-map
|
||||||
[(concat events-acc events)
|
(assoc context
|
||||||
(+ dur-acc dur)]))
|
:time
|
||||||
[[] 0]
|
(+ (:time context) time-acc))
|
||||||
ms)
|
m)]
|
||||||
|
[{:events (concat events-acc events)
|
||||||
|
:time (+ time-acc dur)}
|
||||||
|
(+ dur-acc dur)]))
|
||||||
|
[{:events [] :time time} 0]
|
||||||
|
ms)]
|
||||||
|
[events dur])
|
||||||
[:= & ms] (reduce (fn [[merged-events max-dur] m]
|
[:= & ms] (reduce (fn [[merged-events max-dur] m]
|
||||||
(let [[events dur] (perf player-map
|
(let [[events dur] (perf player-map
|
||||||
context
|
context
|
||||||
m)]
|
m)]
|
||||||
|
(prn events)
|
||||||
[(merge-perfs merged-events events)
|
[(merge-perfs merged-events events)
|
||||||
(max max-dur dur)]))
|
(max max-dur dur)]))
|
||||||
[[] 0]
|
[[] 0]
|
||||||
|
Loading…
Reference in New Issue
Block a user