;; table-with-sets-score.sal -- example using table and sets ;; ;; (c) 2008 by Roger B. Dannenberg define function table-lookup(key, table) return second(assoc(key, table)) define function table-lookup(key, table) return second(assoc(key, table)) ; Generator table-with-sets defines a table of the ; first four pitch-class sets of cardinality 6. A ; random number selects one of four keys in the range ; 0-3 that corresponds to sets 6-1, 6-2, 6-Z3 and ; 6-Z4. Use the table-look-up to return the pitch ; classes associated with the key. Assign a pitch ; to the note slot by picking a random element of the ; selected list, accessed using nth. begin with table-cardinal6 = {{0 {0 1 2 3 4 5} s6-1} {1 {0 1 2 3 4 6} s6-2} {2 {0 1 2 3 5 6} s6-Z3} {3 {0 1 2 4 5 6} s6-Z4}}, key1 = random(4), key2 = random(4), key3 = random(4), key4 = random(4), set1 = table-lookup(key1, table-cardinal6), set2 = table-lookup(key2, table-cardinal6), set3 = table-lookup(key3, table-cardinal6), set4 = table-lookup(key4, table-cardinal6), ioi-pattern = make-heap({.2 .4 .5}), amp-pattern = make-heap({20 30 40 100}), index exec score-gen(save: quote(table-with-sets-score), score-len: 60, pre: setf(index, random(6)), pitch: #?(sg:count < 15, nth(index, set1) + 40, #?(sg:count < 30, nth(index, set2) + 50, #?(sg:count < 45, nth(index, set3) + 60, nth(index, set4) + 70))), ioi: next(ioi-pattern), dur: 0.1, amp: next(amp-pattern)) end exec score-play(table-with-sets-score)