adding echo to an audio file

3 visualizaciones (últimos 30 días)
Perturabo
Perturabo el 15 de Feb. de 2019
Respondida: Romelyn Ramos el 18 de Mzo. de 2021
I have to create a function
output = echo_gen(input, fs, delay, gain);
Where input is a column vector, fs is sampling rate, delay is delay and gain is the gain of the echo, which is less than 1.
The output vector will be longer than the input vector if the delay is not zero (round to the nearest number of points needed to get the delay, as opposed to floor or ceil). A sound recording has values between -1 and 1, so if the echo causes some values to be outside of this range, you will need to normalize the entire vector, so that all values adhere to this requirement.
I have no idea how to approach this, as I have only ever worked with basic matrices as opposed to actual signals in MATLAB.
  1 comentario
Priyamvada Shankar
Priyamvada Shankar el 25 de Mzo. de 2019
If anyone knows the correct code please do reply

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 15 de Feb. de 2019
multiply delay in seconds by sampling frequency in samples per second to get number of samples for delay. floor() to get integer count. Call it ds. if ds is 0 then declare an error .
now [1, zeroes(1,ds-1), gain] are coefficients for a filter you can pass the signal through .
After filtering then if max(abs(signal)) is greater than 1 you need to divide by that value to rescale.
  27 comentarios
Walter Roberson
Walter Roberson el 13 de Abr. de 2020
what error are you encountering?
Walter Roberson
Walter Roberson el 13 de Abr. de 2020
You should not be concerned about whether the echo part exceeds +/- 1, you should be concerned about whether the output does. for example original data 0.7 echo 0.4, echo is not outside the range +/- 1 but the sum of the two is outside the range.

Iniciar sesión para comentar.


Romelyn Ramos
Romelyn Ramos el 18 de Mzo. de 2021
function [output]= echo_gen(input,fs,delay,amp)
[r,c] = size(input);
extraEchoTime = round(delay*fs);
echoSignal = zeros(r+extraEchoTime,1);
addEchoSignal = echoSignal ;
for i=1:r
echoSignal(extraEchoTime+i,1) =input(i,1)*amp ;
addEchoSignal(i) = input(i);
end
addEchoSignal = addEchoSignal + echoSignal ;
range = abs(addEchoSignal) ;
maxrange = max(range);
if maxrange>1
addEchoSignal = addEchoSignal/maxrange;
end
output = addEchoSignal ;
end

Categorías

Más información sobre Audio Processing Algorithm Design en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by