javaFlacEncoder
Class Frame

java.lang.Object
  extended by javaFlacEncoder.Frame

public class Frame
extends java.lang.Object

Handles taking a set of audio samples, and splitting it into the proper subframes, and returning the resulting encoded data. This object will do any calculations needed for preparing the “channel configuration” used in encoding, such as mid-side or left-right(based upon the given configuration).

Author:
Preston Lacey

Field Summary
static int DEBUG_LEV
          For debugging: Higher level equals more output(generally in increments of 10
 
Constructor Summary
Frame(StreamConfiguration sc)
          Constructor.
 
Method Summary
 int encodeSamples_OLD(int[] samples, int count, int start, int skip, EncodedElement result, long frameNumber)
          Encodes samples into the appropriate compressed format, saving the result in the given “data” EncodedElement list.
 int encodeSamples(int[] samples, int count, int start, int skip, EncodedElement result, long frameNumber)
          Encodes samples into the appropriate compressed format, saving the result in the given “data” EncodedElement list.
 int getEncodedSize()
          Returns the total number of valid bits used in the last encoding(i.e, the number of compressed bits used).
 boolean registerConfiguration(EncodingConfiguration ec)
          This method is used to set the encoding configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_LEV

public static int DEBUG_LEV
For debugging: Higher level equals more output(generally in increments of 10

Constructor Detail

Frame

public Frame(StreamConfiguration sc)
Constructor. Sets the StreamConfiguration to use at creation of object. If the StreamConfiguration needs to be changed, you *MUST* create a new Frame object.

Parameters:
sc - StreamConfiguration to use for encoding with this frame.
Method Detail

registerConfiguration

public boolean registerConfiguration(EncodingConfiguration ec)
This method is used to set the encoding configuration. This configuration can be altered throughout the stream, but cannot be called while an encoding process is active.

Parameters:
ec - encoding configuration to use.
Returns:
true if configuration was changed. false otherwise(i.e, and encoding process was active at the time of change)

encodeSamples_OLD

public int encodeSamples_OLD(int[] samples,
                             int count,
                             int start,
                             int skip,
                             EncodedElement result,
                             long frameNumber)
Encodes samples into the appropriate compressed format, saving the result in the given “data” EncodedElement list. Encodes 'count' samples, from index 'start', to index 'start' times 'skip', where “skip” is the format that samples may be packed in an array. For example, 'samples' may include both left and right samples of a stereo stream. Therefore, “skip” would equal 2, resulting in the valid indices for the first channel being even, and second being odd.

Parameters:
samples - the audio samples to encode. This array may contain samples for multiple channels, interleaved; only one of these channels is encoded by a subframe.
count - the number of samples to encode.
start - the index to start at in the array.
skip - the number of indices to skip between successive samples (for use when channels are interleaved in the given array).
data - the EncodedElement to attach encoded data to. Data in Encoded Element given is not altered. New data is attached starting with “data.getNext()”. If “data” already has a “next” set, it will be lost!
Returns:
int Returns the number of inter-channel samples encoded; i.e, if block-size is 4000, and it is stereo audio. There are 8000 samples in this block, but the return value is “4000”. There is always an equal number of samples encoded from each channel. This exists primarily to support dynamic block sizes in the future; Pre-condition: none Post-condition: Argument 'data' is the head of a list containing the resulting, encoded data stream.

encodeSamples

public int encodeSamples(int[] samples,
                         int count,
                         int start,
                         int skip,
                         EncodedElement result,
                         long frameNumber)
Encodes samples into the appropriate compressed format, saving the result in the given “data” EncodedElement list. Encodes 'count' samples, from index 'start', to index 'start' times 'skip', where “skip” is the format that samples may be packed in an array. For example, 'samples' may include both left and right samples of a stereo stream. Therefore, “skip” would equal 2, resulting in the valid indices for the first channel being even, and second being odd.

Parameters:
samples - the audio samples to encode. This array may contain samples for multiple channels, interleaved; only one of these channels is encoded by a subframe.
count - the number of samples to encode.
start - the index to start at in the array.
skip - the number of indices to skip between successive samples (for use when channels are interleaved in the given array).
data - the EncodedElement to attach encoded data to. Data in Encoded Element given is not altered. New data is attached starting with “data.getNext()”. If “data” already has a “next” set, it will be lost!
Returns:
int Returns the number of inter-channel samples encoded; i.e, if block-size is 4000, and it is stereo audio. There are 8000 samples in this block, but the return value is “4000”. There is always an equal number of samples encoded from each channel. This exists primarily to support dynamic block sizes in the future; Pre-condition: none Post-condition: Argument 'data' is the head of a list containing the resulting, encoded data stream.

getEncodedSize

public int getEncodedSize()
Returns the total number of valid bits used in the last encoding(i.e, the number of compressed bits used). This is here for convenience, as the calling object may also loop through the resulting EncodingElement from the encoding process and sum the valid bits.

Returns:
an integer with value of the number of bits used in last encoding. Pre-condition: none Post-condition: none