Re: [Audacity-nyquist] extreme newbie question about abs function
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
|
From: David S. <dav...@vc...> - 2005-03-29 15:59:42
|
Thanks Steven, s-max does work, but only on mono signals, even if I include a (if (arrayp s)...) check, as below (which I have commented out). Below that is the Nyquist error msg, which I don't understand. David ;nyquist plug-in ;version 1 ;type process ;name "Rectifier..." ;action "Rectifying audio..." ;info "Code by Steven Jones\nReleased under terms of GPL" ;control rectify "Rectify" int "0=half 1=full" 1 0 1 ; Rectifier compiled by David R. Sky, ; code by Steven Jones ; March 29, 2005 ; Released under terms of the GNU Public License ; http://www.opensource.org/licenses/gpl-license.php ; Return only the positive half cycles of signal (defun pos (signal) (s-max signal 0)) ; Return only the negative half-cycles of signal ; AND invert them. (defun neg (signal) (pos (scale -1 signal))) (defun my-abs (signal rectify) (if (= rectify 1) (sum (pos s) (neg s)) (pos s))) ; checking for stereo signal ; (if (arrayp s) ; (vector (my-abs (aref s 0) rectify) ; (my-abs (aref s 1) rectify)) (my-abs s rectify) ; ) error: bad argument type - 0 Function: #<Subr-LENGTH: #12cbb40> Arguments: 0 Function: #<FSubr-COND: #12cb570> Arguments: ((/= N (LENGTH S2)) (ERROR "unequal number of channels in max")) Function: #<FSubr-LET*: #12cb430> Arguments: ((N (LENGTH S1)) (P (MAKE-ARRAY N))) (COND ((/= N (LENGTH S2)) (ERROR "unequal number of channels in max"))) (DOTIMES (I N) (SETF (AREF P I) (S-MAX (AREF S1 I) (AREF S2 I)))) P Function: #<Closure-NYQ:MAX-OF-ARRAYS: #12fe068> Arguments: #(#<Sound: #7cb2390> #<Sound: #7cb2618>) 0 Function: #<FSubr-COND: #12cb570> Arguments: ((ARRAYP S1) (NYQ:MAX-OF-ARRAYS S1 S2)) (T (NYQ:MAX-2-SOUNDS S1 S2)) Function: #<Closure-S-MAX: #12fe548> Arguments: #(#<Sound: #7cb2390> #<Sound: #7cb2618>) 0 Function: #<Closure-POS: #130be80> Arguments: #(#<Sound: #7cb2390> #<Sound: #7cb2618>) Function: #<FSubr-IF: #12cb3f0> Arguments: (= RECTIFY 1) (SUM (POS S) (NEG S)) (POS S) Function: #<Closure-MY-ABS: #130bb00> Arguments: #(#<Sound: #7cb2390> #<Sound: #7cb2618>) 1 1> [ gc: total 18640, 3629 free; samples 1KB, 0KB free ] |