Implement a reverbration effect on an audio

I faced diffiulties in implentenig revrerbartion with the feedback filter y[?] = ?[? − ?] + ?[?], where D is related to the dimensions of the simulated room, and
0 < ? < 1 is the absorption coefficient of the wallsusing tho and audio using this eqution. so whats it the mistake and how the code should be
x=audioread("SpeechDFT-16-8-mono-5secs.wav")
sound(x)
y=zeros(1,length x)
for
n=10
a=1
d=0.500
y(n)=a*y(n-d)+x(n)
end

Answers (1)

In MATLAB, for loops must have one of these syntaxes:
for variable = start : stop
for variable = start : increment : stop
for variable = expression
Using plain for without something that looks like an assignment on the same line, is not valid syntax.
y=zeros(1,length x)
You need to use the function form of length
y=zeros(1,length(x));

4 Comments

I improved the code and try this but it doesn't work
x=audioread("SpeechDFT-16-8-mono-5secs.wav")
sound(x)
y=zeros(1,length(x))
for n=2:length(x)
a=1
d=0.500
y(n) =a*y(n-d)+x(n)
end
n is your index. d is 1/2. n-d is your index minus 1/2. You then use that to try to index y, but n-1/2 is not an integer, and so is not a valid index.
Look again at your equation:
y[?] = ?[? − ?] + ?[?]
There is no y[something] on the right hand side of that, and your 0 < ? < 1 looks like it is a constant so might represent multiplication of a constant by that value. Or perhaps not: you might have forgotten to give information that would make a into a function or sequence.
y(n) =a*y(n-d)+x(n)
d = 0.5
but array index (n-d) must be integer.
y(n-d) does not appear anywhere in your posted equation, y[?] = ?[? − ?] + ?[?]
Perhaps it should have been . If so then take note that the [] are not indices and instead represent functional relationship. The value at time n depends upon the value at time n - D. D is time, not relative index. When you convert your equation over to using vectors, you need to convert that D from being time to being relative index, by multiplying the time by the sample rate.
Often when time is converted to delay in samples, the result is not an integer. You can choose to ignore that, using floor() or ceil() or round() of the delay-in-samples; this will result in the signal not really being right, especially if it has to pass through more processing. For example, two stages of delays of 22.5 samples should logically be the same as a single delay of 45 samples, not of 2*floor(22.5) = 44 or 2*ceil(22.5) = 26. The higher your sample rate, the less significant the difference will be for perception. But to get it right, you might choose to use fractional delay techniques.

Sign in to comment.

Categories

Asked:

on 29 Apr 2020

Commented:

on 29 Apr 2020

Community Treasure Hunt

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

Start Hunting!