BASS.NET API for the Un4seen BASS Audio Library

BassCdBASS_CD_GetTrackPregap Method

BASS.NET API for the Un4seen BASS Audio Library
Retrieves the pregap length (in bytes) of a track.

Namespace:  Un4seen.Bass.AddOn.Cd
Assembly:  Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax

[DllImportAttribute("basscd")]
public static int BASS_CD_GetTrackPregap(
	int drive,
	int track
)

Parameters

drive
Type: SystemInt32
The drive... 0 = the first drive.
track
Type: SystemInt32
The track to retrieve the pregap length of... 0 = the first track.

Return Value

Type: Int32
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.
Remarks

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

A track's pregap is actually played as part of the preceeding 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 doesn't have to - it could contain crowd noise in a live recording, for example.

ERROR CODEDescription
BASS_ERROR_DEVICEdrive is invalid.
BASS_ERROR_NOCDThere's 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.

Examples

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

Reference