Skip to content

Commit

Permalink
Fix setphase!(::FIRArbitrary, ϕ) similarly
Browse files Browse the repository at this point in the history
Here, the problem is less severe as it requires an explcit call to `setphase!`
with a problematic phase which cannot be hit within normal `resample`
operation.
  • Loading branch information
martinholters committed Nov 19, 2024
1 parent 8c3ba52 commit 8e47ee5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Filters/stream_filt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ end
function setphase!(kernel::FIRArbitrary, ϕ::Real)
ϕ >= zero(ϕ) || throw(ArgumentError("ϕ must be >= 0"))
(ϕ, xThrowaway) = modf(ϕ)
if round*kernel.Nϕ) == kernel.
xThrowaway += 1
ϕ -= 1
end
kernel.inputDeficit += round(Int, xThrowaway)
kernel.ϕAccumulator = ϕ*(kernel.Nϕ) + 1.0
kernel.ϕIdx = round(kernel.ϕAccumulator)
Expand Down
4 changes: 4 additions & 0 deletions test/filt_stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,7 @@ end
# check that these don't throw; the output should actually probably be longer
@test resample(1:2, 3, [zeros(2); 1; zeros(3)]) == [1, 0, 0, 2] # [1, 0, 0, 2, 0, 0]
@test resample(1:2, 3//2, [zeros(2); 1; zeros(3)]) == [1, 0] # [1, 0, 0]
let H = FIRFilter(2.22)
setphase!(H, 0.99)
@test length(filt(H, 1:2)) == 3
end

0 comments on commit 8e47ee5

Please sign in to comment.