num(c)=i; c=c+1; else end end
%=====转换关键点,精确定位
dot=zeros(1000,1);%定义一个矩阵 len=length(num); dot(1)=0;
dot(2)=num(1); %dot是存储精确定位点的元素 b=3;
for i=3:len
if((num(i)-num(i-1))>3000) dot(b)=num(i); b=b+1; end end
dot(b)=length(x);
%=======对语音序列逆序操作 new=[]; %存放逆序后的矩阵 for i=1:b-1
singlelen=dot(b-i+1)-dot(b-i); temp=zeros(singlelen,1); for h=1: singlelen
temp(h)=y(h+dot(b-i)); end
new=[new;temp]; temp=[]; end
%=========对分割点做平滑处理 for i=2:b-1
new(dot(i))=(new(dot(i)-3)+new(dot(i)-2)+new(dot(i)-1)+new(dot(i)+1)+new(dot(i)+2)+new(dot(i)+3))*1/6; end
set(hObject,'string','倒序完毕'); pause(0.1);
sound(new,handles.Fs);
set(hObject,'string','自适应倒序'); %else %end
% --- Executes on selection change in xuanzexiaoguo.
function xuanzexiaoguo_Callback(hObject, eventdata, handles) % hObject handle to xuanzexiaoguo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns xuanzexiaoguo contents as cell array
% contents{get(hObject,'Value')} returns selected item from xuanzexiaoguo
% --- Executes during object creation, after setting all properties. function xuanzexiaoguo_CreateFcn(hObject, eventdata, handles) % hObject handle to xuanzexiaoguo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in fastdaoxu.
function fastdaoxu_Callback(hObject, eventdata, handles) % hObject handle to fastdaoxu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) w=handles.y;
N=length(w); %N是文件的长度,即点数即wavread中的第二个变量x=zeros(N,1);%定义单列矩阵,
x=w(:,1); %提取单声道元素,用于后面的运算 y=zeros(N,1);%定义单列矩阵,
y=w(:,1); %找到关键点后,利用关键点对原矩阵运算 L=N;
Nfast=N-mod(N,10);xfast=[];j=0; for i=10:10:Nfast j=j+1;
xfast(j)=x(i); end
x=[];
x=xfast;
N=length(x); %重新测定长度 %消除噪音
for i=1:N-1
if abs(x(i))<0.075; x(i)=0; end end
%=====定义标志量,用于插值运算 flag1=0; flag2=0; flag3=0;
%============================================================= for i=800:N-800 for m=1:100
if ((x(i)==0)&((x(i-m)~=0))) flag1=1; end
if ((x(i)==0)&((x(i+m)~=0))) flag2=1; end
flag3=flag1+flag2; if (flag3==2) x(i)=0.03; end
flag1=0; flag2=0; flag3=0; end end
%====寻找关键点 c=1;
num=zeros(100,1);%定义一个矩阵 for i=100:N-100
if (((x(i)==0)&(x(i+1)~=0))|((x(i)~=0)&(x(i+1)==0))) num(c)=i; c=c+1; else end
end
num=num*10; %恢复压缩前位置
%=====转换关键点,精确定位
dot=zeros(100,1);%定义一个矩阵 len=length(num); dot(1)=0;
dot(2)=num(1); %dot是存储精确定位点的元素 b=3;
for i=2:len
if((num(i)-num(i-1))>3000) dot(b)=num(i); b=b+1; end end
dot(b)=length(y);
%=======对语音序列逆序操作 new=[]; %存放逆序后的矩阵 for i=1:b-1
singlelen=dot(b-i+1)-dot(b-i); temp=zeros(singlelen,1); for h=1: singlelen
temp(h)=y(h+dot(b-i)); end
new=[new;temp]; temp=[]; end
%=========对分割点做平滑处理 for i=2:b-1
new(dot(i))=(new(dot(i)-3)+new(dot(i)-2)+new(dot(i)-1)+new(dot(i)+1)+new(dot(i)+2)+new(dot(i)+3))*1/6; end
sound(new,handles.Fs);
参考文献
[1] 方勇.数字信号处理——原理与实践. 第2版. 北京:清华大学出版社,2010. [2] 章毓晋. 图像处理和分析教程. 北京:人民邮电出版社,2009. [3] 刘任化. 基于数字音频信号处理技术的研究. 2008.