function digits = ttdecode(x)
	rowks = [175 193 214 236];
	colks = [303 335 370];
	lookup = [ 1 2 3 ; 4 5 6 ; 7 8 9 ; -1 0 -1 ];

	digits = [];
	% Average is there to stop false transitions caused by sinewaves
	% hitting zero.
	silences = abs([0 x]+[x 0])<0.0001;
	transitions = [0 silences] - [silences 0];
	for start = find(transitions==1),
		stops = find(transitions([start:length(transitions)])==-1);
		if length(stops)>0
			stop = stops(1)+start;
		else
			stop = length(x);
		end;
		dig=x([start:stop]);
		DIG = fft(dig,2048);
		energyDIG = abs(DIG).^2;
		rowenergies = energyDIG(rowks);
		colenergies = energyDIG(colks);
		[val rows] = max(rowenergies);
		row = rows(1);
		[val cols] = max(colenergies);
		col = cols(1);
		num = lookup(row,col);
		digits = [digits num];
	end;
