java 音频 合成

/**
* 将两个wav音频文件合并成一个音频文件 *
* @param srcFile1
* 源文件1
* @param srcFile2
* 源文件2
* @param descFile
* 目标文件
* @throws IOException
* @throws UnsupportedAudioFileException
*/
public static void mergeFile(File srcFile1, File srcFile2, File descFile) throws IOException,
UnsupportedAudioFileException {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(srcFile1);
AudioInputStream ais1 = AudioSystem.getAudioInputStream(srcFile1);
AudioInputStream ais2 = AudioSystem.getAudioInputStream(srcFile2);

SequenceInputStream sis = new SequenceInputStream(ais1, ais2);

AudioSystem.write(new AudioInputStream(sis, aff.getFormat(), ais1.getFrameLength()
+ ais2.getFrameLength()), aff.getType(), descFile);

if (ais1 != null)
ais1.close();
if (ais2 != null)
ais2.close();
if (sis != null)
sis.close();
}
展开阅读全文

没有更多推荐了,返回首页