Created
August 20, 2016 15:12
-
-
Save daveyarwood/4d5709725a123d6d9cf21cd020f24ad7 to your computer and use it in GitHub Desktop.
Steve Reich's "Clapping Music" in Alda
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
# Clapping Music (1972) | |
# for two performers | |
# | |
# Steve Reich | |
# | |
# sheet music: | |
# https://sites.ualberta.ca/~michaelf/SEM-O/SEM-O_2014/Steve's%20piece/clapping_reich.jpg | |
(def clap (alda-code "o2 d+8")) | |
(def pattern | |
(let [rest (pause (duration (note-length 8)))] | |
[clap clap clap rest clap clap rest clap rest clap clap rest])) | |
(defn shift [n pattern] | |
(take (count pattern) (drop n (cycle pattern)))) | |
(tempo! 172) | |
midi-percussion: | |
V1: | |
(times 13 | |
(times 12 pattern)) | |
V2: | |
(for [n (range 13)] | |
(times 12 (shift n pattern))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry, just now saw this!
That's a really interesting thought. Unfortunately, though, variables in an Alda score and symbols defined in the Clojure environment are not stored in the same place, so they can't be used interchangeably like this.
I just played around with this for a bit in the Alda REPL, and I realized that the value of
(alda-code "pattern")
is always({:event-type :get-variable, :variable :pattern})
regardless of whether or not you've defined a variable calledpattern
:As you can see, when we dip down into Clojure, we're working at a "meta level" where we can construct/generate Alda events, but these events have no context of the score in which they're being evaluated, until the score is actually evaluated by Alda.
One consequence of this is that
(alda-code "pattern")
can only represent({:event-type :get-variable, :variable :pattern})
, which the Alda score evaluation process will replace with the current value of the variable at that point in the score. The variable replacement happens after the Clojure code is evaluated, so we'll always end up with the unmodified variable value.Is this awkward? Probably yes :) I haven't fully explored this aspect of creating scores with Alda yet, but so far, it seems like once you're in the mindset of writing inline Clojure code in an Alda score, the easiest thing is to work with def'd Clojure vars instead of Alda variables.