directivity pattern utils moved into TxRxModels package

This commit is contained in:
zymon 2023-02-13 23:35:44 +01:00
parent 2ca29791d0
commit 7285e5cf4f
5 changed files with 5 additions and 119 deletions

View file

@ -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"

View file

@ -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

View file

@ -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")

View file

@ -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

View file

@ -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