BASS.NET API for the Un4seen BASS Audio LibraryBassBASS_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.12.0
Syntax

[DllImportAttribute("bass.dll", CharSet = CharSet.Unicode)]
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:
VB
' length in bytes
Dim len As Long = Bass.BASS_ChannelGetLength(channel)
' position in bytes
Dim pos As Long = Bass.BASS_ChannelGetPosition(channel)
' the total time length
Dim totaltime As Double = Bass.BASS_ChannelBytes2Seconds(channel, len)
' the elapsed time length
Dim elapsedtime As Double = Bass.BASS_ChannelBytes2Seconds(channel, pos)
Dim remainingtime As Double = totaltime - elapsedtime
// 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