Programmatically (e.g. in Python) adding clipping to an audio file? I am trying to replicate the audio artifact exemplified here to a set of 1000 audio files. In particular, I would like to be able to 'clip' the louder parts of each sound clip so they become distorted as in this video. Is there a way I can do this with a script?

Thanks!
Simple clipping :
threshold = 0.5
If x > threshold
  x = threshold
elseif x &lt; -threshold
  x = -threshold
end

Real-world clipping can be significantly more complex than this, involving various time-constants, asymmetry, heating-effects,....