f_as_wav.m
来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 60 行
M
60 行
% Ascii to wave file conversion
% Author : Karthik and modified by Childers
% Uses the MATLAB function wavwrite
% For more information see MATLAB help on wavwrite
% Matlab also has a file auwrite for audio files.
cwd=pwd;
[fname pathname]=uigetfile('*.dat','Load input file(.dat)');
S=sprintf('cd %s',cwd);
eval(S);
if fname ~= 0
S=sprintf('Loading data .....');
disp(S);
S=sprintf('load %s%s',pathname,fname);
eval(S);
name=basename(fname);
waveData=eval(name);
maxWaveData = max(abs(waveData));
waveData = waveData./maxWaveData;
disp('The sample rate of the input file is assumed to be 10000.' );
sRate=10000;
end
if (exist('waveData'))
cwd=pwd;
[fname pathname]=uiputfile('*.wav','Save file (ASCII)');
S=sprintf('cd %s',cwd);
eval(S);
if (fname ~= 0)
S=sprintf('Saving data into %s (wav format)',fname);
disp(S);
S = [char(pathname) char(fname)];
wavwrite(waveData,sRate,S)
else
fname=o_fname;
pathname=o_pname;
end
end
% 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=sprintf('The sample rate of the input file is assumed to be 10000.');
text(-0.05,1,ss1,'color',TEXT_COLOR,'FontSize',10);
pause(5.);
close(message_win);
clear message_win;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?