Linear filter for echo effect

9 ビュー (過去 30 日間)
RoBoTBoY
RoBoTBoY 2021 年 1 月 17 日
回答済み: Mathieu NOE 2021 年 1 月 18 日
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 Center および File ExchangeFilter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by