diff --git a/Project.toml b/Project.toml index 918b304..c1eb5d3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,12 +1,13 @@ name = "RoomAcoustics" uuid = "9b22aa7e-b0d0-4fe8-9c3b-2b8bf774f735" authors = ["Szymon M. Woźniak "] -version = "0.3.0" +version = "0.3.1" [deps] DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +SLEEFPirates = "476501e8-09a2-5ece-8869-fb82de89a1fa" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" diff --git a/src/ISM.jl b/src/ISM.jl index 079d006..0d0d921 100644 --- a/src/ISM.jl +++ b/src/ISM.jl @@ -145,6 +145,11 @@ function ISM_RectangularRoom_core!( # Transform size of the room from meters to samples Lₛ = L ./ Γ + # Impulse parameters + Δt = 1 / fs + ω = 2π / Wd + twid = π * fs + # Compute maximal wall reflection N = ceil.(Int, Nh ./ (2 .* Lₛ)) @@ -216,10 +221,11 @@ function ISM_RectangularRoom_core!( # Insert yet another impulse into transfer function for i ∈ i_s:i_e - t = (i - 1) / fs - τ # time signature - w = 0.5 * (1.0 + cos(2π * t / Wd)) # Hann window - x = π * fs * t + eps() - h[i] += w * A * sin(x)/x + t = (i - 1) * Δt - τ # time signature + w = fma(cos_fast(ω*t), 0.5, 0.5) # Hann window + x = twid * t + sinc = ifelse(iszero(x), 1.0, sin_fast(x)/x) + @inbounds h[i] += w * A * sinc end end end diff --git a/src/RoomAcoustics.jl b/src/RoomAcoustics.jl index 04f8d9c..f37abfe 100644 --- a/src/RoomAcoustics.jl +++ b/src/RoomAcoustics.jl @@ -6,6 +6,7 @@ using Statistics using Random using Random: GLOBAL_RNG +using SLEEFPirates: cos_fast, sin_fast using DSP: conv include("TxRxModels.jl")