Retrieves the pregap length (in bytes) of a track.

DWORD BASS_CD_GetTrackPregap(
    DWORD drive,
    DWORD track


driveThe drive... 0 = the first drive.
trackThe track to retrieve the pregap length of... 0 = the first track.

Return value

If an error occurs, -1 is returned, use BASS_ErrorGetCode to get the error code. If successful, the pregap length of the track is returned. To translate the pregap length from bytes to frames, divide by 2352.

Error codes

BASS_ERROR_DEVICEdrive is invalid.
BASS_ERROR_NOCDThere is no CD in the drive.
BASS_ERROR_CDTRACKThe track number is invalid.
BASS_ERROR_NOTAUDIOThe track is not an audio track.
BASS_ERROR_NOTAVAILReading sub-channel data is not supported by the drive.


The drive needs to support sub-channel reading in order to detect all but the first pregap length. BASS_CD_GetInfo can be used to check whether the drive can read sub-channel data.

A track's pregap is actually played as part of the preceding track. So to remove the gap from the end of a track, you would get the pregap length of the following track. The gap will usually contain silence, but it does not have to; it could contain crowd noise in a live recording, for example.


Get the length of track 1 minus the ending gap (pregap of track 2).
DWORD len = BASS_CD_GetTrackLength(0, 0); // get first track length
len -= BASS_CD_GetTrackPregap(0, 1); // subtract the ending gap

See also

BASS_CD_GetTrackLength, BASS_CD_GetTracks