%All pass filter

function [y, b, a] = allpass(x, g, d)

max_length = max(d);

a = [1, zeros(1, (max_length-1)), g];
b = [g, zeros(1, (max_length-1)), 1];

imp_resp = impz(b, a);

y = conv(x, imp_resp);
