BASS.NET API for the Un4seen BASS Audio LibraryBassFxBASS_FX_BPM_BeatCallbackSet Method BASS.NET API for the Un4seen BASS Audio Library
Enable getting Beat position in seconds in real-time.

Namespace: Un4seen.Bass.AddOn.Fx
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.12.0
Syntax

[DllImportAttribute("bass_fx.dll", CharSet = CharSet.Unicode)]
public static bool BASS_FX_BPM_BeatCallbackSet(
	int handle,
	BPMBEATPROC proc,
	IntPtr user
)

Parameters

handle
Type: SystemInt32
Stream/music/wma/cd/any other supported add-on format.
proc
Type: Un4seen.Bass.AddOn.FxBPMBEATPROC
User defined function to receive the beat position values (see BPMBEATPROC).
user
Type: SystemIntPtr
User instance data to pass to the callback function.

Return Value

Type: Boolean
If successful, is returned, else is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

This method works on real-time (buffered) as well as on decoding channels and might also be used together with Tempo channels.

BASS_FX_BPM_BeatFree(Int32) must be called at the end to free the real-time beat position callback and resources.

Note: You should call BASS_FX_BPM_BeatCallbackReset(Int32) after you have changed the position of the stream when called from a "mixtime" SYNCPROC.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not valid.

Examples

Get all the beat positions of the first minute of a track:
VB
Private _beatProc As BPMBEATPROC
...
Dim stream As Integer = Bass.BASS_StreamCreateFile("test.mp3", 0L, 0L, BASSFlag.BASS_DEFAULT)
_beatProc = New BPMBEATPROC(AddressOf MyBeatProc)
BassFx.BASS_FX_BPM_BeatCallbackSet(stream, _beatProc, IntPtr.Zero)
Bass.BASS_ChannelPlay(stream, False)
...
Private Sub MyBeatProc(channel As Integer, beatpos As Double, user As IntPtr)
  Console.WriteLine("Beat at: {0}", beatpos)
End Sub
private BPMBEATPROC _beatProc;
...
int stream = Bass.BASS_StreamCreateFile("test.mp3", 0L, 0L, BASSFlag.BASS_DEFAULT);
_beatProc = new BPMBEATPROC(MyBeatProc);
BassFx.BASS_FX_BPM_BeatCallbackSet(stream, _beatProc, IntPtr.Zero);
Bass.BASS_ChannelPlay(stream, false);
...
private void MyBeatProc(int channel, double beatpos, IntPtr user)
{
  Console.WriteLine("Beat at: {0}", beatpos);
}
See Also

Reference