rmband.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 rmband uses ring modulation to produce narrow-band noise.
function
(rmband pitch [:dur][:bw][:modsig]) Provide band of noise centered around pitch pitch - flonum. Center pitch as MIDI key number :dur - flonum. Duration in seconds, default 1.0 :bw - flonum. Band width, default 1000 :modsig - sound. Frequency modulation source, default silence return - sound.
function
(rmband:harmonic pitch dur [:n][:bwfn][:rffn][:rafn][:modsig]) Generates noisy harmonics by calling rmband n times. pitch - flonum. MIDI key number. dur - flonum. Duration in seconds. :n - integer. Number of noise bands, default 8 :bwfn - closure. Band width as function of harmonic index. Default (lambda (j) 50), j = {1 2 3 ... n} :rffn - closure. Relative frequency as function of harmonic index. Default (lambda (j hz)(* j hz)), j = {1 2 3 ... n} where hz is fundamental frequency in Hertz. :rafn - closure. Relative amplitude as function of harmonic index. Default (lambda (j)(/ 1.0 j), j = {1 2 3 ... n} :modsig - sound. Optional; frequency modulator, default silence. return - sound
;; rmband.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 ;; ;; rmband uses ring modulation to produce narrow-band noise. ;; (require 'pink) (provide 'rmband) (current-file "rmband") ;; @doc function rmband ;; (rmband pitch [:dur][:bw][:modsig]) ;; Provide band of noise centered around pitch ;; ;; pitch - flonum. Center pitch as MIDI key number ;; :dur - flonum. Duration in seconds, default 1.0 ;; :bw - flonum. Band width, default 1000 ;; :modsig - sound. Frequency modulation source, default silence ;; ;; return - sound. ;; (defun rmband (pitch &key dur bw modsig) (let ((dur (or dur 1.0)) (bw (or bw 1000))) (mult (fmosc pitch (or modsig (s-rest dur))) (pink dur bw)))) ;; @doc function rmband:harmonic ;; (rmband:harmonic pitch dur [:n][:bwfn][:rffn][:rafn][:modsig]) ;; Generates noisy harmonics by calling rmband n times. ;; ;; pitch - flonum. MIDI key number. ;; dur - flonum. Duration in seconds. ;; :n - integer. Number of noise bands, default 8 ;; :bwfn - closure. Band width as function of harmonic index. ;; Default (lambda (j) 50), j = {1 2 3 ... n} ;; :rffn - closure. Relative frequency as function of harmonic index. ;; Default (lambda (j hz)(* j hz)), j = {1 2 3 ... n} ;; where hz is fundamental frequency in Hertz. ;; :rafn - closure. Relative amplitude as function of harmonic index. ;; Default (lambda (j)(/ 1.0 j), j = {1 2 3 ... n} ;; :modsig - sound. Optional; frequency modulator, default silence. ;; ;; return - sound ;; (defun rmband:harmonic (pitch dur &key n bwfn rffn rafn modsig) (let ((hz (step-to-hz pitch)) (j 0)) (setq n (or n 8)) (setq bwfn (or bwfn #'(lambda (i) 50))) (setq rffn (or rffn #'(lambda (i fhz)(* i fhz)))) (setq rafn (or rafn #'(lambda (i)(/ 1.0 i)))) (simrep (i (truncate n)) (progn (setq j (+ i 1)) (scale (funcall rafn j) (rmband (hz-to-step (funcall rffn j hz)) :dur dur :bw (funcall bwfn j) :modsig modsig))))))