BASS.NET API for the Un4seen BASS Audio Library

BassBASS_ChannelBytes2Seconds Method

BASS.NET API for the Un4seen BASS Audio Library
Translates a byte position into time (seconds), based on a channel's format.

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

[DllImportAttribute("bass")]
public static double BASS_ChannelBytes2Seconds(
	int handle,
	long pos
)

Parameters

handle
Type: SystemInt32
The channel handle... a HCHANNEL, HMUSIC, HSTREAM, or HRECORD. HSAMPLE handles may also be used.
pos
Type: SystemInt64
The position in BYTES to translate.

Return Value

Type: Double
If successful, then the translated length in seconds is returned, else a negative value is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

The translation is based on the channel's initial sample rate, when it was created.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not a valid channel.

Examples

Getting the elapsed and remaining time:
// length in bytes
long len = Bass.BASS_ChannelGetLength(channel);
// position in bytes
long pos = Bass.BASS_ChannelGetPosition(channel);
// the total time length
double totaltime = Bass.BASS_ChannelBytes2Seconds(channel, len);
// the elapsed time length
double elapsedtime = Bass.BASS_ChannelBytes2Seconds(channel, pos);
double remainingtime = totaltime - elapsedtime;
See Also

Reference