内容发布更新时间 : 2024/12/23 23:49:29星期一 下面是文章的全部内容请认真阅读。
end
function pushbutton8_Callback(hObject, eventdata, handles) global num_string;global bool; num_string=strcat(num_string,'8'); set,'string',num_string); if bool==0; Music(8); else
Signal(8); end
function pushbutton9_Callback(hObject, eventdata, handles) global num_string;global bool; num_string=strcat(num_string,'9'); set,'string',num_string); if bool==0; Music(9); else
Signal(9); end
function pushbutton10_Callback(hObject, eventdata, handles) global num_string;global bool; num_string=strcat(num_string,'*'); set,'string',num_string); if bool==0; Music(42); else
Signal(42); end
function pushbutton11_Callback(hObject, eventdata, handles) global num_string;global bool; num_string=strcat(num_string,'0'); set,'string',num_string); if bool==0; Music(0); else
Signal(0); end
function pushbutton12_Callback(hObject, eventdata, handles) global num_string;global bool; num_string=strcat(num_string,'#'); set,'string',num_string); if bool==0; Music(35); else
Signal(35); end
function pushbuttonCall_Callback(hObject, eventdata, handles) global bool; global num2_string; global num_string; num2_string=num_string; num_string=''; Call();
if str2num(num2_string)==10000; bool=1; Music(10000); else
Music(11); end
set,'string',num2_string); set,'string','');
function pushbuttonDown_Callback(hObject, eventdata, handles) global num_string; global music; global bool; bool=0; num_string=''; set,'string',''); set,'string',''); music=0;
function text1_CreateFcn(hObject, eventdata, handles) function text2_CreateFcn(hObject, eventdata, handles)
function y=Signal(d);
tm=[1,2,3,65; 4,5,6,66; 7,8,9,67; 42,48,35,68]; N=205; Fs=8000;
K=[18,20,22,24,31,34,38,42]; f1=[697,770,852,941]; f2=[1209,1336,1477,1633]; for p=1:4; for q=1:4; if tm(p,q)==abs(d); break;end end
if tm(p,q)==abs(d); break;end end
n=0:1023;
y = sin(2*pi*n*f1(p)/Fs) + sin(2*pi*n*f2(q)/Fs); sound(y,Fs); X=goertzel(y(1:205),K+1);
val=abs(X);
stem(K,val,'.');grid on;xlabel('k');ylabel('|X(k)|');
function v=Call(); global num2_string;
tm=[1,2,3,65; 4,5,6,66; 7,8,9,67; 42,0,35,68]; Fs=8000;
f1=[697,770,852,941];
f2=[1209,1336,1477,1633]; TN=str2num(num2_string); len=length(num2_string);
for l=1:len; d=fix(TN/10^(len-l)); TN=TN-d*10^(len-l);
for p=1:4; for q=1:4; if tm(p,q)==abs(d); break;end end
if tm(p,q)==abs(d); break;end end
n=0:1023;
y = sin(2*pi*n*f1(p)/Fs) + sin(2*pi*n*f2(q)/Fs); sound(y,Fs); pause; end
function Music(d); global music;
tm=[1,2,3,65; 4,5,6,66; 7,8,9,67; 42,0,35,68]; N=205; Fs=8000;
K=[18,20,22,24,31,34,38,42]; f1=[697,770,852,941]; f2=[1209,1336,1477,1633]; for p=1:4; for q=1:4; if tm(p,q)==abs(d); break;end end
if tm(p,q)==abs(d); break;end
end
hfile =[int2str(d),'.wav']; [y, Fs, nbits] = wavread(hfile); music=audioplayer(y,Fs); play(music);
n=0:1023;
y = sin(2*pi*n*f1(p)/8000) + sin(2*pi*n*f2(q)/8000); X=goertzel(y(1:205),K+1); val=abs(X);
stem(K,val,'.');grid on;xlabel('k');ylabel('|X(k)|'); end