Speaker as Phone Dialer

[Home]

The Goal

To program a telephone dialer that makes phone calls using computer synthesized sounds (Dual-Tone Multi-Frequency (DTMF) tones).

Procedure

Pick up the handset of an ordinary DTMF telephone. Play the synthesized sounds. Done!
(Note: It might not support phones with digital interface.)

Examples of synthesized DTMF tones,

dial('13800138000');
[The ChinaMobile SIM card recharging service ->]

dial('8884737267');
[The US number of GRE Scores by Phone Service ->]

The Code

To have a try, please save the following Matlab script to dial.m, and call it as dial('123-456-7789').

%DIAL.M synthesizes sound to make a phone-call.
% Example Usage:
% dial('123-456-7789');
 
function dial(number_str)
   [tmp len] = size(number_str);
   for i=1:len
      c = number_str(i);
      if c>='1' && c<='9'
         idx = c-'0';
      elseif c=='*'
         idx = 10;
      elseif c=='0'
         idx = 11;
      elseif c=='#'
         idx = 12;
      else
         idx = 0; % Nop
      end
      SoundOne(idx);
   end
end
 
function SoundOne(idx)
   % Buttons 1 2 3 4 5 6 7 8 9 * 0 #
   Frequency_L = [697 697 697 770 770 770 852 852 852 941 941 941];
   Frequency_H = [1209 1336 1477 1209 1336 1477 1209 1336 1477 1209 1336 1477];
 
   Fs = 8192; % Sample Rate
   TimeLen = 1/3; % TimeLength
 
   if idx~=0
      x = 1:Fs*TimeLen/2; % Sound for TimeLength/2
      y_L = sin(2*3.14159265/(1/Frequency_L(idx)*Fs)*x);
      y_H = sin(2*3.14159265/(1/Frequency_H(idx)*Fs)*x);
      y = (y_L+y_H)/2;
      sound(y, Fs);
   end
   pause(TimeLen);
end

 

[Go to my Homepage]
Page last updated: December 30, 2007 8:21 PM