Re: [Audacity-nyquist] extreme newbie question about abs function
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
From: Jeff R. <jef...@ya...> - 2005-03-29 16:16:33
|
All: this plugin does exactly what I was trying to do. Thank you. The workaround was a lot more involved than I would have guessed! --- David Sky <dav...@vc...> wrote: > 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 ] > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Audacity-nyquist mailing list > Aud...@li... > https://lists.sourceforge.net/lists/listinfo/audacity-nyquist > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |