Skip to content

Commit

Permalink
Removed Float32 from biquads due to Accelerate bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rprechelt committed Apr 5, 2016
1 parent 78c31d0 commit 9dae727
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
21 changes: 14 additions & 7 deletions src/DSP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ type DFTSetup{T}
end
end

immutable Biquad{T}
type Biquad{T}
setup::Ptr{Void}
sections::Integer
sections::Int

function Biquad(setup::Ptr{Void}, sections::Int)
biquadsetup = new(setup, sections)
finalizer(biquadsetup, biquaddestroy)
biquadsetup
end
end

## === FUNCTIONS == ##
Expand Down Expand Up @@ -129,7 +135,7 @@ for (T, suff) in ((Float64, "D"), (Float32, ""))
end

## == Biquadratic/IIR filtering
for (T, suff) in ((Float64, "D"), (Float32, ""))
for (T, suff) in ((Float64, "D"), )

"""
Initializes a vDSP_biquad_setup for use with vDSP_biquad. A multi-section filter
Expand All @@ -140,7 +146,7 @@ for (T, suff) in ((Float64, "D"), (Float32, ""))
Returns: Biquad{T}
"""
@eval begin
function createbiquad(coefficients::Vector{$T}, sections::Integer)
function biquadcreate(coefficients::Vector{$T}, sections::Int)
if length(coefficients) < 5*sections
error("Incomplete biquad specification provided - coefficients must
contain 5 elements for each filter section")
Expand All @@ -161,7 +167,7 @@ for (T, suff) in ((Float64, "D"), (Float32, ""))
Returns: Vector{T}
"""
@eval begin
function biquad(X::Vector{$T}, delays::Vector{$T}, numelem::Integer, biquad::Biquad)
function biquad(X::Vector{$T}, delays::Vector{$T}, numelem::Int, biquad::Biquad{$T})
if length(delays) < (2*(biquad.sections)+2)
error("Incomplete delay specification provided - delays must contain 2*M + 2
values where M is the number of sections in the biquad")
Expand All @@ -177,12 +183,13 @@ for (T, suff) in ((Float64, "D"), (Float32, ""))

"""
Frees all resources associated with a particular Biquad previously
created through a call to biquad_create_setup
created through a call to biquad_create_setup. This is called automatically
when the setup object is no longer visible to the garbage collector.
Returns: Void
"""
@eval begin
function destroybiquad(biquad::Biquad{$T})
function biquaddestroy(biquad::Biquad{$T})
ccall(($(string("vDSP_biquad_DestroySetup", suff), libacc)), Void,
(Ptr{Void}, ),
biquad.setup)
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ for T in (Float32, Float64)
end
end

for T in (Float32, Float64)
for T in (Float64, )
@testset "Biquadratic Flitering::$T" begin
@testset "Single Section::$T" begin
X::Vector{T} = randn(10)
d::Vector{T} = zeros(4)
c::Vector{T} = [0.5, 0.5, 0.5, 0.5, 0.5]
c::Vector{T} = [x%0.5 for x in randn(5)]
fdsp = DSP.Biquad(c[1], c[2], c[3], c[4], c[5])
fa = AppleAccelerate.createbiquad(c, 1)
@test filt(fdsp, X) AppleAccelerate.biquad(X, d, length(X), fa)
fa = AppleAccelerate.biquadcreate(c, 1)
@test DSP.filt(fdsp, X) AppleAccelerate.biquad(X, d, length(X), fa)
end
end
end
Expand Down

0 comments on commit 9dae727

Please sign in to comment.