FMOD troubles...

BlitzMax Forums/BlitzMax Beginners Area/FMOD troubles...

TeaVirus(Posted 2005) [#1]
I'm having some problems getting FMOD working properly. If I call FSOUND_Init() in a program I start having various array indexing errors. For example, when I execute the following:
Strict

Graphics 800,600,0

If Not FSOUND_Init(44100,32,0)
	Print FMOD_ErrorString(FSOUND_GetError())
	End
EndIf
Print "FMOD initialized."

Local btn64:tImage=LoadImage("64x64.png")

While Not KeyHit(KEY_ESCAPE)
	Cls	

	DrawImage btn64,GraphicsWidth()-64,0

	FlushMem
	Flip
Wend
End

I get an error telling me that I'm trying to index an array out of bounds. Upon inspecting the debugger I can see that DrawImage thinks that it needs to draw frame 736! This also happens to be the x coordinate (something is getting scrambled). If I comment out the lines that initialize FMOD the code runs as expected. I've also tried using bass.dll in the same way and have similar results. I've been staring at this problem for hours and have no idea what I could be doing wrong. If anyone feels like taking a stab at this you can download the mod that I started and all other needed files here:

http://www.evillink.net/FMOD.zip

Any help would be greatly appreciated!


Mark1nc(Posted 2005) [#2]
I was having similar problems with using the BASS sound system. Could be down to how you are declaring your function calls to the FMOD lib.

This works:

Local dll:Int = LoadLibraryA("bass.dll") 
Local addr:Int = Int(GetProcAddress(dll,"BASS_Init"))
Global BASS_Init%(device:Int, freq:Int, flags:Int, win:Int, clsid:Int) "win32" 
(Int Ptr(Varptr(BASS_Init)))[0]=addr 

But when I omitted the "win32" reference, all hell broke loose.


TeaVirus(Posted 2005) [#3]
Mark1nc, thanks for the reply.

I'm doing this a bit differently (not using LoadLibraryA()) but you're suggestion fixed the problem!! I've added "win32" to my mod like this:
Module teavirus.fmod

Import "libfmod.a"

Extern "win32"
	Function FSOUND_Init( mixrate,maxsoftwarechannels,flags ) = "FSOUND_Init@12"
	Function FSOUND_Close() = "FSOUND_Close@0"
	Function FSOUND_File_SetCallbacks( useropen,userclose,userread,userseek,usertell ) = "FSOUND_File_SetCallbacks@20"
	Function FSOUND_SetBufferSize( len_ms ) = "FSOUND_SetBufferSize@4"
	Function FSOUND_SetDriver( driver ) = "FSOUND_SetDriver@4"
	Function FSOUND_SetHWND( hwnd:Byte Ptr ) = "FSOUND_SetHWND@4"
	Function FSOUND_SetMaxHardwareChannels( maxchn ) = "FSOUND_SetMaxHardwareChannels@4"
	Function FSOUND_SetMemorySystem( poolmem:Byte Ptr,poollen,useralloc,userrealloc,userfree ) = "FSOUND_SetMemorySystem@20"
	Function FSOUND_SetMinHardwareChannels( minchn ) = "FSOUND_SetMinHardwareChannels@4"
	Function FSOUND_SetMixer( mixer ) = "FSOUND_SetMixer@4"
	Function FSOUND_SetOutput( outputtype ) = "FSOUND_SetOutput@4"

	Function FSOUND_Update() = "FSOUND_Update@0"

	Function FSOUND_GetVersion:Float() = "FSOUND_GetVersion@0"
	Function FSOUND_GetError() = "FSOUND_GetError@0"
EndExtern

and it appears to be working properly now. Thanks for your help!