BASS_CD_StreamCreateFile


Creates a sample stream from an audio CD track, using a CDA file on the CD.

HSTREAM BASS_CD_StreamCreateFile(
    char *file,
    DWORD flags
);

Parameters

fileThe CDA filename... for example, "D:\Track01.cda".
flagsAny combination of these flags.
BASS_SAMPLE_FLOATUse 32-bit floating-point sample data. See Floating-point channels for more info.
BASS_SAMPLE_SOFTWAREForce the stream to not use hardware mixing.
BASS_SAMPLE_LOOPLoop the file. This flag can be toggled at any time using BASS_ChannelFlags.
BASS_SAMPLE_FXEnable the old implementation of DirectX 8 effects. See the DX8 effect implementations section for details. Use BASS_ChannelSetFX to add effects to the stream.
BASS_STREAM_AUTOFREEAutomatically free the stream when playback ends.
BASS_STREAM_DECODEDecode the sample data, without playing it. Use BASS_ChannelGetData to retrieve decoded sample data. The BASS_STREAM_AUTOFREE and SPEAKER flags cannot be used together with this flag. The BASS_SAMPLE_SOFTWARE and BASS_SAMPLE_FX flags are also ignored.
BASS_SPEAKER_xxxSpeaker assignment flags.
BASS_CD_SUBCHANNELRead sub-channel data. 96 bytes of de-interleaved sub-channel data will be inserted after each 2352 bytes of audio. This flag cannot be used without the BASS_STREAM_DECODE flag or with the BASS_SAMPLE_FLOAT flag; see BASS_CD_StreamCreateFileEx.
BASS_CD_SUBCHANNEL_NOHWRead sub-channel data, without using any hardware de-interleaving. This is identical to the BASS_CD_SUBCHANNEL flag, except that the de-interleaving is always performed by BASSCD even if the drive is apparently capable of de-interleaving itself.
BASS_CD_C2ERRORSInclude C2 error info. 296 bytes of C2 error info is inserted after each 2352 bytes of audio (and optionally 96 bytes of sub-channel data). The first 294 bytes contain the C2 error bits (one bit for each byte of audio), followed by a byte containing the logical "OR" of all 294 bytes, which can be used to quickly check if there were any C2 errors. The final byte is just padding. This flag cannot be used without the BASS_STREAM_DECODE flag or with the BASS_SAMPLE_FLOAT flag; see BASS_CD_StreamCreateFileEx.
BASS_UNICODEfile is a Unicode (UTF-16) filename.

Return value

If successful, the new stream's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_INITBASS_Init has not been successfully called.
BASS_ERROR_FILEOPENThe file could not be opened.
BASS_ERROR_FILEFORMThe file was not recognised as a CDA file.
BASS_ERROR_DEVICEThe drive could not be found.
BASS_ERROR_ALREADYA stream using this drive already exists.
BASS_ERROR_ILLPARAMThe BASS_CD_SUBCHANNEL and BASS_CD_C2ERRORS flags cannot be used without the BASS_STREAM_DECODE flag or with the BASS_SAMPLE_FLOAT flag. See BASS_CD_StreamCreateFileEx.
BASS_ERROR_NOTAVAILReading sub-channel data and/or C2 error info is not supported by the drive, or a read offset is in effect. In case of the latter, see BASS_CD_StreamCreateFileEx.
BASS_ERROR_FORMATThe sample format is not supported by the device/drivers. If the stream is more than stereo or the BASS_SAMPLE_FLOAT flag is used, it could be that they are not supported.
BASS_ERROR_SPEAKERThe specified SPEAKER flags are invalid. The device/drivers do not support them, they are attempting to assign a stereo stream to a mono speaker or 3D functionality is enabled.
BASS_ERROR_MEMThere is insufficient memory.
BASS_ERROR_UNKNOWNSome other mystery problem!

Remarks

Only one stream can exist at a time per CD drive. If a stream using the drive already exists, this function will fail, unless the BASS_CONFIG_CD_FREEOLD config option is enabled. BASS_CD_StreamSetTrack can be used to change track without creating a new stream.

The sample format of a CD audio stream is always 44100hz stereo 16-bit, unless the BASS_SAMPLE_FLOAT flag is used, in which case it is converted to 32-bit. When reading sub-channel data and/or C2 error info, the sample rate will be increased accordingly, taking the additional data into account.

When reading sub-channel data, BASSCD will automatically de-interleave the data if the drive cannot do it. BASS_CD_GetInfo can be used to check whether the drive can de-interleave the data itself, or even read sub-channel data at all.

Platform-specific

CDA files are a feature of Windows, so this function is only available on the Windows platform.

See also

BASS_CD_GetTracks, BASS_CD_StreamCreate, BASS_CD_StreamCreateFileEx, BASS_CD_StreamSetTrack

BASS_ChannelGetInfo, BASS_ChannelGetLength, BASS_ChannelPlay, BASS_ChannelSetAttribute, BASS_ChannelSetDSP, BASS_ChannelSetFX, BASS_ChannelSetLink, BASS_StreamFree