function varargout = tongxin(varargin)
% TONGXIN MATLAB code for tongxin.fig
% TONGXIN, by itself, creates a new TONGXIN or raises the existing
% singleton*.
%
% H = TONGXIN returns the handle to a new TONGXIN or the handle to
% the existing singleton*.
%
% TONGXIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TONGXIN.M with the given input arguments.
%
% TONGXIN('Property','Value',...) creates a new TONGXIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before tongxin_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to tongxin_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help tongxin
% Last Modified by GUIDE v2.5 15-Jun-2012 19:30:08
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @tongxin_OpeningFcn, ...
'gui_OutputFcn', @tongxin_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 tongxin is made visible.
function tongxin_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 tongxin (see VARARGIN)
% global sample;
% Choose default command line output for tongxin
handles.output = hObject;
% Fs=11025;
% time1=1;
% plot(handles.axes1,(0:Fs*time1-1)/Fs,sample);
% FFT=1024;
% Singles=abs(fft(sample,FFT));
% plot(handles.axes2,(0:FFT-1)*11025/FFT,Singles);
% axis([0 2000 0 20]);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes tongxin wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = tongxin_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)
global sample;
global code_seris;
global LongMa;
global hdb3Code;
Fs=11025;
time1=0.5;
sample=wavrecord(time1*Fs,Fs);
wavplay(sample,Fs);
xx=sample';
[n1,n2]=size(xx);
dt =1/Fs;
tt=n2/Fs;
t=dt:dt:tt;
vm1 = 0;
vm = 10.^(vm1/20);
v = 1; %量化区间为[-1,+1]
for k=1:length(vm)
for m=1:1
% x=vm(k)*sin(2*pi*t+2*pi*rand(1));
if(n1>1)
x=xx(1,:);
else
x=xx;
end
sxx = floor(x*4096);
code_seris = pcm_encode(sxx);%PCM量化编码后的0 1序列
end
end
[mazhi,LongMa]=bianma(7,3,code_seris);
hdb3Code=hdb3_code(mazhi);
plot(handles.axes1,(0:Fs*time1-1)/Fs,sample);
FFT=1024;
Singles=abs(fft(sample,FFT));
plot(handles.axes2,(0:FFT-1)*11025/FFT,Singles);
axis([0 2000 0 20]);
% % hdb3Decode=hdb3_decode(hdb3Code);
% % BCHDecode1=yima(7,3,hdb3Decode,LongMa);
% % [m1 m2]=size(BCHDecode1);
% % long=mod(m2,8);
% % BCHDecode=BCHDecode1(1:m2-long);
% % Recover=pcm_decode(BCHDecode,2);
% % plot(handles.axes3,Recover);
% % handles={handles Recover sample};
% % guidata(hObject,handles);
% wavplay(Recover,Fs);
% % % % % % % sample=handles{2};
% % % % % % % FFT=1024;
% % % % % % % Singles=abs(fft(sample,FFT));
% % % % % % % plot(handles{1}.axes2,(0:FFT-1)*11025/FFT,Singles);
% --- Executes on button press in pushbutton1.
function pushbutton2_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)
%data=guidata(hObject);
% Recover=handles{2};
global sample;
global code_seris;
global LongMa;
global hdb3Code;
Fs=11025;
time1=0.5;
sample=wavrecord(time1*Fs,Fs);
wavplay(sample,Fs);
xx=sample';
[n1,n2]=size(xx);
dt =1/Fs;
tt=n2/Fs;
t=dt:dt:tt;
vm1 = 0;
vm = 10.^(vm1/20);
v = 1; %量化区间为[-1,+1]
for k=1:length(vm)
for m=1:1
% x=vm(k)*sin(2*pi*t+2*pi*rand(1));
if(n1>1)
x=xx(1,:);
else
x=xx;
end
sxx = floor(x*4096);
code_seris = pcm_encode(sxx);%PCM量化编码后的0 1序列
end
end
[mazhi,LongMa]=bianma(7,3,code_seris);
hdb3Code=hdb3_code(mazhi);
Fs=11025;
time1=0.5;
plot(handles.axes1,(0:Fs*time1-1)/Fs,sample);
FFT=1024;
Singles=abs(fft(sample,FFT));
plot(handles.axes5,(0:FFT-1)*11025/FFT,Singles);
axis([0 2000 0 20]);
% Singles=abs(fft(sample,FFT));
% plot(handles{1}.axes2,(0:FFT-1)*11025/FFT,Singles);
% --- 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)
global Recover;
% global BCHDecode_FSK;
global code_seris;
global WuMa_FSK;
% hdb3Code=handles{2};
% LongMa=handles{3};
% sample=handles{4};
global sample;
global LongMa;
global hdb3Code;
% [n1 n2]=size(sample);
Mcode=MFSK(hdb3Code);
nn=length(Mcode);
N0=6;%双边功率谱密度
B=4; %带宽
t=1:nn;%产生高斯白噪声,由于白噪声的信号功率为无穷大,因此这里只用较大的近似
P=N0*B;
st=sqrt(P)*randn(1,length(t));
Mcode=Mcode+st;
BestDe=BestRecover(Mcode);
hdb3Decode=hdb3_decode(BestDe);
% hdb3Decode=hdb3_decode(hdb3Code);
BCHDecode1=yima(7,3,hdb3Decode,LongMa);
[m1 m2]=size(BCHDecode1);
long=mod(m2,8);
BCHDecode=BCHDecode1(1:m2-long);
n1=length(code_seris);
WuMa_FSK=sum(abs((code_seris(1:n1)-BCHDecode(1:n1))))/n1;
Recover=pcm_decode(BCHDecode,2);
% bb=fir1(34,0.2,chebwin(35,40));
% Recover=conv(bb,Recover);
FFT=1024;
plot(handles.axes3,Recover);
plot(handles.axes4,(0:FFT-1)*11025/FFT,abs(fft(Recover,FFT)));
axis([0 2000 0 20]);
fsk=num2str(WuMa_FSK);
set(handles.edit2,'string',fsk);
% handles={handles Recover sample};
% guidata(hObject,handles);
% --- 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)
global Recover1;
global WuMa_ASK;
global code_seris;
% hdb3Code=handles{2};
% LongMa=handles{3};
% sample=handles{4};
global LongMa;
global hdb3Code;
Mcode=MASK(hdb3Code);
nn=length(Mcode);
N0=6;%双边功率谱密度
B=4; %带宽
t=1:nn;%产生高斯白噪声,由于白噪声的信号功率为无穷大,因此这里只用较大的近似
P=N0*B;
st=sqrt(P)*randn(1,length(t));
Mcode=Mcode+st;
BestDe=BestRecover1(Mcode);
hdb3Decode=hdb3_decode(BestDe);
% hdb3Decode=hdb3_decode(hdb3Code);
BCHDecode1=yima(7,3,hdb3Decode,LongMa);
[m1 m2]=size(BCHDecode1);
long=mod(m2,8);
BCHDecode=BCHDecode1(1:m2-long);
n1=length(code_seris);
WuMa_ASK=sum(abs((code_seris(1:n1)-BCHDecode(1:n1))))/n1;
Recover1=pcm_decode(BCHDecode,2);
% bb=fir1(34,0.2,chebwin(35,40));
% Recover1=conv(bb,Recover1);
FFT=1024;
plot(handles.axes3,Recover1);
plot(handles.axes4,(0:FFT-1)*11025/FFT,abs(fft(Recover1