diff --git a/src/dsp.jl b/src/dsp.jl index a1bb22f..f9fca39 100644 --- a/src/dsp.jl +++ b/src/dsp.jl @@ -410,8 +410,8 @@ sfiltfilt(coef, x) = signal(filtfilt(coef, samples(x)), framerate(x)) Same as [`resample`](https://docs.juliadsp.org/stable/filters/#DSP.Filters.resample), but correctly handles sampling rate conversion. """ -sresample(x, rate) = signal(resample(samples(x), rate), rate * framerate(x)) -sresample(x, rate, coef) = signal(resample(samples(x), rate, coef), rate * framerate(x)) +sresample(x, rate) = signal(resample(samples(x), rate; dims=1), rate * framerate(x)) +sresample(x, rate, coef) = signal(resample(samples(x), rate, coef; dims=1), rate * framerate(x)) # overload DSP versions of the above functions DSP.filt(f::AbstractVector{<:Number}, x::SampledSignal) = sfilt(f, x) diff --git a/test/runtests.jl b/test/runtests.jl index efeeaa9..07a4a4f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -541,8 +541,18 @@ end @test framerate(x1) == framerate(x) x1 = sresample(x, 3//2) @test framerate(x1) == 3 * framerate(x) / 2 + x1 = sresample(x, 3//2, [1,1,1]) + @test framerate(x1) == 3 * framerate(x) / 2 + x1 = sresample([x x], 3//2) + @test framerate(x1) == 3 * framerate(x) / 2 + x1 = sresample([x x], 3//2, [1,1,1]) + @test framerate(x1) == 3 * framerate(x) / 2 x1 = resample(x, 3//2) @test framerate(x1) == 3 * framerate(x) / 2 + x1 = resample([x x], 3//2) + @test framerate(x1) == 3 * framerate(x) / 2 + x1 = resample([x x], 3//2, [1,1,1]) + @test framerate(x1) == 3 * framerate(x) / 2 x = signal(randn(rng, 100), 10kHz) x1 = signal(vcat(zeros(1000), x/2, zeros(1000)), 10kHz)