Need help for GUI of DTMF
1 次查看(过去 30 天)
显示 更早的评论
I have written a code which generates DTMF tones of .5 sec each with 0.1 sec silence gap.I am using this command. soundsc(dtmfdial([1 7 '*' '#' 1 5]),8000);
Now i want that i may have a GUI, in which i will first press the keys and when the keys will finsh, i will press enter and then i will start to listen tones. I have made GUI. but plz help me how to link GUI with code. kindly tell me for just 1 key, rest i will domyself
This is my DTMF code
function [dtmf]=dtmfdial(x);
low_fg = [697 770 852 941]; % Low frequency group
high_fg = [1209 1336 1477]; % High frequency group
f = [];
for a=1:4,
for b=1:3,
f = [ f [low_fg(a);high_fg(b)] ];
end
end
disp('Table of Frequencies is shown')
table=f' %Transpose is taken which converts rows into column and column
dur=.5; %Duration for each tone is .5 sec
fs=8000; % Sampling Freq is 8000 Hz for tones
tt=0:(1/fs):dur;
n=length(x);
D=cell(1,n);
for k=1:n
if x(k)==1
freqa=table(1,1); %Freq is picked from table(row1,col1)
freqb=table(1,2); %Freq is picked from table(row1,col2)
else if x(k)==2
freqa=table(2,1);
freqb=table(2,2);
else if x(k)==3
freqa=table(3,1);
freqb=table(3,2);
else if x(k)==4
freqa=table(4,1);
freqb=table(4,2);
else if x(k)==5
freqa=table(5,1);
freqb=table(5,2);
else if x(k)==6
freqa=table(6,1);
freqb=table(6,2);
else if x(k)==7
freqa=table(7,1);
freqb=table(7,2);
else if x(k)==8
freqa=table(8,1);
freqb=table(8,2);
else if x(k)==9
freqa=table(9,1);
freqb=table(9,2);
else if x(k)=='*'
freqa=table(10,1);
freqb=table(10,2);
else if x(k)==0
freqa=table(11,1);
freqb=table(11,2);
else x(k)='#';
freqa=table(12,1);
freqb=table(12,2);
end
end
end
end
end
end
end
end
end
end
end
% Both the tones are generated
tone1=sin(2*pi*freqa*tt); % Tone of First Frequency
tone2=sin(2*pi*freqb*tt); % Tone of Second Frequency
tone=tone1+tone2; % Now both tones are added
sil_dur=.1; % Defining silence duration between tones
sil_freq=0; % Since we want to keep silence, so frequency is zero
sil_tt=0:(1/fs):sil_dur;
sil_tone=sin(2*pi*sil_freq*sil_tt); % Generating silence tone
D{k} = [tone,sil_tone];
end %end of for loop
dtmf = cat(2, D{:});
Now the GUI file
function varargout = dialgui(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @dialgui_OpeningFcn, ...
'gui_OutputFcn', @dialgui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before dialgui is made visible.
function dialgui_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to dialgui (see VARARGIN)
% Choose default command line output for dialgui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes dialgui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = dialgui_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
0 个评论
回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 DTMF 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!