lameonj.encoder.std
Interface GenericEncoder

All Superinterfaces:
Encoder

public interface GenericEncoder
extends Encoder

This interface may be used to progressively encode PCM data to MP3.

LAME flags must be set up before starting an encoding task, LAME uses the default configuration and no configuration data (number of channels etc) is extracted from the audio data provided to the encoder, in fact only raw PCM is supposed. Call the Encoder.getEncoderConfig() method to config the encoder.

A complete encoding process does not close the encoder and can be reused. The encoder must be closed explicitly (see Encoder.close()).

The encoding process does not add the VBR Info tag, you can use the method Encoder.writeVbrTag(String)

Note: if you want to encode a WAV file using this interface, skip the WAV header first (skips the first 44 bytes of the file)

See Also:
LAMEOnJStdEncoder.createGenericEncoder()

Method Summary
 int encodeBuffer(byte[] pcmBuffer, int size, byte[] mp3Buffer)
          Encodes a chunk of raw PCM data, if stereo source audio data must be interleaved.
 int encodeFlush(byte[] mp3Buffer)
          Finalizes the encoding task, any remainder MP3 data in the encoder is flushed to the MP3 buffer.
 void initEncoding(int[] pcmBufferSize, int[] mp3BufferSize)
          Starts an encoding process.
 
Methods inherited from interface lameonj.encoder.std.Encoder
close, getEncoderConfig, getLameFlags, isClosed, writeVbrTag
 

Method Detail

initEncoding

void initEncoding(int[] pcmBufferSize,
                  int[] mp3BufferSize)
Starts an encoding process.

The required size of source PCM and target MP3 byte buffers are returned using the first array item of the provided parameters.

Parameters:
pcmBufferSize - the one element array where the required PCM buffer size is saved.
mp3BufferSize - the one element array where the required MP3 buffer size is saved.

encodeBuffer

int encodeBuffer(byte[] pcmBuffer,
                 int size,
                 byte[] mp3Buffer)
Encodes a chunk of raw PCM data, if stereo source audio data must be interleaved.

PCM and MP3 buffers must have the lengths provided by the method initEncoding(int[],int[])

Parameters:
pcmBuffer - the PCM data to encode.
size - the number of bytes with PCM data.
mp3Buffer - the MP3 buffer to fill with the encoded MP3 audio.
Returns:
the number of bytes used to fill the MP3 buffer.

encodeFlush

int encodeFlush(byte[] mp3Buffer)
Finalizes the encoding task, any remainder MP3 data in the encoder is flushed to the MP3 buffer.

Parameters:
mp3Buffer - the MP3 buffer to fill with the encoded MP3 audio.
Returns:
the number of bytes used to fill the MP3 buffer.


Copyright © 2006-2008 Jose Maria Arranz. All Rights Reserved.