BASS.dll and BPMs

Blitz3D Forums/Blitz3D Userlibs/BASS.dll and BPMs

Hello! Flame here!

Been awhile since I last posted here, and I come back with a rather odd question/problem. Hopefully it's a simple one that can be easily fixed.

I am busy working on a game that uses BPMs of the background music to create enemies in a sort of shooter game. I knew right away I'd need to use BASS to get the job done, and after looking around, I found out my function I need is BASS_FX_BPM_DecodeGet. After finding the parameters needed, I came up with this in the main loop:
thesize# = BASS_ChannelBytes2Seconds#(music, BASS_ChannelGetLength(music))
duh = BASS_FX_BPM_DecodeGet(music, 0, thesize#, 0, 2, BASS_NULL)

The music handler is done by such:
music = BASS_StreamCreateFile(0,"media\free.mp3",0,0,BASS_STREAM_DECODE)
BASS_ChannelPlay(music,BASS_TRUE)

This is using a modified demo_stream.bb script from the a Bass.dll source that included many examples and userlibs (I think this is the 2.1 one or something), but upon running it, I get a MAV on BASS_FX_BPM_DecodeGet.
My question is: What am I doing wrong?
Source:
Include "includes\bass.bb"
Include "includes\bass_fx.bb"

Timer=CreateTimer (60)
Graphics 640,480,0,2
SetBuffer BackBuffer()

error = BASS_Init(-1,44100,0,0,BASS_NULL)
If error <> 1 Then RuntimeError(error)

Global music
;music = BASS_StreamCreateFile(0,"media\Darwinia - Pain Fading Down.mp3",0,0,BASS_MUSIC_FLOAT)
music = BASS_StreamCreateFile(0,"media\free.mp3",0,0,BASS_STREAM_DECODE)
BASS_ChannelPlay(music,BASS_TRUE)
While Not KeyHit (1)
Color 255,255,255
Cls

Text 0,0,"Bass Stream demo"

version = BASS_GetVersion()
Text 0,20,"Bass version : " +Hex$(version)

cpu# = BASS_GetCPU()
Text 0,30,"CPU time : "+cpu+"%"

device$ = BASS_GetDeviceDescriptionString(1)
Text 0,40,"First (real) device : "+device

devid = BASS_GetDevice()
Text 0,50,"Device id : "+devid

 mvolume = BASS_GetVolume()
 Text 0,60,"Master Volume : " +mvolume
 
pos = BASS_ChannelGetPosition(music)
Text 0,80, "Stream position : "+pos
Text 300,80,"Seconds: "+BASS_ChannelBytes2Seconds(music,pos)
Text 300,100,BASS_ChannelBytes2Seconds(music,pos)/pos
Text 0,100, "Hit 8 to jump to position 3000000"
If KeyHit (9) Then BASS_ChannelSetPosition(music,3000000)

vumono = BASS_ChannelGetLevel (music)
vuleft = BASS_MakeLoWord (vumono)
vuright = BASS_MakeHiWord (vumono)
Color Rand(0,255),Rand(0,255),Rand(0,255)
Text 0,170,"Left channel : "+vuleft
Rect 0,200,vuleft/52,20,1
Rect 0,240,vuright/52,20,1
Text 0,270,"Right channel : "+vuright
thesize# = BASS_ChannelBytes2Seconds#(music, BASS_ChannelGetLength(music))
If KeyHit(57) Then duh = BASS_FX_BPM_DecodeGet(music, 0, thesize#, 0, 2, BASS_NULL)
Text 0,150,"Power: "+duh


DrawFFT(100)

WaitTimer Timer 
Flip 0
Wend
BASS_Free()
End


Function DrawFFT(coloring)
	sdbank = CreateBank(2048*4)
	duh=BASS_ChannelGetData(music,sdbank,BASS_DATA_FFT1024)

	For a = 0 To 512 Step 8
		fftd# = PeekFloat(sdbank,a)
		fftd2# = PeekFloat(sdbank,(a) + 4)
		fftd# = Sqr((fftd#))*3*100
		fftd2# = Sqr((fftd2#))*3*100
		fftd# = (fftd# + fftd2#)/2
		Color coloring,0,coloring
		Rect a/2,480-fftd#,4,fftd#
		;Line 50+a,(GraphicsHeight() / 2) - (fftd# * (GraphicsHeight() * 1.5))+200,50+a+4,(GraphicsHeight() / 2) - (fftd2# * (GraphicsHeight() * 1.5))+200
	Next
	Color 255,255,255
	FreeBank sdbank
End Function

;~IDEal Editor Parameters:
;~C#Blitz3D


If you have a MAV....nothing.....with the bass.dll. Bass can not produce a MAV in the BB compiler. ;)

But, if you have time, i take a look at the rest this weekend.

cu

Hi, works fine here. simple & debug compile

Make shure that you use the right bass version. 2.3.0.3.
(look into your windows/system32 folder if there is an older one , if yes, deltete it/Make shure that you use DLLS/DECLS and INCLUDES of the lattest download (see my signature))

Btw..nice function ;)

bye

Edit: next update will have a BASS_InitCallVersionError function ^^

I got a MAV by asking Blitz to link to the wrong bass.dll (see other thread). Also running compile actually rebooted my machine a couple of times!

Now I have all the latest dll's, includes etc, no prooblem.
Thanks Abrexxes.

Hi, John

Yes, if you have somewhere the old CALLDLL libs you can have a MAV and crashes. But my version of bass can only return 0 and not cause a crash.
The only case is if you try to return values in a blitzbank. But that is always a problem of the bb code.

Nice to hear that your problems are solwed.

bye

Yeah Abrexxes - solid as a rock now.
See the 'bass.dll + 3D?' thread for the results.

Yea, I am sure I used the latest one (had downloaded it from your link 4 days before attempting this). I just checked the versions and the version matches what was stated, but I didn't install the DLL into the system32 (because it seems to play without any problem, it's just this one function). After doing so, I still cannot get it to run at all. I have both bass.dll and bass_fx.dll in the userlibs, and even after compiling into exe and running it in a folder (with the dlls in the folder btw), it still fails with MAV. My system is Windows XP Home on a Dell Laptop Inspiron 1300 if that helps.

EDIT: Is it possibly because I'm using B3D?

EDIT: Is it possibly because I'm using B3D?


1.98 or 1.99? No.

hmm....sorry.. no idea