Last active
December 14, 2015 08:59
-
-
Save seabre/5061753 to your computer and use it in GitHub Desktop.
Used in live-coding session for: https://soundcloud.com/seabre/constant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'overtone.live) | |
(use 'overtone.inst.sampled-piano) | |
; arpeggiate-chord: | |
; | |
; Arpeggiate a given chord. | |
; | |
; instrument - Some sort of instrument function. | |
; a-chord - List of midi nums. | |
; spacing - Spacing between notes in milliseconds. | |
; t - Time at which to start. Usually used with (now) | |
; | |
(defn arpeggiate-chord [instrument a-chord spacing t] | |
(let [steps (map vector a-chord | |
(map (fn [n] (+ (* n spacing) t)) | |
(range 0 (+ (count a-chord) 1)))) | |
lasttime (+ (second (last steps)) spacing) | |
] | |
(doseq [s steps] | |
(at (second s) (instrument (first s))) | |
) | |
(apply-at lasttime arpeggiate-chord instrument a-chord spacing lasttime []) | |
) | |
) | |
; I used these specifically. Not in any particular order, though. | |
(arpeggiate-chord sampled-piano (chord :G4 :major) 500 (now)) | |
(arpeggiate-chord sampled-piano (chord :C5 :major) 5000 (now)) | |
(arpeggiate-chord sampled-piano (chord :G5 :major) 5000 (now)) | |
(arpeggiate-chord sampled-piano (chord :C6 :major) 10000 (now)) | |
(arpeggiate-chord sampled-piano (chord :C4 :major) 10000 (now)) | |
(arpeggiate-chord sampled-piano (chord :C5 :major) 1000 (now)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment