[Audacity-nyquist] Would this code for dc bias adjust work?
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
|
From: David R. S. <dav...@sh...> - 2005-11-28 18:33:35
|
Hi Edgar,
The first macro below, peak, is from nyquist.lsp from a pre-1.2.3
Audacity. Would the remaining code be valid to adjust a signal's
(expression's) dc bias, without using an hp filter?
David
;; (PEAK sound-expression number-of-samples) - find peak amplitude
;
; NOTE: this used to be called s-max
;
(defmacro peak (expression maxlen)
`(snd-max ',expression ,maxlen))
(defmacro inv-peak (expression maxlen)
`(snd-min ',expression ,maxlen))
(defun bias-adjust (expression)
(setf high (peak expression ny:all)) ; maximum signal height
(setf low (inv-peak expression ny:all)) ; minimum signal height
(setf amplitude (- high low)) ; peak-to-peak
(setf mid-amp (/ amplitude 2.0)) ; midpoint of signal
(setf adjust (- mid-amp)) ; dc bias to add to or subtract from
; expression, so expression goes from -value to +value
(sum expression adjust))
(bias-adjust s)
|