The following is the code that reads audio data from 2 audio input streams
into a byte array.
import javax.sound.sampled.*;
import java.io.*;
class tester {
public static void main(String args[]) throws IOException {
try {
Clip clip_1 = AudioSystem.getClip();
AudioInputStream ais_1 = AudioSystem.getAudioInputStream( new File("D:\\UnderTest\\wavtester_1.wav") );
clip_1.open( ais_1 );
Clip clip_2 = AudioSystem.getClip();
AudioInputStream ais_2 = AudioSystem.getAudioInputStream( new File( "D:\\UnderTest\\wavtester_2.wav") );
clip_2.open( ais_2 );
byte arr_1[] = new byte[ais_1.available()]; // not the right way ?
byte arr_2[] = new byte[ais_2.available()];
ais_1.read( arr_1 );
ais_2.read( arr_2 );
} catch( Exception exc ) {
System.out.println( exc );
}
}
}
From the above code i have a byte array1,array2
for ais_1,ais_2
. Is there any way to concatenate these 2 byte arrays ( arr_1,arr_2
) and then convert them back to an audio stream ? I want to concatenate 2 audio files.