|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xiph.speex.AudioFileWriter
org.xiph.speex.PcmWaveWriter
public class PcmWaveWriter
Writes basic PCM wave files from binary audio data.
Here's an example that writes 2 seconds of silence
PcmWaveWriter s_wsw = new PcmWaveWriter(2, 44100); byte[] silence = new byte[16*2*44100]; wsw.Open("C:\\out.wav"); wsw.WriteHeader(); wsw.WriteData(silence, 0, silence.length); wsw.WriteData(silence, 0, silence.length); wsw.Close();
Field Summary | |
---|---|
private int |
channels
Defines the number of channels of the audio input (1=mono, 2=stereo). |
private boolean |
isPCM
|
private int |
mode
Defines the encoder mode (0=NB, 1=WB and 2-UWB). |
private int |
nframes
Defines the number of frames per speex packet. |
private int |
quality
|
private java.io.RandomAccessFile |
raf
|
private int |
sampleRate
Defines the sampling rate of the audio input. |
private int |
size
|
private boolean |
vbr
Defines whether or not to use VBR (Variable Bit Rate). |
static int[][][] |
WAVE_BITS_PER_FRAME
Table describing the number of bit per Speex frame, depending on its mode-1 (1=NB, 2=WB, 3=UWB), channels-1 (1=mono, 2=stereo) and the quality setting (0 to 10). |
static short |
WAVE_FORMAT_PCM
Wave type code of PCM |
static short |
WAVE_FORMAT_SPEEX
Wave type code of Speex |
static int[][][] |
WAVE_FRAME_SIZES
Table describing the number of frames per packet in a Speex Wave file, depending on its mode-1 (1=NB, 2=WB, 3=UWB), channels-1 (1=mono, 2=stereo) and the quality setting (0 to 10). |
Constructor Summary | |
---|---|
PcmWaveWriter()
Constructor. |
|
PcmWaveWriter(int sampleRate,
int channels)
Constructor. |
|
PcmWaveWriter(int mode,
int quality,
int sampleRate,
int channels,
int nframes,
boolean vbr)
Constructor. |
Method Summary | |
---|---|
private static int |
calculateBlockSize(int mode,
int channels,
int quality)
Calculates block size (considering padding). |
private static int |
calculateEffectiveBitrate(int mode,
int channels,
int quality)
Calculates effective bitrate (considering padding). |
void |
close()
Closes the output file. |
void |
open(java.io.File file)
Open the output file. |
void |
open(java.lang.String filename)
Open the output file. |
private void |
setPCMFormat(int sampleRate,
int channels)
Sets the output format for a PCM Wave file. |
private void |
setSpeexFormat(int mode,
int quality,
int sampleRate,
int channels,
int nframes,
boolean vbr)
Sets the output format for a Speex Wave file. |
void |
writeHeader(java.lang.String comment)
Writes the initial data chunks that start the wave file. |
void |
writePacket(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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final short WAVE_FORMAT_PCM
public static final short WAVE_FORMAT_SPEEX
public static final int[][][] WAVE_FRAME_SIZES
public static final int[][][] WAVE_BITS_PER_FRAME
private java.io.RandomAccessFile raf
private int mode
private int quality
private int sampleRate
private int channels
private int nframes
private boolean vbr
private int size
private boolean isPCM
Constructor Detail |
---|
public PcmWaveWriter()
public PcmWaveWriter(int sampleRate, int channels)
sampleRate
- the number of samples per second.channels
- the number of audio channels (1=mono, 2=stereo, ...).public PcmWaveWriter(int mode, int quality, int sampleRate, int channels, int nframes, boolean vbr)
mode
- the mode of the encoder (0=NB, 1=WB, 2=UWB).quality
- 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 Detail |
---|
private void setPCMFormat(int sampleRate, int channels)
sampleRate
- the number of samples per second.channels
- the number of audio channels (1=mono, 2=stereo, ...).private void setSpeexFormat(int mode, int quality, int sampleRate, int channels, int nframes, boolean vbr)
mode
- the mode of the encoder (0=NB, 1=WB, 2=UWB).quality
- 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
- public void close() throws java.io.IOException
close
in class AudioFileWriter
java.io.IOException
- if there was an exception closing the Audio Writer.public void open(java.io.File file) throws java.io.IOException
open
in class AudioFileWriter
file
- - file to open.
java.io.IOException
- if there was an exception opening the Audio Writer.public void open(java.lang.String filename) throws java.io.IOException
open
in class AudioFileWriter
filename
- filename to open.
java.io.IOException
- if there was an exception opening the Audio Writer.public void writeHeader(java.lang.String comment) throws java.io.IOException
writeHeader
in class AudioFileWriter
comment
- ignored by the WAV header.
java.io.IOException
public void writePacket(byte[] data, int offset, int len) throws java.io.IOException
writePacket
in class AudioFileWriter
data
- audio dataoffset
- the offset from which to start reading the data.len
- the length of data to read.
java.io.IOException
private static final int calculateEffectiveBitrate(int mode, int channels, int quality)
mode
- channels
- quality
-
private static final int calculateBlockSize(int mode, int channels, int quality)
mode
- channels
- quality
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |