Understanding the constructor of AudioFormat , AudioInputStream and start method

Viewed 6561

I have tried writing program that plays a sound file but have been unsuccessful so far. I am unable to understand some parts of the code:

InputStream is = new FileInputStream("sound file");
   AudioFormat af = new AudioFormat(float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian); // I don't understand it's constructor
   long length ; // length in sample frames
   // how cani i know the length of frames ?
   AudioInputStream ais = new AudioInputStream( is , af , length );
   // open ( ais );
   // start playing by invoking start method
  • In the constructor of AudioFormat how can I know the sample rate, file size in advance, what are channels, and the 2 boolean variable in the end?
  • How can I get the value of sample frames (length)?
  • Also how do I invoke start method? I don't want the data from any line but from the file kept in a folder (i.e a clip)
2 Answers
Related