psah.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 A pseudo sample and hold. Uses pwl to approximate sample-and-hold of noise source. See sah.lsp for a true ample and hold
function
(psah frq [dur]) A simulation of sample-and-hold of noise source. frq - flonum. SH clock rate in Hz. dur - flonum. Duration of result in seconds. return - Sound. A signal at *control-srate* with frq*dur random events. The amplitude is in interval (-1,+1)
;; psah.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 ;; ;; A pseudo sample and hold. Uses pwl to approximate sample-and-hold of noise ;; source. See sah.lsp for a true ample and hold (provide 'psah) (current-file "psah") ;; Generate break point list for use by pwl-list ;; (defun psah:make-pwl-list (frq dur) (let (period events p a acc) (setf period (/ 1.0 frq)) (setf events (/ dur period)) (setf p 0) (setf a (rndr -1 1)) (setf acc (list a 0)) (dotimes (i (truncate events)) (setf p (+ p period)) (push p acc) (push a acc) (push p acc) (setf a (rndr -1 1)) (push a acc)) (push dur acc) (reverse acc))) ;; @doc function psah ;; (psah frq [dur]) ;; A simulation of sample-and-hold of noise source. ;; ;; frq - flonum. SH clock rate in Hz. ;; dur - flonum. Duration of result in seconds. ;; return - Sound. A signal at *control-srate* with frq*dur random events. ;; The amplitude is in interval (-1,+1) ;; (defun psah (frq &optional (dur 1)) (pwl-list (psah:make-pwl-list frq dur)))