;; harmonize.sal -- simple harmonizing example ;; (c) 2008 by Roger B. Dannenberg ; build a test score begin with pitches = list(A3, B3, C4, D4, E4, F4, G4, A4), pitch-pattern = make-line(pitches) exec score-gen(save: quote(harm-in), score-len: length( pitches), pitch: next(pitch-pattern), vel: 100, ioi: 1) end ;; global harm-in is now initialized define function add-harmony(time, dur, expr) begin with pitch = expr-get-attr(expr, keyword(pitch)) if member(pitch, list(c4, e4)) then return list(time, dur, expr-set-attr(expr, keyword(pitch), list(pitch, c3, e3, g3))) else begin if pitch = d4 then return list(time, dur, expr-set-attr(expr, keyword(pitch), list(d4, b2, d3, f3, g3))) else return list(time, dur, expr) end end set harm-out = score-apply(harm-in, quote(add-harmony)) exec score-play(harm-out)