function [y, b, a] = all_pass(x, g, d)
% A simple all-pass filter function
% Inputs:
% x - input signal
% g - feedforward gain, should be less than 1 for stability 
% d - delay length
% Outputs:
 % y - output signal
 % b - numerator coefficients of the transfer function
 % a - denominator coefficients of the transfer function
% a)
a = zeros(1,d+1);%denominator
a(1)=1;
a(end)=g;

%b)
b= zeros(1,d+1);%numerator
b(1)=g;
b(end)=1;

%c)
[impresp, timevector] = impz(b,a);
y=conv(x,impresp);

end

