Skip to content

Commit

Permalink
cosmetics, DomainError
Browse files Browse the repository at this point in the history
  • Loading branch information
wheeheee authored and martinholters committed Dec 2, 2024
1 parent 9856def commit 27898c7
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/Filters/stream_filt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,22 +210,22 @@ end
# setphase! set's filter kernel phase index
#
function setphase!(kernel::FIRDecimator, ϕ::Real)
ϕ >= zero(ϕ) || throw(ArgumentError("ϕ must be >= 0"))
ϕ >= zero(ϕ) || throw(DomainError(ϕ, "ϕ must be >= 0"))
xThrowaway = round(Int, ϕ)
kernel.inputDeficit += xThrowaway
nothing
end

function setphase!(kernel::Union{FIRInterpolator, FIRRational}, ϕ::Real)
ϕ >= zero(ϕ) || throw(ArgumentError("ϕ must be >= 0"))
ϕ >= zero(ϕ) || throw(DomainError(ϕ, "ϕ must be >= 0"))
xThrowaway, ϕIdx = divrem(round(Int, ϕ * kernel.Nϕ), kernel.Nϕ)
kernel.inputDeficit += xThrowaway
kernel.ϕIdx = ϕIdx + 1
nothing
end

function setphase!(kernel::FIRArbitrary, ϕ::Real)
ϕ >= zero(ϕ) || throw(ArgumentError("ϕ must be >= 0"))
ϕ >= zero(ϕ) || throw(DomainError(ϕ, "ϕ must be >= 0"))
(ϕ, xThrowaway) = modf(ϕ)
kernel.inputDeficit += round(Int, xThrowaway)
kernel.ϕAccumulator = ϕ * kernel.
Expand Down Expand Up @@ -395,19 +395,10 @@ end
# Calculates the delay caused by the FIR filter in # samples, at the input sample rate, caused by the filter process
#

function timedelay(kernel::Union{FIRRational, FIRInterpolator, FIRArbitrary})
(kernel.hLen - 1)/(2.0*kernel.Nϕ)
end

function timedelay(kernel::Union{FIRStandard, FIRDecimator})
(kernel.hLen - 1)/2
end


function timedelay(self::FIRFilter)
timedelay(self.kernel)
end

timedelay(kernel::Union{FIRRational,FIRInterpolator,FIRArbitrary}) =
(kernel.hLen - 1) / (2 * kernel.Nϕ)
timedelay(kernel::Union{FIRStandard,FIRDecimator}) = (kernel.hLen - 1) / 2
timedelay(self::FIRFilter) = timedelay(self.kernel)

#
# Single rate filtering
Expand Down

0 comments on commit 27898c7

Please sign in to comment.