org.tritonus.share.sampled.convert
Class TSynchronousFilteredAudioInputStream
java.lang.Object
java.io.InputStream
javax.sound.sampled.AudioInputStream
org.tritonus.share.sampled.convert.TAudioInputStream
org.tritonus.share.sampled.convert.TSynchronousFilteredAudioInputStream
- All Implemented Interfaces:
- Closeable
- Direct Known Subclasses:
- AlawFormatConversionProvider.FromAlawStream, AlawFormatConversionProvider.ToAlawStream, ImaAdpcmFormatConversionProvider.DecodedImaAdpcmAudioInputStream, ImaAdpcmFormatConversionProvider.EncodedImaAdpcmAudioInputStream, PCM2PCMConversionProvider.PCM2PCMStream, UlawFormatConversionProvider.FromUlawStream, UlawFormatConversionProvider.ToUlawStream
- public abstract class TSynchronousFilteredAudioInputStream
- extends TAudioInputStream
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 !
- Author:
- Florian Bomers
Field Summary |
protected byte[] |
buffer
The intermediate buffer used during convert actions
(if not convertInPlace is used). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
buffer
protected byte[] buffer
- The intermediate buffer used during convert actions
(if not convertInPlace is used).
It remains until this audioStream is closed or destroyed
and grows with the time - it always has the size of the
largest intermediate buffer ever needed.
TSynchronousFilteredAudioInputStream
public TSynchronousFilteredAudioInputStream(AudioInputStream audioInputStream,
AudioFormat newFormat)
enableConvertInPlace
protected boolean enableConvertInPlace()
convert
protected abstract int convert(byte[] inBuffer,
byte[] outBuffer,
int outByteOffset,
int inFrameCount)
- Override this method to do the actual conversion.
inBuffer starts always at index 0 (it is an internal buffer)
You should always override this.
inFrameCount is the number of frames in inBuffer. These
frames are of the format originalFormat.
- Returns:
- the resulting number of frames converted and put into
outBuffer. The return value is in the format of this stream.
convertInPlace
protected void convertInPlace(byte[] buffer,
int byteOffset,
int frameCount)
- Override this method to provide in-place conversion of samples.
To use it, call "enableConvertInPlace()". It will only be used when
input bytes per frame >= output bytes per frame.
This method must always convert frameCount frames, so no return value is necessary.
read
public int read()
throws IOException
- Overrides:
read
in class AudioInputStream
- Throws:
IOException
getOriginalStream
public AudioInputStream getOriginalStream()
getOriginalFormat
public AudioFormat getOriginalFormat()
read
public int read(byte[] abData,
int nOffset,
int nLength)
throws 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:
IOException
skip
public long skip(long nSkip)
throws IOException
- Overrides:
skip
in class AudioInputStream
- Throws:
IOException
available
public int available()
throws IOException
- Overrides:
available
in class AudioInputStream
- Throws:
IOException
close
public void close()
throws IOException
- Specified by:
close
in interface Closeable
- Overrides:
close
in class AudioInputStream
- Throws:
IOException
mark
public void mark(int readlimit)
- Overrides:
mark
in class AudioInputStream
reset
public void reset()
throws IOException
- Overrides:
reset
in class AudioInputStream
- Throws:
IOException
markSupported
public boolean markSupported()
- Overrides:
markSupported
in class AudioInputStream