diff --git a/Project.toml b/Project.toml index 9227c13..1da9d61 100644 --- a/Project.toml +++ b/Project.toml @@ -9,3 +9,4 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +TxRxModels = "b3a66cf7-5ddc-45c2-8bf6-0600270461a1" diff --git a/src/ISM.jl b/src/ISM.jl index 41a1460..89fb9e0 100644 --- a/src/ISM.jl +++ b/src/ISM.jl @@ -82,7 +82,7 @@ function ISM_RectangularRoom_core( lrng::AbstractRNG # random number generator )::AbstractVector{T} where {T<:AbstractFloat} - # Allocate memory for impulose response + # Allocate memory for the impulose response h = zeros(T, Nh) # Call diff --git a/src/RoomAcoustics.jl b/src/RoomAcoustics.jl index 01ede2d..7dd52d9 100644 --- a/src/RoomAcoustics.jl +++ b/src/RoomAcoustics.jl @@ -7,9 +7,11 @@ using DSP using Random using Random: GLOBAL_RNG +using TxRxModels +using TxRxModels: AbstractDirectivityPattern + include("types.jl") include("utils.jl") -include("directivity.jl") include("ISM.jl") include("moving_sources.jl") diff --git a/src/directivity.jl b/src/directivity.jl deleted file mode 100644 index fc02e65..0000000 --- a/src/directivity.jl +++ /dev/null @@ -1,74 +0,0 @@ - -""" - -""" -function cardioid_pattern( - d::SVector{3, <:Real}, - B::SMatrix{3, 3, <:Real}, - ρ::Real, -)::Real - r = [1., 0., 0.] - ρ + (1-ρ) * r' * B' * d -end - - - -""" - -""" -function directivity_pattern( - d::SVector{3, <:Real}, - B::SMatrix{3, 3, <:Real}, - pattern::OmnidirectionalPattern, -)::Real - 1 -end - - -""" - -""" -function directivity_pattern( - d::SVector{3, <:Real}, - B::SMatrix{3, 3, <:Real}, - pattern::SubcardioidPattern, -)::Real - cardioid_pattern(d, B, 0.75) -end - - -""" - -""" -function directivity_pattern( - d::SVector{3, <:Real}, - B::SMatrix{3, 3, <:Real}, - pattern::CardioidPattern, -)::Real - cardioid_pattern(d, B, 0.50) -end - - -""" - -""" -function directivity_pattern( - d::SVector{3, <:Real}, - B::SMatrix{3, 3, <:Real}, - pattern::HypercardioidPattern, -)::Real - cardioid_pattern(d, B, 0.25) -end - - -""" - -""" -function directivity_pattern( - d::SVector{3, <:Real}, - B::SMatrix{3, 3, <:Real}, - pattern::BidirectionalPattern, -)::Real - cardioid_pattern(d, B, 0.00) -end - diff --git a/src/types.jl b/src/types.jl index ff54902..e000981 100644 --- a/src/types.jl +++ b/src/types.jl @@ -1,52 +1,9 @@ -export Omnidirectional, - Subcardioid, - Cardioid, - Hypercardioid, - Bidirectional - -export TxRx, TxRxArray export Room, RectangularRoom export RIRConfig, ISMConfig - -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() -const Subcardioid = SubcardioidPattern() -const Cardioid = CardioidPattern() -const Hypercardioid = HypercardioidPattern() -const Bidirectional = BidirectionalPattern() - - - -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 |> SVector{3}, B, d) -end - -struct TxRxArray{T<:Real} <: AbstractTxRx - p::Vector{<:TxRx{T}} # list of TxRxes in the local frame - origin::SVector{3, T} # Position of the local origin in reference to the global origin - B::SMatrix{3, 3, T} # Orientation of the array (local -> global) -end - - abstract type Room end struct RectangularRoom{T<:Real} <: Room