0
0

hi there!

has anybody tried to code a BPM Counter (of mp3 stream) in vb with the FSOUND_DSP_GetSpectrum function?

here is a quick and dirty (and not really working) solution:

‘……………..
Public Function GetSpectrum(ByRef Spectrum() As Single)

Dim nrOfVals As Long, lpSpectrum As Long
If UBound(Spectrum) > 511 Then nrOfVals = 512 Else nrOfVals = UBound(Spectrum) + 1
lpSpectrum = FSOUND_DSP_GetSpectrum
CopyMemory Spectrum(0), ByVal lpSpectrum, nrOfVals * 4

End Function
‘……
‘ the BPM Counter.-part
‘………
Dim SpectralData(300) As Single
GetSpectrum SpectralData
realdata= SpectralData(0) * FSOUND_GetVolume(MChannel2) / 255
If realdata > 0.8 Then
If Abs(MerkBPMLast – realdata) > 0.1 Then
MerkBPMLast = realdata
MerkBPM = MerkBPM + 1
end if
end if

‘**************
Part1: spectraldata has to fixed (low value for low volume)
Part2: Sectraldata(0) : is this the value for to lowest frequency ? (base)
Part3: values are between 0 and 1, so i noticed >0.8 is quit good
Part4: count only, if we notice a difference of more than 0.1

‘*************+

the result is quit good for some mp3 files, but somtimes its not wirking
i think spectraldata(0) is not the right way, and also the 0.8 and 0.1 seems not to be a good way.

any other solutions ?

thx,
Thomas.
[url:1lsj0hpd]http://www.mp3observer.com[/url:1lsj0hpd]

  • You must to post comments
0
0

Hmmm, interesting code but why do you use only one element of the spectrum data when you initialized it with 300 elements??? If you are only using one element (element 0) than you should initialize it as so. Also, I suggest taking the first, maybe, 5 elements and averaging them. Im assuming you did this to get the most bass since the majority of the bass comes in the first few bars of the spectrum. This code wont work too good because their can still be a beat change but not be over 0.8, do you know what I mean?? Real BPM calculation is way complex, but I think someone on this board has a working BPM ticker for MP3’s you might search around for it.

  • You must to post comments
0
0

To do it properly you would probably need to look at a chunk of data, a small sample perhaps, once u have the sample its just a matter of compairing high values and counting them over samples playtime then multipling by the measure of sample to make it 1 minute. To do it real time u would have to keep doing this for each sample played but you get the tpoint.

I believe there is some code for this somewhere on the fourms.

++Cire.

  • You must to post comments
0
0

have a look here for good BPM detection and BEAT MATCHING !

http://www.owlnet.rice.edu/~elec301/Pro … round.html

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.