org.tritonus.share.sampled.convert
Class TSynchronousFilteredAudioInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by javax.sound.sampled.AudioInputStream
          extended by org.tritonus.share.sampled.convert.TAudioInputStream
              extended by org.tritonus.share.sampled.convert.TSynchronousFilteredAudioInputStream
All Implemented Interfaces:
java.io.Closeable, FloatSampleInput
Direct Known Subclasses:
FloatAudioInputStream, ImaAdpcmFormatConversionProvider.DecodedImaAdpcmAudioInputStream, ImaAdpcmFormatConversionProvider.EncodedImaAdpcmAudioInputStream

public abstract class TSynchronousFilteredAudioInputStream
extends TAudioInputStream
implements FloatSampleInput

Base class for types of audio filter/converter that translate one frame to another frame.
It provides all the transformation of frame sizes.
It does NOT handle different sample rates of original stream and this stream !


Constructor Summary
TSynchronousFilteredAudioInputStream(AudioInputStream audioInputStream, AudioFormat newFormat)
           
 
Method Summary
 int available()
           
 void close()
           
 int getChannels()
           
 AudioFormat getOriginalFormat()
           
 AudioInputStream getOriginalStream()
           
 float getSampleRate()
           
 boolean isDone()
          Determine if this stream has reached its end.
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] abData, int nOffset, int nLength)
          Read nLength bytes that will be the converted samples of the original InputStream.
 void read(FloatSampleBuffer buffer)
          Fill the entire buffer with audio data.
 void read(FloatSampleBuffer buffer, int offset, int sampleCount)
          read sampleCount converted samples at the specified offset.
 void reset()
           
 long skip(long nSkip)
           
 
Methods inherited from class org.tritonus.share.sampled.convert.TAudioInputStream
properties
 
Methods inherited from class javax.sound.sampled.AudioInputStream
getFormat, getFrameLength, read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TSynchronousFilteredAudioInputStream

public TSynchronousFilteredAudioInputStream(AudioInputStream audioInputStream,
                                            AudioFormat newFormat)
Method Detail

read

public int read()
         throws java.io.IOException
Overrides:
read in class AudioInputStream
Throws:
java.io.IOException

getOriginalStream

public AudioInputStream getOriginalStream()

getOriginalFormat

public AudioFormat getOriginalFormat()

read

public final int read(byte[] abData,
                      int nOffset,
                      int nLength)
               throws java.io.IOException
Read nLength bytes that will be the converted samples of the original InputStream. When nLength is not an integral number of frames, this method may read less than nLength bytes.

Overrides:
read in class AudioInputStream
Throws:
java.io.IOException

skip

public long skip(long nSkip)
          throws java.io.IOException
Overrides:
skip in class AudioInputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class AudioInputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class AudioInputStream
Throws:
java.io.IOException

mark

public void mark(int readlimit)
Overrides:
mark in class AudioInputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class AudioInputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class AudioInputStream

getChannels

public int getChannels()
Specified by:
getChannels in interface FloatSampleInput
Returns:
the number of audio channels of the audio data that this stream provides. If it can support a variable number of channels, this method returns AudioSystem.NOT_SPECIFIED.

getSampleRate

public float getSampleRate()
Specified by:
getSampleRate in interface FloatSampleInput
Returns:
the sample rate of the audio data that this stream provides. If it can support different sample rates, this method returns a negative number, e.g. AudioSystem.NOT_SPECIFIED.

isDone

public boolean isDone()
Description copied from interface: FloatSampleInput
Determine if this stream has reached its end. If true, subsequent calls to read() will return 0-sized buffers.

Specified by:
isDone in interface FloatSampleInput
Returns:
true if this stream reached its end.

read

public void read(FloatSampleBuffer buffer,
                 int offset,
                 int sampleCount)
read sampleCount converted samples at the specified offset. The current implementation requires that offset is 0 and sampleCount == buffer.getSampleCount().

Specified by:
read in interface FloatSampleInput
Parameters:
buffer - the buffer to be filled
offset - the start index, in samples, where to start filling the buffer
sampleCount - the number fo samples to fill into the buffer

read

public void read(FloatSampleBuffer buffer)
Description copied from interface: FloatSampleInput
Fill the entire buffer with audio data. If fewer samples are read, this method will use buffer.changeSampleCount() to adjust the size of the buffer. If no samples can be written to the buffer, the buffer's sample count will be set to 0.

The buffer's channel count and sample rate may not be changed by the implementation of this method.

Specified by:
read in interface FloatSampleInput
Parameters:
buffer - the buffer to be filled