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

% A tapped delay function
% Inputs:
% x - input signal
% n - number of taps (reflections)
% g - vector of gains of each tap
% d - vector of delay lengths of each tap
% Outputs:
% y - output signal
% b - numerator coefficients of the transfer function
% a - denominator coefficients of the transfer function

max_delay = max(d);

a = 1;

b = [0, zeros(1, max_delay)];


for k = 1:n
    
    b(d(k)+1)=b(d(k)+1)+g(k);
    
end

impres = impz(b, a);

y = conv(impres, x);

