Thursday, March 31, 2005

my first Audacity plugin

;nyquist plug-in
;version 1
;type process
;name "Bizarro..."
;action "Bizarrifying audio..."
;info "by Jeff Robertson\nReleased under terms of GPL"

;control thresh "Threshold" real "0 to 1" 0.1 0 1


;
; This plugin takes round stuff and makes it square.
; Every sample whose absolute value is below the given
; threshold will become 0. Every other sample will become
; either 1 or -1, depending on sign.
;
; Sounds sort of like a combination of fuzz pedal and
; a toggle switch that noisily switches the guitar's sound
; on and off at the start and end of each note.
;

; This is the largest possible IEEE 754 floating point number,
; we pretend that it is "infinity".
(setf maxfloat 3.4028234663852886E38)

(scale

; multiplying by "infinity" will force everything that that is
; not zero to be clipped to either 1 or -1.
maxfloat

; this eliminates any sample whose absolute value is under
; the threshhold. this is used to reduce noise in the final
; output, since otherwise even the tiniest positive or negative
; sample would go to 1 or -1.
(sum
(s-max s thresh)
(scale -1 (s-max (scale -1 s) thresh) ))
)

)

Comments: