From: <edgarrft@we...>  20080213 09:30:34

Hi list, Coming back to a question from Jean Zundel about the missing ssqrt function in Audacity, I have written some code to demonstrate how this could be solved by using the logarithmic Nyquist functions. A copy of the plugin can be found in the attachment.  start of plugin code  ;nyquist plugin ;version 1 ;type process ;name "nth Root Distortion..." ;action "Performing Distortion Effect..." ;info "Computes the nth root of a sound." ;control n "n:" real "" 2.0 1.0 10.0 (if (< n 1.0) (setf n 1.0)) (if (> n 10.0) (setf n 10.0)) ;;  smin fix  ;; CAUTION: smin is broken in Audacity. There are two known bugs ;; in the nyq:min2sounds function [nyquist/nyquist.lsp] ;; Here's a fixed version which overwrites the broken function: (defun nyq:min2sounds (s1 s2) (cond ((numberp s1) (cond ((numberp s2) (min s1 s2)) (t (sndminv s2 ; in Audacity 's2' is missing (sndconst s1 (localtoglobal 0.0) (sndsrate s2) (getduration 1.0)))))) ((numberp s2) (sndminv s1 ; in Audacity 's1' is missing (sndconst s2 (localtoglobal 0.0) (sndsrate s1) (getduration 1.0)))) (t (let ((s1sr (sndsrate s1)) (s2sr (sndsrate s2))) (cond ((> s1sr s2sr) (sndminv s1 (sndup s1sr s2))) ((< s1sr s2sr) (sndminv (sndup s2sr s1) s2)) (t (sndminv s1 s2))))))) ;;  end of smin fix  ;; logarithmic math with Nyquist and XLISP ;; nth power of x: (exp (* (log x) n)) ;; nth root of x: (exp (/ (log x) n)) ;; nth root of x, with two sounds: ;; (sexp (mult (slog xsound) (srecip nsound))) ;;  NOTE: s[nd]recip is not implemented in Audacity ;; nth root of x, with x = sound and n = number: ;; (sexp (mult (slog xsound) (/ 1.0 nnumber))) ;;  NOTE: this works in Audacity (defun nthroot (sound) (sexp (mult (slog sound) (/ 1.0 n)))) ; n is the slider value ;; because root functions [in math] only work with positive x values, ;; we must write extra code for negative samples (defun positivehalfwave (sound) (nthroot (smax 0.0 sound))) (defun sinv (sound) (scale 1.0 sound)) (defun negativehalfwave (sound) (sinv (nthroot (sinv (smin 0.0 sound))))) (defun distort (sound) (sum (positivehalfwave sound) (negativehalfwave sound))) (if (arrayp s) (vector (distort (aref s 0)) (distort (aref s 1))) (distort s))  end of plugin code  have fun,  edgar  The author of this email does not necessarily endorse the following advertisements, which are the sole responsibility of the advertiser: _____________________________________________________________________ Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! http://smartsurfer.web.de/?mc=100071&distributionid=000000000066 