;; pat-fm-scale.sal -- play a scale by changing frequency of a continuous tone ;; (c) 2008 by Roger B. Dannenberg ;; pat-ctrl is copied from pat-ctrl.sal ;; It creates a control function from a pattern define function pat-ctrl(durpat, valpat) return seq(const(next(valpat), next(durpat)), pat-ctrl(durpat, valpat)) ;; pat-fm is copied from pat-fm.sal ;; It creates a tone with duration and frequency controlled by patterns define function pat-fm(durpat, valpat, pitch, dur) begin with hz = step-to-hz( pitch + pat-ctrl(durpat, valpat)) return pwl(0.01, 1, dur - 0.1, 1, dur) * hzosc(hz + 4.0 * hz * hzosc(hz)) end ;; play a scale by providing a pattern to modulate the frequency play pat-fm(0.2, make-cycle({0 2 4 5 7 9 11 12}), c4, 4.8)