efx.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 few DSP algorithms
function
(efx:transpose-mono snd [:transpose][:r][:base]) Stretch sound by given transposition and ratio. For multi channel sounds use efx:transpose instead. snd - sound. The MONO sound source. :transpose - integer. The number of half-steps to transpose. The actual number of steps is the sum of the transpose argument and the value returned by the (get-transpose) function from the Nyquist environment. Default (+ 0 (get-transpose)) :base - flonum. The half-step scale ratio. Default +12ROOT2+ :r - flonum. A "straight" scale ratio, default 1.00 return - sound. The combined stretch factor is: sf = 1/(r * (base ^^-(t + nt))) Where t = transpose argument and nt is result of (get-transpose)
function
(efx:transpose snd [:transpose][:r][:base]) Stretch sound by given transposition values. May be used to process mono or stereo sounds. See efx:transpose-mono snd - sound. The source signal return - sound.
function
(efx:echo snd dly [:xpose][:base][:dry][:wet]) Mix sound with delayed copy of itself. Alternatively the sound may be transposed (by stretching) snd - sound. The source signal dly - flonum. Delay time :xpose - flonum. Transpose amount in steps, default 0 :base - flonum. Transpose step ratio, default +12ROOT2+ :dry - flonum. Relative amplitude of source signal, default 0.5 :wet - flonum. Relative amplitude of delayed signal, default 0.5 return - sound.
function
(efx:necho snd dly [:n][:xpose][:base]) Mix sound with n delayed copies of itself. snd - sound. The source signal dly - flonum. Delay time :n - integer. Number of copies, default 4 :xpose - flonum. Transpose amount in steps, default 0 :base - flonum. Transpose step ratio, default +12ROOT2+ return - sound.
function
(efx:fbecho snd dly [:n][:xpose][:base][:fb]) Mix sound with n delayed copies of itself with decaying (or increasing) amplitude snd - sound. The source signal dly - flonum. Delay time :n - integer. Number of copies, default 4 :xpose - flonum. Transpose amount in steps, default 0 :base - flonum. Transpose step ratio, default +12ROOT2+ :fb - flonum. Relative amplitude of successive echos, default 0.5 return - sound.
;; efx.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 few DSP algorithms ;; (provide 'efx) (current-file "efx") ;; @doc function efx:transpose-mono ;; (efx:transpose-mono snd [:transpose][:r][:base]) ;; Stretch sound by given transposition and ratio. ;; For multi channel sounds use efx:transpose instead. ;; ;; snd - sound. The MONO sound source. ;; ;; :transpose - integer. The number of half-steps to transpose. The actual ;; number of steps is the sum of the transpose argument and the ;; value returned by the (get-transpose) function from the ;; Nyquist environment. Default (+ 0 (get-transpose)) ;; ;; :base - flonum. The half-step scale ratio. Default +12ROOT2+ ;; ;; :r - flonum. A "straight" scale ratio, default 1.00 ;; ;; return - sound. ;; The combined stretch factor is: ;; ;; sf = 1/(r * (base ^^-(t + nt))) ;; ;; Where t = transpose argument and nt is result of (get-transpose) ;; (defun efx:transpose-mono (snd &key transpose r base) (let* ((xpose (- (+ (get-transpose)(or transpose 0)))) (r (if (null r) 1.00 (/ (float (if (zerop r) 1.00 r))))) (base (float (or base +12ROOT2+))) (rr (* r (expt base xpose)))) (force-srate *default-sound-srate* (stretch rr (sound snd))))) ;; @doc function efx:transpose ;; (efx:transpose snd [:transpose][:r][:base]) ;; Stretch sound by given transposition values. ;; May be used to process mono or stereo sounds. ;; See efx:transpose-mono ;; ;; snd - sound. The source signal ;; ;; return - sound. ;; (defun efx:transpose (snd &key transpose r base) (multichan-expand #'efx:transpose-mono snd :transpose transpose :r r :base base)) ;; @doc function efx:echo ;; (efx:echo snd dly [:xpose][:base][:dry][:wet]) ;; Mix sound with delayed copy of itself. Alternatively the sound may be ;; transposed (by stretching) ;; ;; snd - sound. The source signal ;; dly - flonum. Delay time ;; :xpose - flonum. Transpose amount in steps, default 0 ;; :base - flonum. Transpose step ratio, default +12ROOT2+ ;; :dry - flonum. Relative amplitude of source signal, default 0.5 ;; :wet - flonum. Relative amplitude of delayed signal, default 0.5 ;; return - sound. ;; (defun efx:echo (snd dly &key (xpose 0)(base +12ROOT2+)(dry 0.5)(wet 0.5)) (sim (scale dry (efx:transpose snd :transpose xpose :base base)) (at dly (scale wet (efx:transpose snd :transpose xpose :base base))))) ;; @doc function efx:necho ;; (efx:necho snd dly [:n][:xpose][:base]) ;; Mix sound with n delayed copies of itself. ;; ;; snd - sound. The source signal ;; dly - flonum. Delay time ;; :n - integer. Number of copies, default 4 ;; :xpose - flonum. Transpose amount in steps, default 0 ;; :base - flonum. Transpose step ratio, default +12ROOT2+ ;; return - sound. ;; (defun efx:necho (snd dly &key (n 4)(xpose 0)(base +12ROOT2+)) (simrep (index n) (at (* index dly)(cue (efx:transpose snd :transpose xpose :base base))))) ;; @doc function efx:fbecho ;; (efx:fbecho snd dly [:n][:xpose][:base][:fb]) ;; Mix sound with n delayed copies of itself with decaying (or increasing) ;; amplitude ;; ;; snd - sound. The source signal ;; dly - flonum. Delay time ;; :n - integer. Number of copies, default 4 ;; :xpose - flonum. Transpose amount in steps, default 0 ;; :base - flonum. Transpose step ratio, default +12ROOT2+ ;; :fb - flonum. Relative amplitude of successive echos, default 0.5 ;; return - sound. ;; (defun efx:fbecho (snd dly &key (n 4)(xpose 0)(base +12ROOT2+)(fb 0.5)) (simrep (index n) (at (* index dly) (cue (scale (expt fb (float index)) (efx:transpose snd :transpose xpose :base base))))))