;; member.sal -- example using member in score-gen ;; (c) 2008 by Roger B. Dannenberg ;; melody is drawn from pitches in 6-Z3, 6-Z36, ;; 5-Z38 and 7-Z38 (first two pitches, 0 and 1, ;; in these sets are omitted begin with notes-1 = make-heap({2 3 4 7}), ;; 6-Z3 notes-2 = make-heap({2 3 5 6}), ;; 6-Z36 notes-3 = make-heap({2 5 8}), ;; 5-Z38 notes-4 = make-heap({2 4 5 7 8}), ;; 7-Z38 amp-pattern = make-cycle( {10 20 30 40 50 60 70 80 90 10 20 30 40 50 60 70 80 90 10 20 30 40 50 10 20 30 40 50 10 20 30 40 50 10 20 30 40 50 10 20 30 40 50 60 70}), rhythm-pattern = make-heap(list(q, qd, h, hd)), pitch ;; The first score is member-melody: select a ;; pattern and shift by 2 to 5 octaves depending on ;; the starting time exec score-gen(save: quote(member-melody), score-dur: 20, pre: setf(pitch, #?(sg:start < 5, 24 + next(notes-1), #?(sg:start < 10, 36 + next(notes-2), #?(sg:start < 15, 48 + next(notes-3), 60 + next(notes-4))))), pitch: pitch, ;; emphasize certain pitch classes with high ;; amplitude; pitch class is remainder of ;; pitch divided by 12. "%" is the remainder ;; operator. ;; Use member to test if pitch class is one ;; of 2, 4, 5, or 7: vel: #?(member(pitch % 12, {2 4 5 7}), 100 + random(20), ;; pick 100 to 119 10 + random(30)), ;; pick 10 to 39 ioi: 0.1) ;; a second score is computed called member-accomp. ;; When the pitch: parameter is a list, a chord is ;; generated, so this creates 5- to 7-note chords. exec score-gen(save: quote(member-accomp), score-dur: 20, pre: setf(pitch, #?(sg:start < 5, {50 51 52 53 54 57}, #?(sg:start < 10, {60 61 62 63 65 66}, #?(sg:start < 15, {70 71 72 75 78}, {80 81 82 84 85 87 88})))), pitch: pitch, vel: next(amp-pattern), ioi: next(rhythm-pattern), dur: 0.15) ;; the third score is a final chord exec score-gen(save: quote(member-final), score-len: 1, pitch: {24 25 38 51 64 77 90 103 104}, ;; chord is based on union of all four sets: ;; (0 1 2 3 4 5 6 7 8) or set 9-1. Each ;; pitch class is transposed up a successive ;; octave. (the lowest and highest pitches ;; are adjusted up to fall into the range of ;; the piano) vel: 120, dur: 2) ;; combine all the scores set member-example = score-merge(member-melody, member-accomp, score-shift(member-final, 20)) end exec score-play(member-example)