I use mp3spi to read audio files and then convert them to byte array
ByteArrayOutputStream baout = new ByteArrayOutputStream();
AudioInputStream sound = AudioSystem.getAudioInputStream(file);
byte[] buffer = new byte[4096];
int c;
while ((c = sound.read(buffer, 0, buffer.length)) != -1) {
baout.write(buffer, 0, c);
break; // i read only first 4096 bytes, to make my other stuff faster
}
sound.close();
baout.close();
byte[] data = baout.toByteArray();
If i read audio with following data
frame rate: 38.28125
frame length: -1
frame size: -1
sample rate: 44100.0
channels: 2
bitrate: 320000
i receive an array with over 3900 zero values
int countZero = 0;
for(byte b: data){
if(b == 0){
countZero++;
}
}
System.out.println("count zero values " + countZero); // 3900 - 4000
What is the sense of this zero values? Some traks have 85 instead 0.
Is the difference between different bitrate in this equal values? Is there a way to count, how many this values follow each other, by knowing the bitrate?