WMENCODEPROC callback

Encoded data processing callback function.

void CALLBACK WMEncodeProc(
    HWMENCODE handle,
    DWORD type,
    const void *buffer,
    DWORD length,
    void *user
);

Parameters

handleThe encoder handle.
typeThe type of data to process, one of the following.
BASS_WMA_ENCODE_HEADThe data is the header.
BASS_WMA_ENCODE_DATAThe data is encoded sample data.
BASS_WMA_ENCODE_DONEThe encoding has finished... buffer and length will both be 0.
bufferA pointer to the data to process.
lengthThe length of the data.
userThe user instance data given when BASS_WMA_EncodeOpen was called.

Remarks

When encoding begins, an initial header is given. When encoding is completed, an updated header is given (with the duration info, etc). When encoding to a file (whether that is on disk or not), the initial header should be replaced by the updated one.

Example

A callback function to encode to a file.
void CALLBACK MyWMEncodeProc(HWMENCODE handle, DWORD type, const void *buffer, DWORD length, void *user)
{
    if (type==BASS_WMA_ENCODE_HEAD) {
        fseek(user, 0, SEEK_SET); // rewind to start of file
        fwrite(buffer, length, 1, user); // write the header
    } else if (type==BASS_WMA_ENCODE_DATA)
        fwrite(buffer, length, 1, user); // write encoded data
    else if (type==BASS_WMA_ENCODE_DONE)
        fclose(user); // done encoding - close the file
}
...
FILE *file=fopen("a_file.wma", "wb"); // created the file
BASS_WMA_EncodeOpen(44100, 2, 0, 64000, &MyWMEncodeProc, file); // create the encoder

NOTE: This is just an example. It is simpler to use BASS_WMA_EncodeOpenFile to encode to a file.

See also

BASS_WMA_EncodeOpen