function [ H , G ]  =  filters(M, alpha, tau, tag)
%
% Computes the analysis and synthesis filters corresponding to the
% fractional B-spline of degree 'alpha' and shift 'tau'.
% M is the length of the filter.
% tag = 0 (analysis), = 1 (synthesis).
%

% uniformly sampled frequencies over [0, 2pi]
nu = (0: 1 : M -1) / M;
p  = (alpha+1)/2 - tau;
q  = (alpha+1)/2 + tau;

[A , A2] = autocorr(M, alpha);

H = sqrt(2) * ((1+exp(2*sqrt(-1)*pi*nu))/2).^p ...
    .* ((1+exp(-2*sqrt(-1)*pi*nu))/2).^q;

G = exp(2*sqrt(-1)*pi*nu) .* A .* H;
G = conj([G(M/2 + (1:M/2)) G(1:M/2)]);

if tag == 1
    H = H.*A ./ A2;
    G = G ./ (A2.*[A(M/2 + (1:M/2)) A(1:M/2)]);
end




