Java - removing headers from .wav

I am reading a WAV file into a byte array with the following code.

AudioInputStream inputStream = 
    AudioSystem.getAudioInputStream(/*my .wav file */);
int numBytes = inputStream.available();
byte[] buffer = new byte[numBytes];
inputStream.read(buffer, 0, numBytes);
inputStream.close();

Is there an easy way to remove .wav headers before or after reading into a byte array?

+3
source share
4 answers
+1
source

The AudioInputStream read () method data is already raw wav data. Therefore, there is no need to worry about the .wav header. If you want to access the header materials, you must use the AudioFormat object associated with this AudioInputStream.

http://download.oracle.com/javase/tutorial/sound/converters.html

BTW, .wav , , . while, .

+3

If the correct .wav header is 44 bytes long, so skip / delete the first 44 and there you have it.

I don’t know for sure.

+2
source

Is the wav file header fixed? If so inputStream.skip?

0
source

Source: https://habr.com/ru/post/1717951/


All Articles