To clip a waveform we can just use:
1 2 |
(clip sound amplitude) |
where sound is the waveform and amplitude is the linear level that we wish to clip at.
To clip a sound asymmetrically it is necessary to offset the wave before clipping, then adjust the waveform back to its original position. For example to clip the negative part of a wave at 0.5 we can use:
1 2 3 |
(sim 0.5 (clip (sim -0.5 sound) 1)) |
This works fine for mono tracks, but for stereo tracks sim is only applied to the first channel.
To work round this problem we can create a
sim function that works with multi-channel sound.
Let’s call this function
ssim .
1 2 3 |
(defun ssim (x y) (multichan-expand #' sim x y)) |
Now we can use the previous code to clip the audio:
1 2 3 4 5 6 |
(defun ssim (x y) (multichan-expand #' sim x y)) (setq s (ssim s -0.5)) (ssim 0.5 (clip s 1)) |
Nice site, nice and easy on the eyes and great content too.