Summary: An implementation of distortion in Matlab
A very simple type of guitar distortion can be done with clipping of the signal. This is where a threshold value is set, and if the signal ever increases above this value, it is clipped off. This type of distortion adds a "fuzzy" sounding distortion. As is obvious from the picture of the frequency-domain effects of clipping, clipping the signal creates a more complex signal by adding more frequencies.
| Distorted Sine Wave |
|---|
![]() |
| FFT of a distorted sine wave |
|---|
![]() |
The Matlab code that implements this algorithm is also very simple:
function [output]=fuzzy(sound, amount)
norms = norm(sound);
output = sound/norms;
amount = (1- amount)/100;
for i = 1:length(output)
if ( output(i) > amount )
output(i) = amount;
end
if ( output(i) < -amount)
output(i) = -amount;
end
end
output = output*norms;