首页 > 代码库 > Matlab之合并音频

Matlab之合并音频

程序功能:

1.读入wav下的所有音频

2.每个音频截取前0.6秒

3.合并每个音频

 

clear all;
cd = wav;
waveFiles = dir(fullfile(cd,*.wav));
len = size(waveFiles,1);

Z = [];
for i = 1:len
    fileName = [cd / waveFiles(i).name];
    disp(fileName);
    [X, fs] = audioread(fileName);
    X=X( ( 1 : int32(fs*0.6) ), : );
    
    Z = [Z; X];
end

for i = 1:len
    fileName = [cd / waveFiles(len - i + 1).name];
    disp(fileName);
    [X, fs] = audioread(fileName);
    X=X( ( 1 : int32(fs*0.6) ), : );
 
    Z = [Z; X];
end

audiowrite(final.wav,Z,fs);

 

Matlab之合并音频