|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javaFlacEncoder.FLACEncoder
public class FLACEncoder
This class defines a FLAC Encoder with a simple interface for enabling FLAC
encoding support in an application. This class is appropriate for use in the
case where you have raw pcm audio samples that you wish to encode. Currently,
fixed-blocksize only is implemented, and the "Maximum Block Size" set in the
StreamConfiguration object is used as the actual block size.
An encoding process is simple, and should follow these steps:
1) Set StreamConfiguration to appropriate values. After a stream is opened, this must not be altered until the stream is closed.
2) Set FLACOutputStream, object to write results to.
3) Open FLAC Stream
4) Set EncodingConfiguration(if defaults are insufficient).
5) Add samples to encoder
6) Encode Samples
7) Close stream
(note: steps 4,5, and 6 may be done repeatedly, in any order. However, see related method documentation for info on concurrent use. For step 7, see the documentation for the encodeSamples(...) methods' "end" parameter)
Constructor Summary | |
---|---|
FLACEncoder()
Constructor which creates a new encoder object with the default settings. |
Method Summary | |
---|---|
boolean |
addSamples(int[] samples,
int count)
Add samples to the encoder, so they may then be encoded. |
void |
blockFinished(BlockEncodeRequest ber)
Notify the encoder that a BlockEncodeRequest has finished, and is now ready to be written to file. |
void |
clear()
Clear all samples stored by this object, but not yet encoded. |
int |
encodeSamples(int count,
boolean end)
Attempt to Encode a certain number of samples. |
int |
fullBlockSamplesAvailableToEncode()
Get number of samples which are ready to encode. |
void |
openFLACStream()
Begin a new FLAC stream. |
int |
samplesAvailableToEncode()
Get number of samples that are available to encode. |
boolean |
setEncodingConfiguration(EncodingConfiguration ec)
Set the encoding configuration to that specified. |
void |
setOutputStream(FLACOutputStream fos)
Set the output stream to use. |
boolean |
setStreamConfiguration(StreamConfiguration sc)
Set the stream configuration to that specified. |
int |
t_encodeSamples(int count,
boolean end)
Attempt to Encode a certain number of samples(threaded version). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FLACEncoder()
Method Detail |
---|
public boolean setEncodingConfiguration(EncodingConfiguration ec)
ec
- EncodingConfiguration to use.
public boolean setStreamConfiguration(StreamConfiguration sc)
sc
- StreamConfiguration to use.
public void clear()
public void openFLACStream() throws java.io.IOException
java.io.IOException
- if there is an error writing the headers to output.public boolean addSamples(int[] samples, int count)
samples
- Array holding the samples to encode. For all multi-channel
audio, the samples must be interleaved in this array. For example, with
stereo: sample 0 will belong to the first channel, 1 the second, 2 the
first, 3 the second, etc. Samples are interpreted according to the
current configuration(for things such as channel and bits-per-sample).count
- Number of interchannel samples to add. For example, with
stero: if this is 4000, then "samples" must contain 4000 left samples and
4000 right samples, interleaved in the array.
public void blockFinished(BlockEncodeRequest ber)
ber
- BlockEncodeRequest that is ready to write to file.public int t_encodeSamples(int count, boolean end) throws java.io.IOException
count
- number of samples to attempt to encode. Actual number
encoded may be greater or less if count does not end on a block boundary.end
- true to finalize stream after encode, false otherwise. If set
to true, and return value is greater than or equal to given count, no
more encoding must be attempted until a new stream is began.
java.io.IOException
- if there was an error writing the results to file.public int encodeSamples(int count, boolean end) throws java.io.IOException
count
- number of samples to attempt to encode. Actual number
encoded may be greater or less if count does not end on a block boundary.end
- true to finalize stream after encode, false otherwise. If set
to true, and return value is greater than or equal to given count, no
more encoding must be attempted until a new stream is began.
java.io.IOException
- if there was an error writing the results to file.public int fullBlockSamplesAvailableToEncode()
public int samplesAvailableToEncode()
public void setOutputStream(FLACOutputStream fos)
fos
- output stream to use. This must not be null.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |