f_wav_as.m
来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 74 行
M
74 行
%
% Wave to Ascii Conversion Routine
%Author : Karthik and modified by Childers
%Conversion accomplished using the wavread routine in MATLAB
%For more information see MATLAB help on wavread
%Matlab also has a function auread for audio files.
cwd=pwd;
[fname pathname]=uigetfile('*.wav','Load input file(.wav)');
S=sprintf('cd %s',cwd);
eval(S);
if fname ~= 0
S=sprintf('Loading data .....');
disp(S);
S1 = [char(pathname) char(fname)];
[waveData,fs,bits]=wavread(S1);
S2=sprintf('The sampling frequency of the wav file is %5g ', fs);
disp(S2);
S3=sprintf('The number of bits per sample for the wav file is %3g ', bits);
disp(S3);
disp('The first playback is at the wav sampling frequency');
disp('You may use the play button in the ACTION window to play the data again at the');
disp('wav sampling frequency.');
disp('Remember that if you elect to save the data as an ASCII file');
disp('that the saved file will have a sampling frequency equal to that of the wav file.');
% create message window and write message in that window also
message_win=figure('Unit','normalized',...
'Position',[0.05 0.2 0.9 0.2],...
'Resize','off',...
'Color',BACK_COLOR,...
'Numbertitle','off',...
'Name','Message');
axis('off');
ss1=S2;
text(-0.05,1,ss1,'color',TEXT_COLOR,'FontSize',10);
ss2=S3;
text(-0.05,6/7,ss2,'color',TEXT_COLOR,'FontSize',10);
ss4=sprintf('The first playback is at the wav sampling frequency');
text(-0.05,5/7,ss4,'color',TEXT_COLOR,'FontSize',10);
ss5=sprintf('You may use the play button in the ACTION window to play the data again at the');
text(-0.05,4/7,ss5,'color',TEXT_COLOR,'FontSize',10);
ss6=sprintf('wav sampling frequency.');
text(-0.05,3/7,ss6,'color',TEXT_COLOR,'FontSize',10);
ss7=sprintf('Remember that if you elect to save the data as an ASCII file');
text(-0.05,2/7,ss7,'color',TEXT_COLOR,'FontSize',10);
ss7=sprintf('that the saved file will have a sampling frequency equal to that of the wav file.');
text(-0.05,1/7,ss7,'color',TEXT_COLOR,'FontSize',10);
end
% Plays back the sound wav file
j=1;
while j < 2
soundsc(waveData,fs,bits);
j= menu('Action','Play wav', 'Save file', 'Exit');
end
if j == 2
[fname1 pathname1]=uiputfile('*.dat','Save file (ASCII)');
S=sprintf('cd %s',cwd);
eval(S);
if fname1 ~= 0
S=sprintf('Saving data into %s (ASCII format)',fname1);
disp(S);
S=sprintf('save %s%s waveData -ascii',pathname1,fname1);
eval(S);
else
fname1=o_fname;
pathname1=o_pname;
end
elseif j==3
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?