javaFlacEncoder
Class LPC

java.lang.Object
  extended by javaFlacEncoder.LPC

public class LPC
extends java.lang.Object

This class is used to calculate LPC Coefficients for a FLAC stream.

Author:
Preston Lacey

Field Summary
protected  int order
          The order of this LPC calculation
protected  double[] rawCoefficients
          The coefficients as calculated by the LPC algorithm
protected  double rawError
          The error calculated by the LPC algorithm
 
Constructor Summary
LPC(int order)
          Constructor creates an LPC object of the given order.
 
Method Summary
static void calculate(LPC lpc, long[] R)
          Calculate an LPC using the given Auto-correlation data.
static void calculateFromPrior(LPC lpc, long[] R, LPC priorLPC)
          Calculate an LPC using a prior order LPC's values to save calculations.
static void createAutoCorrelation(long[] R, int[] samples, int count, int start, int increment, int maxOrder)
          Create auto-correlation coefficients(up to a maxOrder of 32).
 double[] getCoefficients()
          Get the calculated LPC Coefficients as an array.
 double getError()
          Get the error for this LPC calculation
 int getOrder()
          Get this LPC object's order
static void window(int[] samples, int count, int start, int increment, int[] windowedSamples)
          Apply a window function to sample data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rawError

protected double rawError
The error calculated by the LPC algorithm


rawCoefficients

protected double[] rawCoefficients
The coefficients as calculated by the LPC algorithm


order

protected int order
The order of this LPC calculation

Constructor Detail

LPC

public LPC(int order)
Constructor creates an LPC object of the given order.

Parameters:
order - Order for this LPC calculation.
Method Detail

getOrder

public int getOrder()
Get this LPC object's order

Returns:
order used for this LPC calculation.

getError

public double getError()
Get the error for this LPC calculation

Returns:
lpc error

getCoefficients

public double[] getCoefficients()
Get the calculated LPC Coefficients as an array.

Returns:
lpc coefficients in an array.

calculate

public static void calculate(LPC lpc,
                             long[] R)
Calculate an LPC using the given Auto-correlation data. Static method used since this is slightly faster than a more strictly object-oriented approach.

Parameters:
lpc - LPC to calculate
R - Autocorrelation data to use

calculateFromPrior

public static void calculateFromPrior(LPC lpc,
                                      long[] R,
                                      LPC priorLPC)
Calculate an LPC using a prior order LPC's values to save calculations.

Parameters:
lpc - LPC to calculate
R - Auto-correlation data to use.
priorLPC - Prior order LPC to use(may be any order lower than our target LPC)

createAutoCorrelation

public static void createAutoCorrelation(long[] R,
                                         int[] samples,
                                         int count,
                                         int start,
                                         int increment,
                                         int maxOrder)
Create auto-correlation coefficients(up to a maxOrder of 32).

Parameters:
R - Array to put results in.
samples - Samples to calculate the auto-correlation for.
count - number of samples to use
start - index of samples array to start at
increment - number of indices to increment between valid samples(for interleaved arrays)
maxOrder - maximum order to calculate.

window

public static void window(int[] samples,
                          int count,
                          int start,
                          int increment,
                          int[] windowedSamples)
Apply a window function to sample data

Parameters:
samples - Samples to apply window to. Values in this array are left unaltered.
count - number of samples to use
start - index of samples array to start at
increment - number of indices to increment between valid samples(for interleaved arrays)
windowedSamples - array containing windowed values. Return values are packed(increment of one).