在Java 1.6中连接两个WAV文件的最简单方法是什么?(等频和所有,没什么特别的.)
(这可能太简单了,但今天我的Google-fu在这个问题上似乎很弱.)
这是准系统代码:
import java.io.File; import java.io.IOException; import java.io.SequenceInputStream; import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; public class WavAppender { public static void main(String[] args) { String wavFile1 = "D:\\wav1.wav"; String wavFile2 = "D:\\wav2.wav"; try { AudioInputStream clip1 = AudioSystem.getAudioInputStream(new File(wavFile1)); AudioInputStream clip2 = AudioSystem.getAudioInputStream(new File(wavFile2)); AudioInputStream appendedFiles = new AudioInputStream( new SequenceInputStream(clip1, clip2), clip1.getFormat(), clip1.getFrameLength() + clip2.getFrameLength()); AudioSystem.write(appendedFiles, AudioFileFormat.Type.WAVE, new File("D:\\wavAppended.wav")); } catch (Exception e) { e.printStackTrace(); } } }