I use the following code to append as many wav files present in the sdcard to a single file. audFullPath is an arraylist containing the path of the audiofiles. Is it correct. When I play the recordedaudio1, after doing this. It play only the first file. I want to play all the files. Any suggestion..
File file=new File("/sdcard/AudioRecorder/recordedaudio1.wav");
RandomAccessFile raf = new RandomAccessFile(file, "rw");
for(int i=0;i<audFullPath.size();i++) {
f=new File(audFullPath.get(i));
fileContent = new byte[(int)f.length()];
System.out.println("Filecontent"+fileContent);
raf.seek(raf.length());
raf.writeBytes(audFullPath.get(i));
}
You can’t append
WAVfiles the way you do. That’s because eachWAVhas special format:The simplest possible
WAVfile looks like this:What you need to do is:
WAVfiles are of compatible: same audioFormat, frequency, bits per sample, number of channels, etc.RIFFheader with total file sizeFMTheaderDATAheader with total audio data sizeThis algorithm will definitely work for LPCM, ULAW, ALAW audio formats. Not sure about others.