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 20, 2024
1 parent 8c3ba52 commit 93e9a42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Filters/stream_filt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function setphase!(kernel::FIRArbitrary, ϕ::Real)
(ϕ, xThrowaway) = modf(ϕ)
kernel.inputDeficit += round(Int, xThrowaway)
kernel.ϕAccumulator = ϕ*(kernel.Nϕ) + 1.0
kernel.ϕIdx = round(kernel.ϕAccumulator)
kernel.ϕIdx = floor(kernel.ϕAccumulator)
kernel.α = modf(kernel.ϕAccumulator)[1]
nothing
end
Expand Down
8 changes: 8 additions & 0 deletions test/filt_stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,11 @@ 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
let H = FIRFilter(122.2)
setphase!(H, 0.99)
@test length(filt(H, 1:2)) == 124
end

0 comments on commit 93e9a42

Please sign in to comment.