net.jinx.audio
Class AudioUtil

java.lang.Object
  extended by net.jinx.audio.AudioUtil

public class AudioUtil
extends java.lang.Object

AudioUtil contains static methods to obtain Buffer objects from various sources.

API Stability: Alpha; this is subject to change at any time.


Method Summary
static boolean isBigEndian()
           
static boolean isBigEndian(java.nio.ByteBuffer buffer)
           
static Buffer loadBuffer(javax.sound.sampled.AudioInputStream in)
          Constructs a Buffer object using data from an AudioInputStream.
static Buffer loadBuffer(java.io.File file)
          Constructs a Buffer object using data from an audio file.
static Buffer loadBuffer(java.net.URL url)
          Constructs a Buffer object using data from an audio file at the given URL.
static Buffer nextBuffer(javax.sound.sampled.AudioInputStream in, int length)
          Constructs a new Buffer object by attempting to read up to the specified number of bytes from the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isBigEndian

public static boolean isBigEndian()

loadBuffer

public static Buffer loadBuffer(java.io.File file)
                         throws java.io.IOException,
                                javax.sound.sampled.UnsupportedAudioFileException
Constructs a Buffer object using data from an audio file.

Parameters:
file - the File to obtain audio data from.
Throws:
java.io.IOException - if an I/O error of any kind occurs.
javax.sound.sampled.UnsupportedAudioFileException - if the file cannot be read because the file type is unsupported.

loadBuffer

public static Buffer loadBuffer(java.net.URL url)
                         throws java.io.IOException,
                                javax.sound.sampled.UnsupportedAudioFileException
Constructs a Buffer object using data from an audio file at the given URL.

Parameters:
url - the URL to obtain audio data from.
Throws:
java.io.IOException - if an I/O error of any kind occurs.
javax.sound.sampled.UnsupportedAudioFileException - if the file cannot be read because the file type is unsupported.

nextBuffer

public static Buffer nextBuffer(javax.sound.sampled.AudioInputStream in,
                                int length)
                         throws java.io.IOException
Constructs a new Buffer object by attempting to read up to the specified number of bytes from the given stream. It may read less. The underlying ByteBuffer is constructed using JOAL's BufferUtils class.

Parameters:
in - the AudioInputStream to obtain audio data from.
length - the number of bytes to read from the stream.
Throws:
java.io.IOException - if an I/O error of any kind occurs.

isBigEndian

public static boolean isBigEndian(java.nio.ByteBuffer buffer)

loadBuffer

public static Buffer loadBuffer(javax.sound.sampled.AudioInputStream in)
                         throws java.io.IOException
Constructs a Buffer object using data from an AudioInputStream. The stream is then closed.

Parameters:
in - the AudioInputStream to obtain audio data from.
Throws:
java.io.IOException - if an I/O error of any kind occurs.