diff --git a/src/ISM.jl b/src/ISM.jl index 0bf25f3..28a3ffe 100644 --- a/src/ISM.jl +++ b/src/ISM.jl @@ -60,12 +60,12 @@ function ISM_RectangularRoom_core( tx::SVector{3, T}, # transmitter position rx::SVector{3, T}, # reveiver position B::SMatrix{3, 3, T}, # receiver orientation - dp::DirectivityPattern, # Receiver directivity pattern + dp::AbstractDirectivityPattern, # Receiver directivity pattern L::Tuple{T, T, T}, # room size (Lx, Ly, Lz) β::Tuple{T, T, T, T, T, T}, # Reflection coefficients (βx1, βx2, βy1, βy2, βz1, βz2) c::T, # velocity of the wave fs::T, # sampling frequeyncy - order::Tuple{<:Int, <:Int}, # order of reflections; min max + order::Tuple{<:Int, <:Int}, # order of reflections; min max Nh::Integer, # h lenght in samples Wd::T, # Window width ISD::T, # Random displacement of image source @@ -103,7 +103,7 @@ function ISM_RectangularRoom_core!( tx::SVector{3, T}, # transmitter position rx::SVector{3, T}, # reveiver position B::SMatrix{3, 3, T}, # receiver orientation - dp::DirectivityPattern, # Receiver directivity pattern + dp::AbstractDirectivityPattern, # Receiver directivity pattern L::Tuple{T, T, T}, # room size (Lx, Ly, Lz) β::Tuple{T, T, T, T, T, T}, # Reflection coefficients (βx1, βx2, βy1, βy2, βz1, βz2) c::T, # velocity of the wave diff --git a/src/types.jl b/src/types.jl index ff7a829..cf5cf5a 100644 --- a/src/types.jl +++ b/src/types.jl @@ -12,12 +12,12 @@ export RIRConfig, ISMConfig -abstract type DirectivityPattern end -struct OmnidirectionalPattern <: DirectivityPattern end -struct SubcardioidPattern <: DirectivityPattern end -struct CardioidPattern <: DirectivityPattern end -struct HypercardioidPattern <: DirectivityPattern end -struct BidirectionalPattern <: DirectivityPattern end +abstract type AbstractDirectivityPattern end +struct OmnidirectionalPattern <: AbstractDirectivityPattern end +struct SubcardioidPattern <: AbstractDirectivityPattern end +struct CardioidPattern <: AbstractDirectivityPattern end +struct HypercardioidPattern <: AbstractDirectivityPattern end +struct BidirectionalPattern <: AbstractDirectivityPattern end const Omnidirectional = OmnidirectionalPattern() @@ -28,20 +28,22 @@ const Bidirectional = BidirectionalPattern() -struct TxRx{T<:AbstractFloat} - position::SVector{3, T} # Position - B::SMatrix{3, 3, T} # Orientation - directivity::DirectivityPattern # Directivity pattern +abstract type AbstractTxRx end + +struct TxRx{T<:Real} <: AbstractTxRx + position::SVector{3, T} # Position + B::SMatrix{3, 3, T} # Orientation + directivity::AbstractDirectivityPattern # Directivity pattern end function TxRx(position, B=SMatrix{3,3}(1.0I), d=Omnidirectional) - TxRx(position, B, d) + TxRx(position |> SVector{3}, B, d) end abstract type Room end -struct RectangularRoom{T<:AbstractFloat} <: Room +struct RectangularRoom{T<:Real} <: Room c::T L::Tuple{T, T, T} β::Tuple{T, T, T, T, T, T} @@ -54,19 +56,19 @@ abstract type RIRConfig end """ """ -struct ISMConfig{T<:AbstractFloat, I <: Integer} <: RIRConfig +struct ISMConfig{T<:Real, I<:Integer, R<:AbstractRNG} <: RIRConfig order::Tuple{I, I} # Order of reflection [low, high] 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) - lrng::AbstractRNG + lrng::R end function ISMConfig( order=(0, -1), - fs=16000, + fs=16000.0, N=4000, Wd=8e-3, hp=true,