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.
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;
1 comments:
Here's another very simple algorithm, but this one gives a more "analog" sounding distortion, like overdriven tubes. It works by repeatedly taking the sine of the signal which "squashes" the wave (high-amplitude samples get attenuated more than low-amplitude samples):
function output = distortion(input,amount)
% distorts input signal to simulate sound of overdriven vacuum tubes
% distortion amount can be any positive integer
% values of 75-100 give a good continuum of light to heavy distortion
% repeatedly take the sine of the input to distort the waveform
for k=1:amount
input= sin(input);
end
% normalize maximum amplitude to 1 to prevent clipping
output= input/norm(input);
Post a Comment