User defined callback function, to get the Beat position in seconds.
void CALLBACK yourBpmBeatProc( |
Parameters
chan | Channel handle that the BASS_FX_BPM_BeatCallbackSet or BASS_FX_BPM_BeatDecodeGet has applied to |
beatpos | The exact beat position in seconds |
user | The user instance data given when BASS_FX_BPM_BeatCallbackSet or BASS_FX_BPM_BeatDecodeGet was called |
Remarks
To filter out false beat positions, users first will have
to find a BPM of a song, using one of the BPM detection functions, e.g: BASS_FX_BPM_DecodeGet
When you know the BPM, you can calculate the approximate
duration that should be between beat positions, e.g:
stream_length = 330 seconds (5 minutes 30 seconds)
stream_bpm
= 140 (beats per minute)
duration_between_beats = stream_bpm / stream_length
= 140 / 330 = 0.4242 sec
If beat position returned by callback
functions doesn't fit in duration_between_beats, then it's probably some
harmonic sound or a false beat, so you can ignore it.
That way you
can also detect and map
all beats, including the 1st one.
Examples
A very simple way to count the BPM in real-time, using only 2 beats.
double prevBeatPos = 0.0f; // previous beat
position in seconds void CALLBACK BeatProcGetBPM(DWORD handle, double beatpos, void
*user) |
Get the detection progress in percents:
float progress = 100.f * (beatpos - startpos) / (endpos - startpos); |
See also
BASS_FX_BPM_BeatCallbackSet,
BASS_FX_BPM_BeatDecodeGet