DSP.jl
DSP.jl copied to clipboard
resample should use `similar`
Currently resample
always returns an Array
even if the input was some other AbstractArray
. It should use similar
so that the returned value is the same type as the input.
MWE:
julia> using SampledSignals, DSP
julia> buf = SampleBuf(rand(100), 48000)
100-frame, 1-channel SampleBuf{Float64, 1}
0.0020833333333333333s sampled at 48000.0Hz
▇▇▇▆▆▇▇▆▇▇▇▆▇▇▇▇▇▆▇▆▇▆▇▇▇▆▆▇▇▆▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▆▆
julia> resample(buf, 1.2)
120-element Array{Float64,1}:
0.8790735553966081
1.0707055066803346
0.5417156513066438
0.9083973585054169
⋮
0.0819987776177565
0.3151630859175723
0.16424615564476444
0.17496872135247912
I'm guessing that's because of this line?
Yes, that should probably be
buffer = similar(x, promote_type(Th,Tx), bufLen)