I figured it out. It came down to a garbage in garbage out problem. My tone generation was bad. I wound up using this code instead, it is mostly an implementation of snippets from the 'dtmfdemo' code.
symbol = {'1','2','3','4','5','6','7','8','9','*','0','#'};
lfg = [697 770 852 941]; % Low frequency group
hfg = [1209 1336 1477]; % High frequency group
f = [];
for c=1:4,
for r=1:3,
f = [ f [lfg(c);hfg(r)] ];
end
end
Fs = 8000; % Sampling frequency 8 kHz
N = 800; % Tones of 100 ms
t = (0:N-1)/Fs; % 800 samples at Fs
pit = 2*pi*t;
tones = zeros(N,size(f,2));
for button=1:12,
tones(:,button) = sum(sin(f(:,button)*pit))';
end
one = tones(:,1)';
two = tones(:,2)';
three = tones(:,3)';
four = tones(:,4)';
five = tones(:,5)';
six = tones(:,6)';
seven = tones(:,7)';
eight = tones(:,8)';
nine = tones(:,9)';
star = tones(:,10)';
zero = tones(:,11)';
pound = tones(:,12)';
pause = zeros(1,800);
array = [one pause two pause three pause four pause five pause six ...
pause seven pause eight pause nine pause star pause zero pause...
pound];
Then I defined the function Phone Decode:
% phoneDecode.m
% Recieves an array representing variable length DTMF tones alternated with
% variable length pauses and returns a string corresponding to the phone
% number provided.
% Written by Jarick Cammarato on 11/24/12.
function [phoneNum] = phoneDecode(array)
phoneNum = [];
buttonArray =['1' '2' '3'
'4' '5' '6'
'7' '8' '9'
'*' '0' '#'];
digitIndex = find(array); % locates the non-zero indices
start = 1; % Initializing start and stop which will act at the limits of
stop = 1; % individual tones.
x = 1;
original_f = [697; 770; 852; 941; 1209; 1336; 1477];
L = round(original_f/8000*205); % Indices of the DFT
estim_f = round(L*8000/205);
for k = 1:length(digitIndex)-1
if digitIndex(k) ~= digitIndex(k+1)- 1 && ...
digitIndex(k-2) ~= digitIndex(k+1)- 4 || ...
k == length(digitIndex) - 1
% if the values of digitIndex are non-sequential it indicates a
% break has occured due to a pause. If the array end is reached
% then the final digit must be captured.
stop = k; % Sets end of array equal to break point.
tone = array(start:start+204)';
start = digitIndex(k+1); % updates start to begining of next digit.
TONE = abs(goertzel(tone,L+1)); % takes DFT of digit using goertzel algorithm
vert = TONE(1:4)>50;
horz = TONE(5:7)>50;
phoneNum = cat(2,phoneNum,buttonArray(vert,horz));
subplot(4,3,x)
stem(estim_f,TONE)
title (phoneNum(:,x))
ylabel('DFT Magnitude');
xlabel('Frequency (Hz)')
x = x + 1;
end
end
set(gca, 'XTick', estim_f, 'XTickLabel', estim_f, 'XLim', [650 1550]);
ylabel('DFT Magnitude');