Linear filter for echo effect

8 次查看(过去 30 天)
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

采纳的回答

Mathieu NOE
Mathieu NOE 2021-1-18
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Audio Processing Algorithm Design 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by