LPAC Codec API

Documentation

Version 1.0 (for Codec 3.02 and higher)

© 2001 Tilman Liebchen

Last update: 02.02.2001


What is the LPAC Codec API

The LPAC Codec API (Application Programming Interface) is a simple C interface for the LPAC codec. You can use the functions in your own applications to losslessly encode wave files (*.wav) and store them in the LPAC file format (*.pac) as well as to decode existing LPAC files. There are functions to encode or decode a whole file with only one function call, and there are sets of functions to process files frame by frame.

 

How to use it

Requiered binaries

To run your application the files "lpaccodec.dll" (the codec itself) and "lpac_codec_api.dll" (the C interface) have to be found in the search path.

C (Visual C++)

Simply add the library "lpac_codec_api.lib" to your project and #include the header file "lpac_codec_api.h" into your source code file. Then the DLLs will be loaded automatically when your application is started.

Other Languages

In addition to including the header file "lpac_codec_api.h" you will need to explicitly load the DLL "lpac_codec_api.dll" by a special command in your source code (please refer to the documentation of your programming language). The DLL "lpaccodec.dll" should be loaded automatically when "lpac_codec_api.dll" is loaded.

 

Function description

The following sections describe data structures, encoder functions and decoder functions.

Data structures

typedef struct
{
    short frame, ver, ra, poly, js, ap, aq, res, ch;
    long num, freq, wsize, psize;
}
PACINFO;

The PACINFO structure can hold information about a compressed LPAC file. It is used by DecoderGetInfo and GetPacFileInfo.

Fields

Encoder functions

short EncodeWaveFile(const char *WavName, const char *PacName, short Version, short CompMode, short Joint, short RA);

This function offers a very simple means to losslessly compress a wave file using only one function. Input and Output file are opened and closed internally, so you just have to provide the file names and some coding options.

Parameters

Return values

short EncoderCreate();

Creates an encoder object. Call this function before using any other encoder function.

Return values

short EncoderOpenFiles(const char *WavName, const char *PacName);

Opens input and output file for the encoder. The files have to be specified by their names.

Parameters

Return values

short EncoderCloseFiles();

Closes input and output file after encoding. Call this function before calling EncoderDelete.

Return values

short EncoderSetFiles(FILE *fpWav, FILE *fpPac);

Specifies input and output file for the encoder. The files have to be specified by file pointers after being opened by the calling application.

Parameters

Return values

short EncoderDelete();

Deletes the encoder object. Call this function before creating another encoder object by calling EncoderCreate.

Return values

short EncoderSetVersion(short Version);

Sets the version of the file format to use. Valid file formats are v2/v4 (codec 1.5x), v5 (codec 2.0x), and v6 (codec 3.x). Call this function (if necessary) before calling EncoderSetCompMode, EncodeFile or EncodeHeader.

Parameters

Return values

short EncoderSetCompMode(short CompMode);

Sets the compression mode. Valid modes are 1 (fast), 2 (simple), 3 (medium), 4 (high), and 5 (extra high). Call this function (if necessary) before calling EncodeFile or EncodeHeader.

Parameters

Return values

short EncoderSetJoint(short Joint);

Turns joint stereo coding on/off. Call this function (if necessary) before calling EncodeFile or EncodeHeader.

Parameters

Return values

short EncoderSetRA(short RA);

Turns random access coding on/off. Call this function (if necessary) before calling EncodeFile or EncodeHeader.

Parameters

Return values

short EncodeFile();

Encodes a whole file. This function is equivalent to calling EncodeHeader, EncodeFrame for all frames, and EncodeRemains. Input and output file have to be specified by calling EncoderOpenFiles or EncoderSetFiles before.

Return values

long EncodeHeader();

Checks the wave file to encode and then encodes the header information. Input and output file have to be specified by calling EncoderOpenFiles or EncoderSetFiles before.

Return values

short EncodeFrame();

Encodes a single frame of audio samples. The number of frames to encode for the whole file has to be determined by calling EncodeHeader before.

Return values

short EncodeRemains();

Encodes remaining non-audio parts of the wave file and writes the CRC. Always use this function after encoding the last audio frame.

Return values

Decoder Functions

short DecodePacFile(const char *PacName, const char *WavName);

This function offers a very simple means to decompress a compressed LPAC file using only one function. Input and Output file are opened and closed internally, so you just have to provide the file names.

Parameters

Return values

short DecoderCreate();

Creates an decoder object. Call this function before using any other decoder function.

Return values

short DecoderOpenFiles(const char *PacName, const char *WavName);

Opens input and output file for the decoder. The files have to be specified by their names.

Parameters

Return values

short DecoderCloseFiles();

Closes input and output file after decoding. Call this function before calling EncoderDelete.

Return values

short DecoderSetFiles(FILE *fpPac, FILE *fpWav);

Specifies input and output file for the decoder. The files have to be specified by file pointers after being opened by the calling application.

Parameters

Return values

short DecoderDelete();

Deletes the decoder object. Call this function before creating another decoder object by calling DecoderCreate.

Return values

short DecodeFile();

Decodes a whole file. This function is equivalent to calling DecodeHeader, DecodeFrame for all frames, and DecodeRemains. Input and output file have to be specified by calling DecoderOpenFiles or DecoderSetFiles before.

Return values

long DecodeHeader();

Checks the LPAC file to decode and then decodes the header information. Input and output file have to be specified by calling DecoderOpenFiles or DecoderSetFiles before.

Return values

short DecodeFrame();

Decodes a single frame of audio samples. The number of frames to decode for the whole file has to be determined by calling DecodeHeader before.

Return values

short DecodeRemains();

Decodes remaining non-audio parts of the file and verifies the CRC. Always use this function after decoding the last audio frame.

Return values

short DecoderGetInfo(PACINFO *info);

Retrieves information from the decoder about the currently opened LPAC file. To use this function, you have to call DecodeHeader or DecodeFile first.

Parameters

Return values

const void *DecoderGetAudioBuffer();

Supplies a pointer to the buffer which contains the last frame of decoded audio data. The size of this buffer in bytes as well as information about the audio format can be retrieved by evaluating the PACINFO structure after calling DecoderGetInfo or GetPacFileInfo.

Return values

short GetPacFileInfo(const char *PacName, PACINFO *info);

Retrieves information from a compressed LPAC file without calling any other decoder functions. The file is opened and closed internally.

Parameters

Return values