Beat Per Min and Sample Rate

Started by kgs1951,

kgs1951

Is there a function in Bass to get the BPM and sample rate of an audio file?

Ian @ un4seen

The sample rate is available from BASS_ChannelGetInfo (see the BASS_CHANNELINFO "freq" field). If you're using BASS.Net's BassTags.BASS_TAG_GetFromFile function (as in your other recent thread) then I believe you'll already have that info in the TAG_INFO "channelinfo" field.

BPM detection is available with the BASS_FX add-on's BASS_FX_BPM_DecodeGet or BASS_FX_BPM_CallbackSet function.

kafffee

I tried that as well, but it seems, when I call the function, that track is being fast-fowarded:


CurrentMP3Info.BPM = CInt(Math.Round(BassFx.BASS_FX_BPM_DecodeGet(stream, 0, Bass.BASS_ChannelGetLength(stream, Nothing), 0, BASSFXBpm.BASS_FX_BPM_BKGRND, Nothing, Nothing)))
Is there anything wrong with this? I am trying to call the function when the track is already playing...

Maybe it interferes with my slider that I use to display progress, respectively jump to another position in the track?

Ian @ un4seen

BASS_FX_BPM_DecodeGet will change the stream's position (according to the requested start-end range). To get the BPM during playback, you should use BASS_FX_BPM_CallbackSet instead. You provide it a callback function, which will be called periodically with the current BPM.