make-balance &optional (hp 10) make-rms &optional (hp 10) make-gain &optional (hp 10) balance b signal compare rms r signal gain g signal rmshp is the half-power point (in cps) of a special internal low-pass filter. Balance and gain return a modified signal, rms returns the rms of the signal.
Extreme cases will cause spikes in the audio - if this occurs try using a gain multiplier to approximate the target rms before applying balance or gain to it. It is a good idea to use a multiplier in any case because balance and gain work better the less they have to gain.
The average gain that was applied can be retrieved:balance-avg b gain-avg g
Use Run* and the average functions to suggest a user-supplied gain for the next time.
For Example:(definstrument formnt-noise (start dur amp &key (freq 440) (r .9) (g 1.0) (postfilter-gain nil)) (let* ((st (floor (* start *srate*))) (nd (+ st (floor (* *srate* dur)))) (rd (make-rand)) (ft (make-formant freq r)) (postfilter-amp (* g (if postfilter-gain postfilter-gain 1.0))) (bal (make-balance))) (run* (bal) (loop for i from st to nd do (let ((sig (* amp (rand rd)))) (outa i (balance bal (* postfilter-amp (formant ft sig)) sig))))) (if (not postfilter-gain) (format t "~&formnt-noise: specify a :postfiler-gain of ~,5F for best results.~%" (balance-avg bal)))))