What's the simplest way to concatenate two WAV files in Java 1.6? (Equal frequency and all, nothing fancy.)
(This is probably sooo simple, but my Google-fu seems weak on this subject today.)
Combine WAV Files Online This audio merger is the handy tool that you need – consolidate them without getting a pesky audio watermark! The web tool works fast and is totally user-friendly. No need to download apps or programs, simply upload your files on the page – choose them from your PC, Google Drive, or Dropbox.
Audacity will allow you to create and subsequently output a multichannel wav file based on an original stereo input wav file. You simply copy and paste or duplicate a track as many times as you require. Or simply create empty (silent) tracks where necessary.
Here is the barebones code:
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();
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With