Jump to content

Fmod.dll And AutoIt


jpam
 Share

Recommended Posts

i missed something , but i can't find the clue !

loading mod files from harddisk works fine ,

but i am trying to load from memory, and i get a handle back from the call but allso an error -3

-3 means (mod failed to open. (file not found, out of memory or other error).

can someone give me a hint ?

From the manual ;

FMUSIC_MODULE * F_API FMUSIC_LoadSongEx(

const char *name_or_data,

int offset,

int length,

unsigned int mode,

const int *samplelist,

int samplelistnum

);

Parameters

name_or_data Name of song or pointer to data containing song to load (if loading from memory and not file). On PlayStation 2 data must be 16 byte aligned if loading from memory.

offset Optional. 0 by default. If > 0, this value is used to specify an offset in a file, so fmod will seek before opening.

length Optional. 0 by default. If > 0, this value is used to specify the length of a memory block when using FSOUND_LOADMEMORY, or it is the length of a file or file segment if the offset parameter is used. On PlayStation 2 this must be 16 byte aligned for memory loading.

mode Mode for opening song. With module files, only FSOUND_LOADMEMORY, FSOUND_NONBLOCKING, FSOUND_LOOP_NORMAL, or FSOUND_LOOP_OFF are supported. For FSB files, FSOUND_2D, FSOUND_HW3D, FSOUND_FORCEMONO also work.

samplelist Optional. Pointer to array of sample indicies to load. Leave as NULL if you want all samples to be loaded (default behaviour). See Remarks for more on this.

samplelistnum Optional. Number of entries in the samplelist array.

Return Value

On success, a FMUSIC_MODULE handle is returned.

On failure, NULL is returned.

Files ;

fmod.dll

http://home.wanadoo.nl/jpamvanderouderaa/fmod.dll

Mod song

http://home.wanadoo.nl/jpamvanderouderaa/aws_dawn.xm

script

$F_DLL = DllOpen("fmod.dll")

FModInit()  

$size = FileGetSize("aws_dawn.xm")
$open = FileOpen("aws_dawn.xm",16)
$fileread = FileRead($open)
$createstruct = DllStructCreate("char["&$size&"]")
DllStructSetData($createstruct,1,$fileread)

$mod = loadModEx(DllStructGetPtr($createstruct,1),$size) ;<= load from memory
Do
    $st = GetOpenState($mod) ; 0 = mod is opened and ready.
                             ; -1 = mod handle passed in is invalid.
                             ; -2 = mod is still opening
                             ; -3 = mod failed to open. (file not found, out of memory or other error).
    ConsoleWrite($st&@CRLF) 
    Sleep(100)
Until $st = 0

;$mod = loadMod("aws_dawn.xm") ;<= Normal fileload

PlayMod($mod)

Func loadModEx($F_Pointer, $F_Size)
    $F_RetValue = DllCall($F_dll, "long", "_FMUSIC_LoadSongEx@24", _
                                  "long", $F_Pointer, _
                                  "long", 0, _
                                  "long", $F_Size, _
                                  "str", 'FSOUND_LOADMEMORY', _
                                  "long", 0, _
                                  "long", 0)
    Return $F_RetValue[0]                             
EndFunc

Func loadMod($F_ModFile)
    $F_RetValue = DllCall($F_dll, "long", "_FMUSIC_LoadSong@4", _
                                  "str" , $F_ModFile)
    Return $F_RetValue[0]
EndFunc

Func PlayMod($F_ModAlias)
    DllCall($F_dll, "long", "_FMUSIC_PlaySong@4", _
                    "long", $F_ModAlias)
EndFunc

Func GetOpenState($F_ModFile)
    $F_State = DllCall($F_dll, "long", "_FMUSIC_GetOpenState@4", _
                               "long", $F_ModFile)
    Return $F_State[0]
EndFunc

Func FModInit() 
    DllCall($F_dll, "long", "_FSOUND_SetBufferSize@4", _
                    "long", 200)
    DllCall($F_dll, "long", "_FSOUND_Init@12", _
                    "long", 44100, _
                    "long", 32, _
                    "long", 0x0001)
EndFunc

While 1
    Sleep(1000)
WEnd
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...