0

I am working on audio data(WAV files) in Java and I am reading an audio file using AudioInputStream. I have a question that when I am reading data using AudioInputStream, does it also include header or the header will be removed?

AudioInputStream ais = AudioSystem.getAudioInputStream(file);
ais.read(data);

What data will contain? All the data along with header? I read things on this link. http://docs.oracle.com/javase/tutorial/sound/converters.html It says it will return Audio Data but I am confused if Audio Data means just data or header too.

Thanks

user3745870
  • 321
  • 1
  • 5
  • 13

1 Answers1

1

Does AudioInputStream's read method exclude header?

Yes, the header is excluded. In my experience, AudioInputStream also properly ignores non-standard non-audio chunks. AudioInputStream#read should only read bytes of audio data.

Here is a makeshift test.

File f = new File("your audio file.wav");
FileInputStream fis = new FileInputStream(f);
AudioInputStream ais = AudioSystem.getAudioInputStream(f);

// prints the number of bytes that are detected not to be audio data
System.out.println(fis.available() - ais.available());

What data will contain?

The data will contain raw bytes straight from the audio section of the file.

Radiodef
  • 37,180
  • 14
  • 90
  • 125