No BSD License  

Highlights from
DTMF Encoder/Decoder with GUI using FFT,goertzel,Filter Banks

image thumbnail

DTMF Encoder/Decoder with GUI using FFT,goertzel,Filter Banks

by

 

A phone-like DTMF Encoding/Decoding tool

update_gui.m
%   Update_gui : The main routine called when a event happens in gui
%   update_gui
%   If algo==1 then ,
%   
%       
%       Input :
%       signal  : to DTMF signal.
%       
%
%       Output:
%                   Updates the gui (with FFT)...
%
%   
%   elseif algo==0,
%       Input :
%       signal  : to DTMF signal.
%       
%
%       Output:
%                   Updates the gui(with Goertzel)...
%       
%   end   
%   Copyright 2005 (R)
%   Author : Zouzias Anastasios
%   Email : zouzias@ceid.upatras.gr
%   $Date: 2005/08/31 18:03:00 $





%   Copyright 2004 (R)
%   Author : Zouzias Anastasios
%   Email : zouzias@ceid.upatras.gr
%   $Date: 2005/07/30 03:42:00 $


pad=['1' '2' '3' ; '4' '5' '6' ; '7' '8' '9'; '*' '0' '#'];




% For Figure1

axes(handles.fig1);
plot(n,signal);
set(handles.fig1,'XMinorTick','on');
title('DTMF Input');xlabel('Time');
ylabel('Amplitude');grid;





% Suxnothta Deigmatolhpsias
fs=8192; 


%x=fft(signal);


% N=size(signal);
% rmain=2048*2;
% rmarg=1024*2;
% n=1:N(1,1);

N=size(signal);
rmain=2048*2;
rmarg=1024*2;
n=1:rmain;


% Filter Chebysev type 1
% Rand             = 9
% Gain in db       = 0.5
% Cutoff frequence = 0.25

% [b,a]=cheby1(3,0.5,0.51,'high');
% [b,a]=cheby1(3,0.5,0.15,'low');



