I’ve been meaning to write an example of this, so here’s an example:
;type process
;;; Amplify by +3 dB
(setq gain (db-to-linear 3.0))
;;; DSP function
(defun amp (a g)
(dotimes (i (length a) a)
(setf (aref a i)(* g (aref a i)))))
;;; Iterate through audio selection
;;; grabbing an array full of samples at a time.
(defun amplify (sig gain)
; len is a global variable for number of samples in the selection
(let* ((Samples (truncate len))
(alen 10000) ; array size
(it (truncate (/ len alen))) ; iterations
(remain (rem samples alen)) ; samples left over
(adur (/ alen *sound-srate*)) ; duration of alen as sound
(remaindur (/ remain *sound-srate*))
(out (s-rest 0))) ; initialise output
(do ((i 0 (1+ i))
tmpsnd
(tnext 0 (+ adur tnext)))
((= i it)) ; do until i=it
; Get the samples
(setf sndarray (snd-fetch-array sig alen alen))
; Apply the DSP
(setf sndarray (amp sndarray gain))
; Convert back to a ]temporary] sound
(setf tmpsnd (snd-from-array 0 *sound-srate* sndarray))
;;Add 'tmpsnd' to the end of 'out'
(setf out
(sim out
(at-abs tnext (cue tmpsnd)))))
;; Now do any remaining samples
(if (> remain 0)
(progn
(setf sndarray (snd-fetch-array sig remain remain))
(setf sndarray (amp sndarray gain))
(sim out
(at-abs (- dur remaindur)
(cue (snd-from-array 0 *sound-srate* sndarray)))))
out)))
; Duration in seconds
(setq dur (get-duration 1))
; 'expand' the AMPLIFY function for each channel of 's'.
(multichan-expand #'amplify s gain)