BASS.NET API for the Un4seen BASS Audio Library

BassFxBASS_FX_BPM_BeatDecodeGet Method

BASS.NET API for the Un4seen BASS Audio Library
Enable getting Beat position in seconds of the decoded channel using a callback function.

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_BeatDecodeGet(
	int channel,
	double startSec,
	double endSec,
	BASSFXBpm flags,
	BPMBEATPROC proc,
	IntPtr user
)

Parameters

channel
Type: SystemInt32
Stream/music/wma/cd/any other supported add-on format using a decoding channel.
startSec
Type: SystemDouble
Start detecting position in seconds.
endSec
Type: SystemDouble
End detecting position in seconds (> 0).
flags
Type: Un4seen.Bass.AddOn.FxBASSFXBpm
Use one of the following (see BASSFXBpm):
BASS_FX_BPM_BKGRNDIf in use, then you can do other stuff while detection's in process.
BASS_FX_FREESOURCEFree the source handle as well?
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 pretty much the same as BASS_FX_BPM_BeatCallbackSet(Int32, BPMBEATPROC, IntPtr) respectivly BASS_FX_BPM_DecodeGet(Int32, Double, Double, Int32, BASSFXBpm, BPMPROGRESSPROC, IntPtr) - it is almost a mix of the two of them.

ERROR CODEDescription
BASS_ERROR_HANDLEchannel is not valid.
BASS_ERROR_DECODEThe channel is not a decoding channel. Make sure the channel was created using the BASS_STREAM_DECODE or BASS_MUSIC_DECODE flag.
BASS_ERROR_ILLPARAMAn illegal parameter was specified.
BASS_ERROR_ALREADYBeat detection, for this channel is already in use.

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_STREAM_DECODE);
_beatProc = new BPMBEATPROC(MyBeatProc);
BassFx.BASS_FX_BPM_BeatDecodeGet(stream, 0.0, 60.0, BASSFXBpm.BASS_FX_BPM_BKGRND, _beatProc, IntPtr.Zero);
BassFx.BASS_FX_BPM_BeatFree(stream);
...
private void MyBeatProc(int channel, double beatpos, IntPtr user)
{
  Console.WriteLine("Beat at: {0}", beatpos);
}
See Also

Reference