;; table.sal -- example using table lookup ;; ;; (c) 2008 by Roger B. Dannenberg ;; table to map letters to pitches ;; in this mapping, consonants are chromatic ;; from 40 to 60 ;; vowels are pitches 35, 67, 78, 89, and 100 define variable *letter-to-pitch* = {{a 35} {b 40} {c 41} {d 42} {e 67} {f 43} {g 44} {h 45} {i 78} {j 46} {k 47} {l 48} {m 49} {n 50} {o 89} {p 51} {q 52} {r 53} {s 54} {t 55} {u 100} {v 56} {w 57} {x 58} {y 59} {z 60}} define function table-lookup(key, table) return second(assoc(key, table)) define function char-to-symbol(text, index) return intern(string-upcase( subseq(text, index, index + 1))) begin with text = "This text is the source data for music generation", pitch exec score-gen(save: quote(table-example), score-len: length(text), pitch: table-lookup(char-to-symbol( text, sg:count), *letter-to-pitch*), dur: 0.3, ioi: 0.2) end exec score-play(table-example)