function keys = dtmfrun(xx,L,fs)
center_freqs = [697 770 852 941 1209 1336 1477 1633];   % Center frequenciec
hh = dtmfdesign(center_freqs,L,fs);                     % Creates coefficients for the bandpass filters

dtmf.keys = ...
['1','2','3','A';
 '4','5','6','B';
 '7','8','9','C';
 '*','0','#','D'];

[nstart,nstop] = dtmfcut(xx,fs);                        % Detects the individual audio segments of the waveform
keys = [];
for kk=1:length(nstart)                                 % One run per audio segment (per DTMF-tone)
    x_seg = xx(nstart(kk):nstop(kk));                   % Extract the audio
    tones_detected = zeros(1,8);                        % Initialize with zeros...
    for m=1:8                                           % Look for eight different tones:
        tones_detected(m) = dtmfscore(x_seg,hh(:,m));   % Check the audio against each of the 8 filters
    end                                                 % ..and make a '1' if the freq. component is present
    lo_tones = tones_detected(1:4);                     % Binary vector representing 697, 770, 852 and 941 hz
    hi_tones = tones_detected(5:8);                     % Binary vector representing 1209, 1336, 1477 & 1633 hz
    if ((1==sum(lo_tones))&&(1==sum(hi_tones)))         % Test to se if there is one tone present from each group
        lo_tones = sum( lo_tones .* [1 2 3 4] );        %  Find row no. (1 to 4)
        hi_tones = sum( hi_tones .* [1 2 3 4] );        %  Find col. no. (1 to 4)
    end                                                 %
    keys = [keys, dtmf.keys(lo_tones,hi_tones)];        % Append DTMF-character from table to the string.
end

F_RESOLUTION = 1000;
ww = linspace(0,pi,F_RESOLUTION);
FRESP = freqz(xx, 1, ww);
ww = ww * 8000/(2*pi);
plot(ww(1:round(F_RESOLUTION/1.7)),abs(FRESP(1:round(F_RESOLUTION/1.7)))),grid


