Heloo! I was trying to read bytes per second from an input audio wav files and write those bytes data per second by skipping some bytes to a new audio wav file. My question is how to skip some bytes per second from the input file and writing only remaining bytes data per second to new audio file in java programming. I have code it as:- p is an array which I am using to classify audio file seconds.508 is the file size of input audio file. Means if at 10th second of audio p[q]==0, then the code should not read bytes at 10th seconds. Please highlight where I am doing wrong in this code? The code is running fine, and generating an audio file with size less than the input audio, but it is not playing, neither I can see its duration.
FileInputStream in=new FileInputStream...
FileOutputStream out=new FileOutputStream...
int q=0;
byte[] buf = new byte[44100];
int len;
while (((len = in.read(buf)) > 0)&&(q<508)) {
if(p[q]==1){
out.write(buf, 0, len);
}
q++;
}
in.close();
out.close();