You can directly edit the code with open resample
and browse the different options. INgredients are border (zero padding, border trimming) and delay management, filter design (uniform or firls
with kaiser
) before the use of upfirdn
for antialiasing. A snippet of the function's help.
% Y = RESAMPLE(X,P,Q,N) uses a weighted sum of 2*N*max(1,Q/P) samples of X
% to compute each sample of Y. The length of the FIR filter RESAMPLE applies
% is proportional to N; by increasing N you will get better accuracy at the
% expense of a longer computation time. If you don't specify N, RESAMPLE uses
% N = 10 by default. If you let N = 0, RESAMPLE performs a nearest
% neighbor interpolation; that is, the output Y(n) is X(round((n-1)*Q/P)+1)
% ( Y(n) = 0 if round((n-1)*Q/P)+1 > length(X) ).
%
% Y = RESAMPLE(X,P,Q,N,BTA) uses BTA as the BETA design parameter for the
% Kaiser window used to design the filter. RESAMPLE uses BTA = 5 if
% you don't specify a value.
%
% Y = RESAMPLE(X,P,Q,B) uses B to filter X (after upsampling) if B is a
% vector of filter coefficients. RESAMPLE assumes B has odd length and
% linear phase when compensating for the filter's delay; for even length
% filters, the delay is overcompensated by 1/2 sample. For non-linear
% phase filters consider using UPFIRDN.