Sets up an encoder on a channel, using an ACM codec and writing the output to a file.

    DWORD handle,
    void *form,
    DWORD flags,
    char *file


handleThe channel handle... a HSTREAM, HMUSIC, or HRECORD.
formACM codec output format.
flagsA combination of these flags.
BASS_ENCODE_NOHEADDon't write a WAVE header to the file.
BASS_ENCODE_RF64Write an RF64 header instead of a standard RIFF header, allowing the file to go beyond 4GB in size. This flag is ignored if the BASS_ENCODE_NOHEAD flag is used.
BASS_ENCODE_QUEUEQueue data to feed the encoder asynchronously. This prevents the data source (DSP system or BASS_Encode_Write call) getting blocked by the encoder, but if data is queud more quickly than the encoder can process it, that could result in lost data.
BASS_ENCODE_PAUSEStart the encoder paused.
BASS_ENCODE_AUTOFREEAutomatically free the encoder when the source channel is freed. If queuing is enabled, any remaining queued data will be sent to the encoder before it is freed.
BASS_UNICODEfile is a Unicode (UTF-16) filename.
fileThe filename to write.

Return value

The encoder handle is returned if the encoder is successfully started, else 0 is returned. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_NOTAVAILThe codec specified in form couldn't be initialized.
BASS_ERROR_CREATEThe file could not be created.
BASS_ERROR_UNKNOWNSome other mystery problem!


This function is identical to BASS_Encode_StartACM, except that it writes the encoded data to a file instead of a callback function.

Unless the BASS_ENCODE_NOHEAD flag is specified, a WAVE header and the form contents will be written to the file. This is generally required for the file to be playable, but in some cases (eg. MP3) it's not. Standard RIFF WAV files are limited to a little over 4GB in size, so BASSenc will automatically stop encoding at that point. That size limit can be overcome with an RF64 file. When writing an RF64 WAV file, a standard RIFF header will still be written initially, which will only be replaced by an RF64 header at the end if the file size has exceeded the standard limit.


This function is only available on Windows and Windows CE.

See also

BASS_Encode_AddChunk, BASS_Encode_GetACMFormat, BASS_Encode_IsActive, BASS_Encode_SetPaused, BASS_Encode_Start, BASS_Encode_StartACM, BASS_Encode_Stop, BASS_Encode_Write, ENCODEPROC callback, BASS_CONFIG_ENCODE_PRIORITY