ISM rectangular post-filter refactor

This commit is contained in:
zymon 2024-06-11 14:45:29 +02:00
parent a9200e1106
commit f0c2574ff4
2 changed files with 7 additions and 20 deletions

View file

@ -39,16 +39,6 @@ function ISM(
h = zeros(config.N)
# TODO: h = zeros(T, config.N)
ISM!(h, tx, rx, room, config)
if config.hp
return AllenBerkley_highpass100(h, config.fs)
# TODO: Tego nie ma w ISM!
# TODO: Zmień to na funkcie operującą na zaalokowanym już h
# AllenBerkley_highpass100!(h, config.fs)
# return h
else
return h
end
end
@ -158,16 +148,16 @@ function ISM!(
room::RectangularRoom,
config::ISMConfig;
) where {T<:AbstractFloat}
# Impulse parameters
Δt = 1 / config.fs
ω = 2π / config.Wd
twid = π * config.fs
for image_source image_source_generator(tx, rx, room, config)
image_source |> isnothing && continue
A, τ, _, _ = image_source
insert_impuse!(h, A, τ, config.Wd, config.fs, Δt, twid, ω, config.N)
end
config.hp && AllenBerkley_highpass100!(h, config.fs)
return h
end

View file

@ -35,29 +35,26 @@ function Sabine_RT60(T60, L::Tuple, c)
sqrt(1-α)
end
"""
b = [1, -B1, -B2]
a = [1, A1, R1]
"""
function AllenBerkley_highpass100(x, fs)
o = x .* 0
function AllenBerkley_highpass100!(x, fs)
Y = zeros(3)
W = 2π*100/fs
W = 2π / fs * 100
R1 = exp(-W)
B1 = 2*R1*cos(W)
B2 = -R1 * R1
B2 = -R1 * R1
A1 = -(1+R1)
for i = eachindex(x)
Y[3] = Y[2]
Y[2] = Y[1]
Y[1] = B2*Y[3] + B1*Y[2] + x[i]
o[i] = Y[1] + A1*Y[2] + R1*Y[3]
x[i] = Y[1] + A1*Y[2] + R1*Y[3]
end
return o
return x
end