image thumbnail
from GUI for DTMF Generator-Decoder using Goertzel's Algorithm by Pranam Janney
GUI for DTMF generator-decoder using Goertzel's algorithm.

GUI(varargin)
function varargout = GUI(varargin)
%          GUI Application M-file for GUI.fig
%        FIG = GUI launch GUI GUI.
%              GUI('callback_name', ...) invoke the named callback.
%
%  Author: Pranam Janney           Date: 15/05/04     Time: 17:50          
%  Email: pranamjanney@yahoo.com

if nargin == 0  % LAUNCH GUI

	fig = openfig(mfilename,'reuse');

	% Use system color scheme for figure:
	set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));

	% Generate a structure of handles to pass to callbacks, and store it. 
	handles = guihandles(fig);
    
    % Initialising structure variables to be used in program
    handles.data = 0;           % used for storing the Num_of_samples value
    handles.data1 = 0;          % used for storing the Slider values
    handles.data3 = 0;          % used for storing the number of times the push button is pressed
    handles.data4(1,8) = ' ';       % Array to store the numbers dialled 
	handles.chk = 0;            %  To check if the Number of samples is used or not
    
    guidata(fig, handles);

	if nargout > 0
		varargout{1} = fig;
	end

elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK

	try
		if (nargout)
			[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
		else
			feval(varargin{:}); % FEVAL switchyard
		end
	catch
		disp(lasterr);
	end

end

% --------------------------------------------------------------------
function varargout = pushbutton1_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator(1,N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton2_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end       %  Number of samples

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator(2,N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton3_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end


NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator('A',N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton4_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator(3,N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);




% --------------------------------------------------------------------
function varargout = pushbutton5_Callback(h, eventdata, handles, varargin)


% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator(4,N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);




% --------------------------------------------------------------------
function varargout = pushbutton6_Callback(h, eventdata, handles, varargin)


% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator(5,N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton7_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator(7,N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton8_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator(6,N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);




% --------------------------------------------------------------------
function varargout = pushbutton9_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator('B',N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton10_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator(8,N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton11_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator(9,N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton12_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator('C',N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton13_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator('*',N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton14_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator('D',N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);




% --------------------------------------------------------------------
function varargout = pushbutton15_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator('#',N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = pushbutton16_Callback(h, eventdata, handles, varargin)

% To check for N
if handles.chk == 0
    N = 205;
else
    N = handles.data;           %  Number of samples
end

NP = handles.data1;         % Noise Power
handles.data3 = handles.data3 + 1;  % to keep track of number of times push buttons are used

% Generator
[x,v,snr] = generator(0,N,NP);
size(x);

% Display SNR
set(handles.edit3,'String',snr)

% To plot on GUI
f = 1:N;
axes(handles.Out_dtmf) % Select the proper axes
plot(f,x(1:N))
set(handles.Out_dtmf,'XMinorTick','on')
grid on

% Decoder
[D,m] = decoder(x,N);
size(m);

% To append each dialled digit into an array (max 8 numbers)
[handles.data4,handles.data3] = StringNum(handles.data4,D,handles.data3);

% After 8th digit the next number is put into first digit place
if handles.data4 == ' ' 
    handles.data4(handles.data3) = D;
end

% To display the dialled numbers 
set(handles.edit2,'String',handles.data4);         % The dialled number as decoded by the decoder
                                       % is displayed on the edit text

% To plot the output                                       
f = 1 : length(m);
axes(handles.G_output) % Select the proper axes
plot(f,m)
set(handles.G_output,'XMinorTick','on')
grid on
guidata(h,handles);



% --------------------------------------------------------------------
function varargout = popupmenu1_Callback(h, eventdata, handles, varargin)

handles.chk = 1;
val = get(h,'Value')    % gets the number of the array element selected
if val == 1
    handles.data = 205;  %  saving the required data into HANDLES
elseif val == 2
    handles.data = 128;
else
    handles.data = 1024;
end
guidata(h,handles);      % saving the HANDLE structure


% --------------------------------------------------------------------
function varargout = slider2_Callback(h, eventdata, handles, varargin)

va = get(h,'Value');

% Display value on EDIT TEXT
set(handles.edit1,'String',num2str(va));
handles.data1 = va;
guidata(h,handles);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



Contact us at files@mathworks.com