Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

single-chunk and multi-chunk runs with streaming arbitrary resampling don't match #134

Closed
ssfrr opened this issue Sep 16, 2016 · 1 comment

Comments

@ssfrr
Copy link
Contributor

ssfrr commented Sep 16, 2016

There's something weird going on with the streaming resampling FIR filter with a floating-point ratio. I'd expect to get the same result (modulo float precision) whether I resampled an array all at once or in chunks with the stateful FIR filter. In the below example it looks like that's not happening. It doesn't happen if I change the ratio to a rational number, so it seems to be a problem just with the FIRArbitrary kernel

function runtest()
    ratio = 9000/48000
    data = rand(64)
    f = FIRFilter(resample_filter(ratio), ratio)
    out1 = filt(f, data)
    f = FIRFilter(resample_filter(ratio), ratio)
    out2 = vcat(filt(f, data[1:32]), filt(f, data[33:end]))

    @assert length(out1) == length(out2)
    for i in 1:length(out1)
        if !isapprox(out1[i], out2[i])
            println("mismatch at element $i: $(out1[i]) != $(out2[i])")
       end
    end
end
julia> runtest()
mismatch at element 7: 0.0021295247679830086 != 1.04360682293e-312
mismatch at element 13: 2.2729773433e-314 != 0.013122266681143116

julia> runtest()
mismatch at element 7: 0.002004266351359534 != 3.254494040945382e-86
mismatch at element 13: 2.2729773433e-314 != 0.012160209855406971

julia> runtest()
mismatch at element 7: 0.001037523637825713 != 1.4004377841750797e195
mismatch at element 13: 2.2729773433e-314 != 0.0076082268936907005

There's a comment in stream_filt.jl above function inputlength(kernel::FIRArbitrary, outputlength::Integer) that says

TODO: figure out why this fails. Might be fine, but the filter operation might not being stepping through the phases correcty.

So maybe that's a clue...

@wheeheee
Copy link
Member

Closing in favour of #317; runtest now produces a BoundsError as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants