BASS_Encode_StartPCMFile

Sets up a PCM/WAVE/AIFF encoder on a channel, writing the output to a file.

HENCODE BASS_Encode_StartPCMFile(
    DWORD handle,
    DWORD flags,
    char *filename
);

Parameters

handleThe channel handle... a HSTREAM, HMUSIC, or HRECORD.
flagsA combination of these flags.
BASS_ENCODE_NOHEADDo not write any headers.
BASS_ENCODE_AIFFWrite an AIFF header instead of a WAVE header. This flag is ignored if the BASS_ENCODE_NOHEAD is used.
BASS_ENCODE_RF64Write an RF64 header instead of a standard RIFF header, allowing more than 4GB of sample data. This flag is ignored if the BASS_ENCODE_NOHEAD or BASS_ENCODE_AIFF flags are used.
BASS_ENCODE_WFEXTWrite the sample format information in WAVEFORMATEXTENSIBLE form instead of WAVEFORMATEX form. This flag is ignored if the BASS_ENCODE_NOHEAD or BASS_ENCODE_AIFF flags are used.
BASS_ENCODE_BIGENDWrite big-endian sample data, else little-endian. This flag is ignored unless the BASS_ENCODE_NOHEAD flag is used.
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. 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_QUEUEQueue data to write asynchronously. This prevents the data source (DSP system or BASS_Encode_Write call) getting blocked by the writing, and can improve performance through multithreading, but if data is queued more quickly than the encoder can process it then that could result in lost data.
BASS_ENCODE_QUEUE_WAITThis is the same as BASS_ENCODE_QUEUE except that it will wait for space in the queue rather than drop data (so the data source may get blocked).
BASS_ENCODE_LIMITLimit the processing rate to real-time speed, by introducing a delay when the rate is too high. With BASS 2.4.6 or above, this flag is ignored when the encoder is fed in a playback buffer update cycle (including BASS_Update and BASS_ChannelUpdate calls), to avoid possibly causing playback buffer underruns.
BASS_ENCODE_PAUSEStart the encoder in a paused state.
BASS_ENCODE_AUTOFREEAutomatically free the encoder when the source channel is freed. If it has queued data, the encoder will be freed asynchronously once that has been processed.
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_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_StartPCM, except that it writes the data to a file instead of a callback function.

Example

Start writing a channel to a WAV file (output.wav).
BASS_Encode_StartPCMFile(channel, 0, "output.wav");

See also

BASS_Encode_AddChunk, BASS_Encode_CastInit, BASS_Encode_IsActive, BASS_Encode_ServerInit, BASS_Encode_SetNotify, BASS_Encode_SetPaused, BASS_Encode_Start, BASS_Encode_StartPCM, BASS_Encode_Stop, BASS_Encode_Write, ENCODEPROC callback, BASS_CONFIG_ENCODE_PRIORITY