adding echo to an audio file

3 ビュー (過去 30 日間)
Perturabo
Perturabo 2019 年 2 月 15 日
回答済み: Romelyn Ramos 2021 年 3 月 18 日
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 件のコメント
Priyamvada Shankar
Priyamvada Shankar 2019 年 3 月 25 日
If anyone knows the correct code please do reply

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 2 月 15 日
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 件のコメント
Walter Roberson
Walter Roberson 2020 年 4 月 13 日
what error are you encountering?
Walter Roberson
Walter Roberson 2020 年 4 月 13 日
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.

サインインしてコメントする。


Romelyn Ramos
Romelyn Ramos 2021 年 3 月 18 日
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

カテゴリ

Help Center および File ExchangeAudio Processing Algorithm Design についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by