BASS_Encode_StartCAFile

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 *filename
);

Parameters

handleThe channel handle... a HSTREAM, HMUSIC, or HRECORD.
ftypeFile format identifier.
atypeAudio data format identifier.
flagsA combination of these flags.
BASS_ENCODE_FP_8BIT,
BASS_ENCODE_FP_16BIT,
BASS_ENCODE_FP_24BIT,
BASS_ENCODE_FP_32BIT
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_FP_AUTOConvert floating-point sample data back to the channel's format (8/16 bit integer) if the data is only floating-point due to the BASS_CONFIG_FLOATDSP option being enabled.
BASS_ENCODE_DITHERApply dither (TPDF) when converting floating-point sample data to integer
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_UNICODEfilename is in UTF-16 form. Otherwise it is UTF-8.
bitrateThe bitrate in bits per second... 0 = the codec's default bitrate.
filenameThe output filename.

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_MEMThere is insufficient memory.
BASS_ERROR_UNKNOWNSome other mystery problem!

Remarks

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

Platform-specific

This function is only available on macOS and iOS.

Example

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_GetCARef, BASS_Encode_IsActive, BASS_Encode_SetPaused, BASS_Encode_Start, BASS_Encode_StartCA, BASS_Encode_Stop, BASS_Encode_Write, BASS_CONFIG_ENCODE_PRIORITY