BASS.NET API for the Un4seen BASS Audio LibraryBassFxBASS_FX_BPM_CallbackSet Method BASS.NET API for the Un4seen BASS Audio Library
Enable getting BPM value by period of time in seconds.

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_CallbackSet(
	int handle,
	BPMPROC proc,
	double period,
	int minMaxBPM,
	BASSFXBpm flags,
	IntPtr user
)

Parameters

handle
Type: SystemInt32
Stream/music/wma/cd/any other supported add-on format.
proc
Type: Un4seen.Bass.AddOn.FxBPMPROC
User defined function to receive the bpm value (see BPMPROC).
period
Type: SystemDouble
Detection period in seconds.
minMaxBPM
Type: SystemInt32
Set min & max bpm, e.g: MakeLong(Int16, Int16)(LowWord, HighWord), LowWord=Min, HighWord=Max. 0 = defaults to 45/230.
flags
Type: Un4seen.Bass.AddOn.FxBASSFXBpm
Use one of the following (see BASSFXBpm):
BASS_FX_BPM_MULT2If in use, then the detected BPM will be automatically multiplied by 2 if (BPM < minBPM*2) - recommended setting.
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

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_ILLPARAMAn illegal parameter was specified.
BASS_ERROR_ALREADYBASS_FX_BPM_TRAN_X2 already used on this handle.

Examples

Getting BPM values in periods of 10 seconds:
VB
Private _bpmProc As BPMPROC
...
Dim stream As Integer = Bass.BASS_StreamCreateFile("test.mp3", 0L, 0L, BASSFlag.BASS_STREAM_DECODE)
_bpmProc = New BPMPROC(MyBPMProc)
BassFx.BASS_FX_BPM_CallbackSet(stream, _bpmProc, 10.0, Utils.MakeLong(45, 240), 
                               BASSFXBpm.BASS_FX_BPM_MULT2, IntPtr.Zero)
...
Private Sub MyBPMProc(handle As Integer, bpm As Single, user As IntPtr)
  Console.Write("BPM: {0}" + ControlChars.Cr, bpm)
End Sub
private BPMPROC _bpmProc;
...
int stream = Bass.BASS_StreamCreateFile("test.mp3", 0L, 0L, BASSFlag.BASS_STREAM_DECODE);
_bpmProc = new BPMPROC(MyBPMProc);
BassFx.BASS_FX_BPM_CallbackSet(stream, _bpmProc, 10.0, Utils.MakeLong(45,240), 
                               BASSFXBpm.BASS_FX_BPM_MULT2, IntPtr.Zero);
...
private void MyBPMProc(int handle, float bpm, IntPtr user)
{
  Console.Write("BPM: {0}\r", bpm);
}
See Also

Reference