BASS.NET API for the Un4seen BASS Audio LibraryBassFxBASS_FX_BPM_BeatSetParameters Method BASS.NET API for the Un4seen BASS Audio Library
Set new values for beat detection parameters.

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

public static bool BASS_FX_BPM_BeatSetParameters(
	int handle,
	float bandwidth,
	float centerfreq,
	float beat_rtime


Type: SystemInt32
Stream/music/wma/cd/any other supported add-on format.
Type: SystemSingle
Bandwidth in Hz between 0 and samplerate/2 (-1.0f = leave current, default is 10Hz).
Type: SystemSingle
The center-frequency in Hz of the band pass filter between 0 and samplerate/2 (-1.0f = leave current, default is 90Hz).
Type: SystemSingle
Beat release time in ms. (-1.0f = leave current, default is 20ms).

Return Value

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

Beat detection is using a Band Pass Filter. A band-pass filter is a device that passes frequencies within a certain range and rejects (attenuates) frequencies outside that range. So the bandwidth parameter defines the range around a center-frequency to include in the beat detection algo. The centerfreq parameter actually defines the center-frequency of the band pass filter. Once a beat is detected, the beat_rtime parameter defines the time in ms. in which no other beat will be detected after that just detected beat. The background is, that often you have kind-of 'double beats' in a drum set. So the beat_rtime should avoid, that a second (quickly repeated beat) beat is detected.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not valid.


Get all the beat positions of the first minute of a track:
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)
BassFx.BASS_FX_BPM_BeatSetParameters(stream, 20F, 240F, 24F)
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);
BassFx.BASS_FX_BPM_BeatSetParameters(stream, 20f, 110f, 24f);
Bass.BASS_ChannelPlay(stream, false);
private void MyBeatProc(int channel, double beatpos, IntPtr user)
  Console.WriteLine("Beat at: {0}", beatpos);
See Also