% [b,a]=cheby1(9,0.5,[0.25 0.50]');


%==================================================
%           HIGH filter for Horizontial freqeunces.
%==================================================

%  [bh,ah]=cheby1(10,0.5,[0.28 0.36]');

%[bh,ah]=cheby1(10,0.5,[2*1200/fs 2*1480/fs]);

[bh,ah]=cheby1(10,0.5,[0.28 0.36]');


%=================================================
%=================================================



[Hh,wh] = freqz(bh,ah,512);
axes(handles.fig15);
plot(wh*fs/(2*pi),abs(Hh));grid;
title('Filter  For Horizontial Freq. Signal');
xlabel('Frequence');ylabel('Amplitude');





%===================================================
%           LOW filter for Horizontial freqeunces.
%===================================================

% [bl,al]=cheby1(9,0.5,[0.15 0.25]');

%[bl,al]=cheby1(9,0.5,[2*630/fs 2*950/fs]);

 [bl,al]=cheby1(9,0.5,[0.15 0.25]');


%=================================================
%=================================================

[Hl,wl] = freqz(bl,al,512);
axes(handles.fig16);
plot(wl*fs/(2*pi),abs(Hl));grid;
title('Filter  For Vertical Freq. Signal');
xlabel('Frequence');ylabel('Amplitude');







yfilthigh=filter(bh,ah,signal);

% For figure 3


axes(handles.fig3);
plot(yfilthigh);grid;
title('Filtered High Freq. Signal');
xlabel('Time');ylabel('Amplitude');



yfiltlow=filter(bl,al,signal);


% For figure 2

axes(handles.fig2);
plot(yfiltlow);grid;
title('Filtered Low Freq. Signal');
xlabel('Time');ylabel('Amplitude');



%============================================
%============================================
%       Algorithm Selection
%============================================
%============================================


if algo==1,
    
        
    % For Horizontial
    yhigh = fft(yfilthigh,rmain);                 
    
    % For Verticle
    ylow = fft(yfiltlow,rmain);                 
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    %y=fft(signal);
    
    % For Horizontial
    mhigh = abs(yhigh);  % Magnitude 
    
    
    % For Figure 5
    
    axes(handles.fig5);
%     mhigh=mhigh(1:end/2);
    plot(mhigh);
    title('FFT High Pass');grid;
    xlabel('n');ylabel('Amplitude');
    
    
    
    
    
    % For Verticle
    mlow = abs(ylow);  % Magnitude 
    
    
    % For Figure 4
    
    axes(handles.fig4);
%     mlow=mlow(1:end/2);
    plot(mlow);
    title('FFT Low Pass');grid;
    xlabel('n');ylabel('Amplitude');
    
    
    
    
    
       
    
    
    energy=[norm(mlow(320:368,1)) norm(mlow(368:406,1)) norm(mlow(406:448,1)) norm(mlow(448:500)) norm(mhigh(587:637,1)) norm(mhigh(637:701,1)) norm(    mhigh(701:760,1)) ]';

    position=[find(energy==max(energy(1:4))) find(energy==max(energy(5:7)))-4]';

      
    digit=pad(position(1,1),position(2,1));
    
    
              
    set(handles.EditPressed,'String',digit(1,1)); 
    
    
    
else
    
       
    
    yfilthigh=[yfilthigh' zeros(1,(rmain-size(yfilthigh,1)) )]';
    
    yfiltlow=[yfiltlow' zeros(1,(rmain-size(yfiltlow,1)) )]';
    
    
    vertical=[601:611 664:674 728:738]';
    
    % 10+10+10
    
    horizontial=[344:354 381:391 422:432 466:476]';
    
    % 10+10+10+10
    
    % For Horizontial
    %yhigh = fft(yfilthigh,rmain);                 
    
    yhigh = goertzel(yfilthigh,vertical);               
    
    %yhigh = goertzel(yfilthigh,1:rmain/2);               
    
    % For Verticle
    
    %ylow=fft(yfiltlow,rmain);
    ylow = goertzel(yfiltlow,horizontial);                 
    
    %ylow = goertzel(yfiltlow,1:rmain/2);
    
    
    
    
    
    
    % For Horizontial
    mhigh = abs(yhigh);  % Magnitude
    
    
    
      % For Figure 5
    
    axes(handles.fig5);
    plot(mhigh);
    title('Goertzel Low Pass for points  (601:611 664:674 728:738)');grid;
    xlabel('Samples with high energy');ylabel('Magnitude');
    
    
    
    
    
    % For Verticle
    mlow = abs(ylow); % Magnitude
    
    
    
      % For Figure 4
    
    axes(handles.fig4);
    plot(mlow);
    title('Goertzel Low Pass for points  (344:354 381:391 422:432 466:476).');grid;
    xlabel('Samples with high energy');ylabel('Magnitude');
    
    
   
   
    
    energy=[norm(mlow(9:12,1)) norm(mlow(20:23,1)) norm(mlow(31:34,1)) norm(mlow(34:37)) norm(mhigh(9:12,1)) norm(mhigh(20:23,1)) norm(    mhigh(24:30,1)) ]';

    position=[find(energy==max(energy(1:4))) find(energy==max(energy(5:7)))-4]';

      
    digit=pad(position(1,1),position(2,1));
    
    
              
    set(handles.EditPressed,'String',digit(1,1)); 
    
    
    
    
    
    
  
    
    
%     max_metro_high=find(mhigh==max(mhigh));
%     
%     max_metro_low=find(mlow==max(mlow));
%     
%     %disp('max_metro is ')
%     digit=[max_metro_low];
%     % digit=[max_metro_high];
%     % max_metro_high];
%     
%     %disp('where?')
%     %t=max(m)
%     
%     
%     
%     if max_metro_high<=12 & max_metro_low<=12;
%         disp('---> Key Pressed is 1');
%         set(handles.EditPressed,'String','1');
%         digit=1;
%     elseif max_metro_high<=23 & max_metro_low<=12;
%         disp('---> Key Pressed is 2');
%         set(handles.EditPressed,'String','2');
%         digit=2;
%     elseif max_metro_high>23 & max_metro_low<=12;
%         disp('---> Key Pressed is 3');
%         set(handles.EditPressed,'String','3');
%         digit=3;
%     elseif max_metro_high<=12 & max_metro_low<=23;
%         disp('---> Key Pressed is 4');
%         set(handles.EditPressed,'String','4');        
%         digit=4;
%     elseif max_metro_high<=23 & max_metro_low<=23;
%         disp('---> Key Pressed is 5');
%         set(handles.EditPressed,'String','5');
%         digit=5;
%     elseif max_metro_high>23 & max_metro_low<=23;
%         disp('---> Key Pressed is 6');
%         set(handles.EditPressed,'String','6');        
%         digit=6;
%     elseif max_metro_high<=12 & max_metro_low<=34;
%         disp('---> Key Pressed is 7');
%         set(handles.EditPressed,'String','7');        
%         digit=7;
%     elseif max_metro_high<=23 & max_metro_low<=34;
%         disp('---> Key Pressed is 8');
%         set(handles.EditPressed,'String','8');        
%         digit=8;
%     elseif max_metro_high>23 & max_metro_low<=34;
%         disp('---> Key Pressed is 9');
%         set(handles.EditPressed,'String','9');        
%         digit=9;
%     elseif max_metro_high<=12 & max_metro_low>=34;
%         disp('---> Key Pressed is *');
%         set(handles.EditPressed,'String','*');        
%         digit='*';
%     elseif max_metro_high<=23 & max_metro_low>=34;
%         disp('---> Key Pressed is 0');
%         set(handles.EditPressed,'String','0');        
%         digit=0;
%     elseif max_metro_high>23 & max_metro_low>=34;
%         disp('---> Key Pressed is #');
%         set(handles.EditPressed,'String','#');        
%         digit='#';
%     end
    
    
    
    
    
end

Contact us