Superimposing A Echo onto a Signal

3 views (last 30 days)
Rakshith R
Rakshith R on 9 Apr 2019
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

Answers (0)

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!