Package org.xiph.speex
Class OggSpeexWriter
java.lang.Object
org.xiph.speex.AudioFileWriter
org.xiph.speex.OggSpeexWriter
Ogg Speex Writer
- Version:
- $Revision: 1.2 $
- Author:
- Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intDefines the number of channels of the audio input (1=mono, 2=stereo).private byte[]Data bufferprivate intPointer within the Data bufferprivate longAbsolute granule position (the number of audio samples from beginning of file to end of Ogg Packet).private byte[]Header bufferprivate intPointer within the Header bufferprivate intDefines the encoder mode (0=NB, 1=WB and 2-UWB).private intDefines the number of frames per speex packet.private OutputStreamThe OutputStreamprivate intSpeex packet count within an Ogg Pagestatic final intNumber of packets in an Ogg page (must be less than 255)private intOgg Page countprivate intDefines the sampling rate of the audio input.private intprivate intOgg Stream Serial Numberprivate booleanDefines whether or not to use VBR (Variable Bit Rate). -
Constructor Summary
ConstructorsConstructorDescriptionBuilds an Ogg Speex Writer.OggSpeexWriter(int mode, int sampleRate, int channels, int nframes, boolean vbr) Builds an Ogg Speex Writer. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the output file.private voidflush(boolean eos) Flush the Ogg page out of the buffers into the file.voidOpen the output file.voidOpen the output file.private voidsetFormat(int mode, int sampleRate, int channels, int nframes, boolean vbr) Sets the output format.voidsetSerialNumber(int serialNumber) Sets the Stream Serial Number.voidwriteHeader(String comment) Writes the header pages that start the Ogg Speex file.voidwritePacket(byte[] data, int offset, int len) Writes a packet of audio.Methods inherited from class org.xiph.speex.AudioFileWriter
buildOggPageHeader, buildSpeexComment, buildSpeexHeader, writeInt, writeInt, writeInt, writeLong, writeLong, writeOggPageHeader, writeShort, writeShort, writeShort, writeSpeexComment, writeSpeexHeader, writeString
-
Field Details
-
PACKETS_PER_OGG_PAGE
public static final int PACKETS_PER_OGG_PAGENumber of packets in an Ogg page (must be less than 255)- See Also:
-
out
The OutputStream -
mode
private int modeDefines the encoder mode (0=NB, 1=WB and 2-UWB). -
sampleRate
private int sampleRateDefines the sampling rate of the audio input. -
channels
private int channelsDefines the number of channels of the audio input (1=mono, 2=stereo). -
nframes
private int nframesDefines the number of frames per speex packet. -
vbr
private boolean vbrDefines whether or not to use VBR (Variable Bit Rate). -
size
private int size -
streamSerialNumber
private int streamSerialNumberOgg Stream Serial Number -
dataBuffer
private byte[] dataBufferData buffer -
dataBufferPtr
private int dataBufferPtrPointer within the Data buffer -
headerBuffer
private byte[] headerBufferHeader buffer -
headerBufferPtr
private int headerBufferPtrPointer within the Header buffer -
pageCount
private int pageCountOgg Page count -
packetCount
private int packetCountSpeex packet count within an Ogg Page -
granulepos
private long granuleposAbsolute granule position (the number of audio samples from beginning of file to end of Ogg Packet).
-
-
Constructor Details
-
OggSpeexWriter
public OggSpeexWriter()Builds an Ogg Speex Writer. -
OggSpeexWriter
public OggSpeexWriter(int mode, int sampleRate, int channels, int nframes, boolean vbr) Builds an Ogg Speex Writer.- Parameters:
mode- the mode of the encoder (0=NB, 1=WB, 2=UWB).sampleRate- the number of samples per second.channels- the number of audio channels (1=mono, 2=stereo, ...).nframes- the number of frames per speex packet.vbr-
-
-
Method Details
-
setFormat
private void setFormat(int mode, int sampleRate, int channels, int nframes, boolean vbr) Sets the output format. Must be called before WriteHeader().- Parameters:
mode- the mode of the encoder (0=NB, 1=WB, 2=UWB).sampleRate- the number of samples per second.channels- the number of audio channels (1=mono, 2=stereo, ...).nframes- the number of frames per speex packet.vbr-
-
setSerialNumber
public void setSerialNumber(int serialNumber) Sets the Stream Serial Number. Must not be changed mid stream.- Parameters:
serialNumber-
-
close
Closes the output file.- Specified by:
closein classAudioFileWriter- Throws:
IOException- if there was an exception closing the Audio Writer.
-
open
Open the output file.- Specified by:
openin classAudioFileWriter- Parameters:
file- - file to open.- Throws:
IOException- if there was an exception opening the Audio Writer.
-
open
Open the output file.- Specified by:
openin classAudioFileWriter- Parameters:
filename- - file to open.- Throws:
IOException- if there was an exception opening the Audio Writer.
-
writeHeader
Writes the header pages that start the Ogg Speex file. Prepares file for data to be written.- Specified by:
writeHeaderin classAudioFileWriter- Parameters:
comment- description to be included in the header.- Throws:
IOException
-
writePacket
Writes a packet of audio.- Specified by:
writePacketin classAudioFileWriter- Parameters:
data- - audio data.offset- - the offset from which to start reading the data.len- - the length of data to read.- Throws:
IOException
-
flush
Flush the Ogg page out of the buffers into the file.- Parameters:
eos- - end of stream- Throws:
IOException
-