function gain = dtmf_filt_char(L,frq,display)
%function gain = dtmf_filt_char(L,frq,display)
%
% DTMF_FILT_CHAR -- a function to help characterize the effects
%                   of a DTMF bandpass filter.  Displays the
%                   gains as a table and on a plot of the 
%                   filter's frequency response.
%
% Input Parameters:
%   L       -- length of the impulse response of the bandpass filter
%   frq     -- center frequency of the bandpass filter
%   display -- indicates whether or not to display the frq response
%
% Ouptut Parameters:
%   gain    -- The gain of the filter at the DTMF frequencies
%

if ~exist('display','var') | isempty(display)
    display = 1;
end


frqs = [697 770 852 941 1209 1336 1477 frq];
frqs = unique(frqs);

fs = 8192;
t = 0:1/fs:(1-1/fs);

h = sin(t(1:L)*2*pi*frq);

[H,w] = freqz(h,1,fs/2);

gain = abs(H(frqs));

if display
    plot(w*fs/2/pi,abs(H));
    xlabel('Frequency (Hz)');
    ylabel('Gain');
    
    hold on
    stem(frqs,abs(H(frqs)),'g');
    stem(frq,abs(H(frq)),'r');
    hold off;
    
    ax = axis;
    axis([500 2000 0 ax(end)]);
end

%fprintf(1,'Frequency:  ');
%fprintf(1,'%8d ',frqs);
%fprintf(1,'\nGain:       ');
%fprintf(1,'%8g ',gain);
%fprintf(1,'\n\n');
