2022-10-13 15:50:42 +02:00
|
|
|
|
2023-02-17 13:24:19 +01:00
|
|
|
export AbstractRoom, RectangularRoom
|
|
|
|
export AbstractRIRConfig, ISMConfig
|
2023-08-27 11:38:33 +02:00
|
|
|
export Node, Event
|
2022-10-13 15:50:42 +02:00
|
|
|
|
|
|
|
|
2023-02-17 13:24:19 +01:00
|
|
|
abstract type AbstractRoom end
|
2022-10-13 15:50:42 +02:00
|
|
|
|
2023-02-17 13:24:19 +01:00
|
|
|
struct RectangularRoom{T<:Real} <: AbstractRoom
|
2024-05-16 09:49:40 +02:00
|
|
|
c::T # Sound wave velocity
|
|
|
|
L::Tuple{T,T,T} # size of room (x, y, z)
|
|
|
|
β::Tuple{T,T,T,T,T,T} # absorption coeffictions for walls
|
2022-10-13 15:50:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-17 13:24:19 +01:00
|
|
|
abstract type AbstractRIRConfig end
|
2022-10-13 15:50:42 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
"""
|
2023-05-16 11:55:55 +02:00
|
|
|
struct ISMConfig{T<:Real,I<:Integer,R<:AbstractRNG} <: AbstractRIRConfig
|
|
|
|
order::Tuple{I,I} # Order of reflection [low, high]
|
2022-10-13 15:50:42 +02:00
|
|
|
fs::T # Sampling frequency
|
|
|
|
N::I # Number of samples in impulse response
|
|
|
|
Wd::T # Single impulse width
|
|
|
|
hp::Bool # High pass filter
|
|
|
|
isd::T # Image source distortion (randomized image method)
|
2022-12-23 10:41:22 +01:00
|
|
|
lrng::R
|
2022-10-13 15:50:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function ISMConfig(
|
|
|
|
order=(0, -1),
|
2022-12-23 10:41:22 +01:00
|
|
|
fs=16000.0,
|
2022-10-13 15:50:42 +02:00
|
|
|
N=4000,
|
|
|
|
Wd=8e-3,
|
|
|
|
hp=true,
|
|
|
|
isd=0.0,
|
|
|
|
lrng=GLOBAL_RNG
|
|
|
|
)
|
|
|
|
ISMConfig(order, fs, N, Wd, hp, isd, lrng)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2023-08-27 11:38:33 +02:00
|
|
|
struct Node{T<:Real}
|
|
|
|
rx::TxRxArray{T}
|
|
|
|
fs::T
|
|
|
|
δ::T
|
|
|
|
function Node(rx, fs::T, δ::T = 0.0) where T
|
|
|
|
δ < 0.0 && error("δ < 0")
|
|
|
|
fs < 0.0 && error("fs < 0")
|
|
|
|
new{T}(rx, fs, δ)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
struct Event{T<:Real, V<:AbstractVector{<:T}} # NOTE: TxNode może będzie lepszą nazwa?
|
|
|
|
tx::TxRx{T}
|
|
|
|
emission::T
|
|
|
|
fs::T
|
|
|
|
signal::V
|
|
|
|
function Event(tx, emission::T, fs::T, signal::V) where {T, V}
|
|
|
|
emission < 0.0 && error("emission < 0")
|
|
|
|
fs < 0.0 && error("fs < 0")
|
|
|
|
new{T, V}(tx, emission, fs, signal)
|
|
|
|
end
|
|
|
|
end
|