Main Page       Index


wshape.lsp


 wshape.lsp
 Version 0.01   06 June 2005
 Author Steven Jones

 Contact:
 jones57@swbell.net  please include the word nyquist in subject line.

 Various wave shapers.


function

wshape:exp

 (wshape:exp sig n)
 Raise signal to the nth-power.
 
 sig    - Sound.
 n      - Integer. 0 < n, 
 return - Sound.


function

wshape:limit

 Limit amplitude of signal to interval +-1
 
 sig    - Sound
 gain   - Flonum. Higher values result in greater clipping, default 1
 return - Sound.


function

wshape:cheb

 (wshape:cheb sig degree)
 Chebyshev wave shaper.

 sig    - Sound.
 degree - Integer. 0 <= degree. Note higher degrees require increasingly 
          more computation
 return - Sound.


View the Sourcecode :



;; wshape.lsp
;; Version 0.01   06 June 2005
;; Author Steven Jones
;;
;; Contact:
;; jones57@swbell.net  please include the word nyquist in subject line.
;;
;; Various wave shapers.

(provide 'wshape)
(current-file "wshape")


;; @doc function wshape:exp
;; (wshape:exp sig n)
;; Raise signal to the nth-power.
;; 
;; sig    - Sound.
;; n      - Integer. 0 < n, 
;; return - Sound.
;;

(defun wshape:exp (sig n)
  (if (plusp n)
      (mult sig (wshape:exp sig (1- n)))
    1))


;; @doc function wshape:limit
;; Limit amplitude of signal to interval +-1
;; 
;; sig    - Sound
;; gain   - Flonum. Higher values result in greater clipping, default 1
;; return - Sound.
;;

(defun wshape:limit (sig &optional (gain 1))
  (let (sig2)
    (setf sig2 (scale gain sig))
    (mult sig2 (recip (sum 1 (multichan-expand #'snd-abs sig2))))))


;; @doc function wshape:cheb
;; (wshape:cheb sig degree)
;; Chebyshev wave shaper.
;;
;; sig    - Sound.
;; degree - Integer. 0 <= degree. Note higher degrees require increasingly 
;;          more computation
;; return - Sound.
;;

(defun wshape:cheb (sig degree)
  (cond ((or (zerop degree)(minusp degree))
	 (s-rest))
	((= 1 degree)
	 sig)
	(t (sum
	    (scale 2 (mult sig (wshape:cheb sig (1- degree))))
	    (scale -1 (wshape:cheb sig (- degree 2)))))))


Main Page       Index