org.tritonus.share.sampled.file
Class TAudioOutputStream

java.lang.Object
  extended byorg.tritonus.share.sampled.file.TAudioOutputStream
All Implemented Interfaces:
AudioOutputStream
Direct Known Subclasses:
AiffAudioOutputStream, AuAudioOutputStream, HeaderlessAudioOutputStream, WaveAudioOutputStream

public abstract class TAudioOutputStream
extends Object
implements AudioOutputStream

Base class for classes implementing AudioOutputStream.

Author:
Matthias Pfisterer

Constructor Summary
protected TAudioOutputStream(AudioFormat audioFormat, long lLength, TDataOutputStream dataOutputStream, boolean bDoBackPatching)
           
 
Method Summary
 void close()
          Closes the stream.
 long getCalculatedLength()
          Gives number of bytes already written.
protected  TDataOutputStream getDataOutputStream()
           
 AudioFormat getFormat()
          Retrieves the AufioFormat of this AudioOutputStream.
 long getLength()
          Gives length of the stream.
protected  void patchHeader()
           
protected  void setLengthFromCalculatedLength()
           
 int write(byte[] abData, int nOffset, int nLength)
          Writes audio data to the destination (file or output stream).
protected abstract  void writeHeader()
          Writes the header of the audio file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TAudioOutputStream

protected TAudioOutputStream(AudioFormat audioFormat,
                             long lLength,
                             TDataOutputStream dataOutputStream,
                             boolean bDoBackPatching)
Method Detail

getFormat

public AudioFormat getFormat()
Description copied from interface: AudioOutputStream
Retrieves the AufioFormat of this AudioOutputStream.

Specified by:
getFormat in interface AudioOutputStream

getLength

public long getLength()
Gives length of the stream. This value is in bytes. It may be AudioSystem.NOT_SPECIFIED to express that the length is unknown.

Specified by:
getLength in interface AudioOutputStream

getCalculatedLength

public long getCalculatedLength()
Gives number of bytes already written.


getDataOutputStream

protected TDataOutputStream getDataOutputStream()

write

public int write(byte[] abData,
                 int nOffset,
                 int nLength)
          throws IOException
Writes audio data to the destination (file or output stream).

Specified by:
write in interface AudioOutputStream
Throws:
IOException

writeHeader

protected abstract void writeHeader()
                             throws IOException
Writes the header of the audio file.

Throws:
IOException

close

public void close()
           throws IOException
Closes the stream. This does write remaining buffered data to the destination, backpatch the header, if necessary, and closes the destination.

Specified by:
close in interface AudioOutputStream
Throws:
IOException

patchHeader

protected void patchHeader()
                    throws IOException
Throws:
IOException

setLengthFromCalculatedLength

protected void setLengthFromCalculatedLength()