Merge pull request #35 from ltcptgeneral/jason-branch
Create distortion_filter.m
This commit is contained in:
commit
b82de0b047
26
src/distortion_filter.m
Normal file
26
src/distortion_filter.m
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
% An audio is distorted based on the value of HIGH. Nothing of a certain
|
||||||
|
% threshold should be played above this constant, or they are simply clipped to this
|
||||||
|
% value. Inspired from Meghaj_Echo.m and epic_effect_schluep.m.
|
||||||
|
% Author: Jason Liang
|
||||||
|
|
||||||
|
function y = distortion_filter(x, HIGH)
|
||||||
|
len = length(X);
|
||||||
|
X = fft(x);
|
||||||
|
X = fftshift(X);
|
||||||
|
Y = zeros(1, len);
|
||||||
|
|
||||||
|
for ind = 1:len
|
||||||
|
if (X(ind) > HIGH)
|
||||||
|
Y(ind) = HIGH;
|
||||||
|
elseif (X(ind) < -HIGH)
|
||||||
|
Y(ind) = -HIGH;
|
||||||
|
else
|
||||||
|
Y(ind) = X(ind);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Y = fftshift(Y);
|
||||||
|
y = ifft(Y);
|
||||||
|
y = real(y);
|
||||||
|
|
||||||
|
end
|
Reference in New Issue
Block a user