Created
March 29, 2012 17:08
-
-
Save alalonde/2240025 to your computer and use it in GitHub Desktop.
Concatenate audio files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(clipIterator.next()); | |
if(clipIterator.hasNext()) { | |
AudioInputStream secondInputStream = AudioSystem.getAudioInputStream(clipIterator.next()); | |
SequenceInputStream clipsStream = new SequenceInputStream(audioInputStream, secondInputStream); | |
if(clipIterator.hasNext()) { | |
AudioInputStream thirdInputStream = AudioSystem.getAudioInputStream(clipIterator.next()); | |
clipsStream = new SequenceInputStream(clipsStream, thirdInputStream); | |
audioInputStream = new AudioInputStream(clipsStream, audioInputStream.getFormat(), | |
audioInputStream.getFrameLength() + secondInputStream.getFrameLength() + | |
thirdInputStream.getFrameLength()); | |
} else { | |
audioInputStream = new AudioInputStream(clipsStream, audioInputStream.getFormat(), | |
audioInputStream.getFrameLength() + secondInputStream.getFrameLength()); | |
} | |
} | |
File newAudioTrack = new File(recording.getTempFilesDir(), "appended.wav"); | |
AudioSystem.write(audioInputStream, AudioFileFormat.Type.WAVE, newAudioTrack); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment