Matlab批量处理指定文件夹下的所有音频文件

filedir='E:/source/Wavfile/*.wav'; % 设置路径
outfiledir='E:/output/Wavfile/';
infiledir='E:/source/Wavfile/';
files = dir(filedir);

for i = 1 : length(files)
infile = [infiledir,files(i).name];
[x,fs] = audioread(infile);
x_L = x(:,1);
x_R = x(:,2);
y = x_L + x_R;
outfile_L = [outfiledir,files(i).name(1:end-4),'_L.wav'];
outfile_R = [outfiledir,files(i).name(1:end-4),'_R.wav'];
outfile_Y = [outfiledir,files(i).name(1:end-4),'_Y.wav'];
audiowrite(outfile_L, x_L , fs);
audiowrite(outfile_R, x_R , fs);
audiowrite(outfile_Y, y , fs);
end

posted @ 2017-06-27 15:26  SStriver  阅读(3647)  评论(0编辑  收藏  举报