Linear filter for echo effect

9 Ansichten (letzte 30 Tage)
RoBoTBoY
RoBoTBoY am 17 Jan. 2021
Beantwortet: Mathieu NOE am 18 Jan. 2021
Hello all!
A discrete-time causal filter is described by the following difference equation.
A simple linear filter for simulation of echo-effect can be described by the following equation
How can I represent the above equation in code?
% I'm not sure about that
syms x(n) y(n)
eq = y(n) == c*x(n)+(1-c)*x(n-P)
Can I use syms function for n x and y.
P and c are known
Also I want to transform from difference equation to tranfer function. Can I use the function ztrans() for that?
Thanks in advance

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 18 Jan. 2021
hello
there is a very simple way to implement echo effects - see demo code below
infile='DirectGuitar.wav';
outfile='out_echo.wav';
% read the sample waveform
[x,Fs] = audioread(infile);
% normalize x to +/- 1 amplitude
x = x ./ (max(abs(x)));
% parameters
N_delay=20; % delay in samples
C = 0.7; % amplitude of direct sound
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y = zeros(length(x),1); % create empty out vector
y(1:N_delay)=x(1:N_delay); % to avoid referencing of negative samples
% for each sample > N_delay
for i = (N_delay+1):length(x)
y(i) = C*x(i) + (1-C)*(x(i-N_delay)); % add delayed sample
end
% write output
% normalize y to +/- 1 amplitude
y = y ./ (max(abs(y)));
audiowrite(outfile, y, Fs);
figure(1)
hold on
plot(x,'r');
plot(y,'b');
title('Echoed and original Signal');
sound(y,Fs);

Weitere Antworten (0)

Kategorien

Mehr zu Audio Processing Algorithm Design finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by