How to clip a wave asymmetrically

To clip a waveform we can just use:

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:

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┬á.

Now we can use the previous code to clip the audio:

One thought on “How to clip a wave asymmetrically”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.