com.jmex.audio.stream
Class AudioInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.jmex.audio.stream.AudioInputStream
All Implemented Interfaces:
java.io.Closeable
Direct Known Subclasses:
OggInputStream, WavInputStream

public abstract class AudioInputStream
extends java.io.FilterInputStream

Super class for audio streams implementing the ability to interpret a specific audio format.

Version:
$Id: AudioInputStream.java 4133 2009-03-19 20:40:11Z blaine.dev $
Author:
Arman Ozcelik, Joshua Slack

Field Summary
protected  java.util.ArrayList<Filter> filters
           
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
AudioInputStream(java.net.URL resource, float length)
           
 
Method Summary
 void addFilter(Filter f)
          Adds a DSP filter on this stream
abstract  int getBitRate()
           
abstract  int getChannelCount()
           
abstract  int getDepth()
           
 float getLength()
           
 java.net.URL getResource()
           
abstract  AudioInputStream makeNew()
           
abstract  int read(java.nio.ByteBuffer buffer, int offset, int length)
          Reads up to len bytes of data from the input stream into a ByteBuffer.
 void setLength(float length)
           
static AudioTrack.Format sniffFormat(java.io.InputStream stream)
           
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filters

protected java.util.ArrayList<Filter> filters
Constructor Detail

AudioInputStream

public AudioInputStream(java.net.URL resource,
                        float length)
                 throws java.io.IOException
Throws:
java.io.IOException
Method Detail

read

public abstract int read(java.nio.ByteBuffer buffer,
                         int offset,
                         int length)
                  throws java.io.IOException
Reads up to len bytes of data from the input stream into a ByteBuffer.

Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException

addFilter

public void addFilter(Filter f)
Adds a DSP filter on this stream

Parameters:
f - the filter to apply on the stream

getChannelCount

public abstract int getChannelCount()
Returns:
number of channels in this stream

getBitRate

public abstract int getBitRate()
Returns:
the bitrate of this stream

getDepth

public abstract int getDepth()
Returns:
the bit depth of this stream

getResource

public java.net.URL getResource()

makeNew

public abstract AudioInputStream makeNew()
                                  throws java.io.IOException
Throws:
java.io.IOException

getLength

public float getLength()

setLength

public void setLength(float length)

sniffFormat

public static AudioTrack.Format sniffFormat(java.io.InputStream stream)
                                     throws java.io.IOException
Throws:
java.io.IOException