stairstep.lsp Version 1.00 31 October 2004 Author Steven Jones Contact jones57@swbell.net include the word "nyquist" in subject line The contents of this file are released under the terms of the GNU General Public License. See the file LICENSE.txt Produce stairstep shaped envelopes and wave-tables.
function
(stairstep dur [:n][:y0][:yn]) Generate a stairsteped envelope. dur - flonum. Duration in seconds :n - integer. Number of steps, default 4 :y0 - flonum. Initial amplitude, default 0.0 :yn - flonum. Final amplitude, default 1.0 return - sound
;; stairstep.lsp ;; Version 1.00 31 October 2004 ;; Author Steven Jones ;; ;; Contact jones57@swbell.net include the word "nyquist" in subject line ;; ;; The contents of this file are released under the terms of the GNU General ;; Public License. See the file LICENSE.txt ;; ;; Produce stairstep shaped envelopes and wave-tables. ;; (provide 'stairstep) (current-file "stairstep") ;; Generate breakpoint list for use with pwl-list ;; n - number of steps ;; xo - initial time ;; dx - step duration (run) ;; y0 - initial amplitude ;; dy - step amplitude (rise) ;; return list ;; (defun stairstep:bplist (n x0 dx y0 dy) (if (or (zerop n)(plusp n)) (append (list x0 y0 x0 (+ y0 dy))(stairstep:bplist (- n 1)(+ x0 dx) dx (+ y0 dy) dy)) nil)) ;; @doc function stairstep ;; (stairstep dur [:n][:y0][:yn]) ;; Generate a stairsteped envelope. ;; ;; dur - flonum. Duration in seconds ;; :n - integer. Number of steps, default 4 ;; :y0 - flonum. Initial amplitude, default 0.0 ;; :yn - flonum. Final amplitude, default 1.0 ;; return - sound ;; (defun stairstep (dur &key (n 4)(y0 0.0)(yn 1.0)) (let* ((dur (float dur)) (n (truncate n)) (dx (/ dur n)) (ddy (- yn y0)) (dy (/ (float ddy) n))) (pwl-list (stairstep:bplist n 0 dx y0 dy))))