Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to care about big endian and little endian when I read data through AudioInputStream?

I am reading a wav file through AudioInputStream into a byte array,

    AudioInputStream audiofile = AudioSystem.getAudioInputStream(f);
    byte[] audio=new byte[numberofframes*framesize];
    int bytes=audiofile.read(audio);

do I need to arrange the bytes of a sample considering that the data is arranged in little endian or does the AudioInputStream do it for me?

like image 273
Romantic Electron Avatar asked Jan 02 '13 04:01

Romantic Electron


1 Answers

Big- versus little-endian matters if the data is encoded in more than a single byte, e.g., bit depths of 16 or more, regardless of the number of channels. Java does not automatically arrange the PCM bytes in a default order, it just accepts them.

The following is the clearest, best written single section of the java audio tutorials, imho, and covers issues pertaining to formats and their conversions:

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

like image 66
Phil Freihofner Avatar answered Oct 12 '22 22:10

Phil Freihofner