Android when I try to merge 2 waves files the output contains only the first wave

  android, java, wav

I am working on android. I want to merge two wave files and want to create a third file. For this, I create two input streams and then trying to write those input streams into one output stream file. the result I get always contains just 1 of the two files and it ignores the second one

This is my code:-

  try {
                      //first file
                FileInputStream fis1 = new FileInputStream(recordPath+"/test2.wav"); 
                     //second file 
                FileInputStream fis2 = new FileInputStream(recordPath+"/test.wav");   
                    //concatenate the two files
                SequenceInputStream sis = new SequenceInputStream(fis1,fis2);
                FileOutputStream fos = new FileOutputStream(new File(recordPath+"/finaloutput.wav")); 
                int temp;
                try {
                    while ((temp = sis.read())!= -1){
                        fos.write(temp);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }

Source: Android Questions

2 thoughts on - Android when I try to merge 2 waves files the output contains only the first wave

LEAVE A COMMENT