;; week3.sal -- score examples ;; let's make a simple score set s1 = {{0 1 {score-begin-end 0 4}} {0 0.25 {note pitch: C4}} {0.25 0.3 {note pitch: D4}} {0.5 0.2 {note pitch: AF4}} {0.75 0.2 {note pitch: F4}} {1.5 0.25 {note pitch: C4}} {1.75 0.2 {note pitch: D4}} {2.0 0.25 {note pitch: AF4}} {2.25 0.2 {note pitch: BF4}} {2.5 0.15 {note pitch: F4}} {3.0 0.75 {note pitch: B3}}} exec score-play(s1) ;; make a score with code: random durations and pitch ;; function make-a-score() begin with score = {}, next-time = 0, expr, event loop for i from 0 below 50 ;; make 50 notes set event = list(quote(note), :pitch, 48 + random(24)) set expr = list(next-time, 0.1, event) set score &= expr set next-time += 0.1 * (1 + random(3)) end return score end set s2 = make-a-score() exec score-print(s2) exec score-play(s2) ;; using score-gen function make-a-score-2() begin return score-gen(score-len: 50, pitch: 48 + random(24), ioi: 0.1 * (1 + random(3)), dur: 0.1) end exec score-play(make-a-score-2()) ;; use the sound from a score play prcrev(seq(timed-seq(s2), s-rest(4)), 2.0, 0.4) ;; manipulate a score - s1 slow then fast ;; set s3 = score-append(s1, score-stretch(s1, 0.75)) exec score-play(s3) ;; make s3 more legato ;; exec score-play(score-sustain(s3, 2)) ;; make notes less legato except last note is really long: ;; first, make all notes a bit longer (duration * 1.5): set s4 = score-sustain(s3, 1.5) ;; second, sustain last note by duration * 4 set s5 = score-sustain(s4, 4, from-index: length(s4) - 1) ;; play it exec score-play(s5) ;; note: you could also save the score (e.g. call ;; score-print(s4) and copy/paste the score into an ;; editor. There, you could make manual adjustments ;; rather than writing code to "edit" the data.