Superimposing A Echo onto a Signal

1 次查看(过去 30 天)
Rakshith R
Rakshith R 2019-4-9
Write a function called echo_gen that adds an echo effect to an audio recording. The function is to be called like this:
output = echo_gen(input, fs, delay, amp);
where input is a column vector with values between -1 and 1 representing a time series of digitized sound data. The input argument fs is the sampling rate. The sampling rate specifies how many samples we have in the data each second. For example, an audio CD uses 44,100 samples per second. The input argument delay represent the delay of the echo in seconds. That is, the echo should start after delay seconds have passed from the start of the audio signal. Finally, amp specifies the amplification of the echo which normally should be a value less than 1, since the echo is typically not as loud as the original signal.
I have a solution to this but i am unable to identify as to why the output variable is a wrong answer when the simple test cases are right
function output = echo_gen(input,fs,delay,amp)
format long;
inputsiz = size(input);
if inputsiz(1) == 1
input = input';
end
D = round(delay*fs);
a = length(input)+D;
if D>0
yy = [zeros(D,1);(input*amp)];
% y = [input;zeros(D,1)] +yy;
% else
% y = input+(input*amp);
% end
xx = [input;zeros(D,1)];
for i=1:length(xx)
y(i) = xx(i) + yy(i);
end
y=y';
else
y = input+(input*amp);
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by