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

HENCODE BASS_Encode_StartCAFile(
    DWORD handle,
    DWORD ftype,
    DWORD atype,
    DWORD flags,
    DWORD bitrate,
    char *file


handleThe channel handle... a HSTREAM, HMUSIC, or HRECORD.
ftypeFile format identifier.
atypeAudio data format identifier.
flagsA combination of these flags.
Convert floating-point sample data to 8/16/24/32 bit integer before encoding. These flags are ignored if the channel is not floating-point and the BASS_CONFIG_FLOATDSP option is not enabled.
BASS_ENCODE_MONOConvert to mono before encoding.
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 in a paused state.
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.
bitrateThe bitrate in bits per second... 0 = the codec's default bitrate.
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_FILEFORMftype is not valid.
BASS_ERROR_CODECatype is not valid or supported with ftype.
BASS_ERROR_NOTAVAILbitrate is not supported by the codec.
BASS_ERROR_FORMATThe channel's sample format is not supported by the codec.
BASS_ERROR_CREATEThe file could not be created.
BASS_ERROR_UNKNOWNSome other mystery problem!


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


This function is only available on OSX and iOS.


Start encoding a channel to an ALAC file (output.m4a).
BASS_Encode_StartCAFile(channel, 'm4af', 'alac', 0, 0, "output.m4a");
BASS_ChannelPlay(channel, 0); // start the channel playing & encoding 

Start encoding a channel to a 128 kb/s AAC MP4 file (output.mp4).

BASS_Encode_StartCAFile(channel, 'mp4f', 'aac ', 0, 128000, "output.mp4");
BASS_ChannelPlay(channel, 0); // start the channel playing & encoding 

See also

BASS_Encode_GetACMFormat, BASS_Encode_IsActive, BASS_Encode_SetPaused, BASS_Encode_Start, BASS_Encode_StartCA, BASS_Encode_Stop, BASS_Encode_Write, BASS_CONFIG_ENCODE_PRIORITY