BASS.NET API for the Un4seen BASS Audio Library

BassFxBASS_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: 2.4.17.5
Syntax

[DllImportAttribute("bass_fx")]
public static bool BASS_FX_BPM_BeatSetParameters(
	int handle,
	float bandwidth,
	float centerfreq,
	float beat_rtime
)

Parameters

handle
Type: SystemInt32
Stream/music/wma/cd/any other supported add-on format.
bandwidth
Type: SystemSingle
Bandwidth in Hz between 0 and samplerate/2 (-1.0f = leave current, default is 10Hz).
centerfreq
Type: SystemSingle
The center-frequency in Hz of the band pass filter between 0 and samplerate/2 (-1.0f = leave current, default is 90Hz).
beat_rtime
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.
Remarks

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.

Examples

Get all the beat positions of the first minute of a track:
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

Reference