0
0

Hi all.
I’ve been using BASSMOD for some time, and am interested in trying FMOD. I have used the same system for using FMOD as i used to use on BASSMOD. To prevent any dlls floating around with my app, i put the dll in resources and extract it and load it at runtime. Unfortunately, the first FMOD function i call using the address from GetProcAddress causes the program to crash, regardless of which function was used.
My code is included below (well the important parts anyway), if anyone has any ideas as to why i would really appreciate some help. Thanks a lot.
[code:3lobwf3l]
func1 db "FSOUND_SetOutput",0
func2 db "FSOUND_SetDriver",0
func3 db "FSOUND_Init",0
func4 db "FMUSIC_LoadSongEx",0
func5 db "FMUSIC_SetMasterVolume",0
func6 db "FMUSIC_PlaySong",0
func7 db "FMUSIC_StopSong",0
func8 db "FMUSIC_FreeSong",0
func9 db "FMUSIC_SetLooping",0
func10 db "FMUSIC_SetPaused",0
func11 db "FMUSIC_GetPaused",0

FMOD_SetOutput_addr dd ?
FMOD_SetDriver_addr dd ?
FMOD_Init_addr dd ?
FMOD_LoadSongEx_addr dd ?
FMOD_SetMasterVolume_addr dd ?
FMOD_PlaySong_addr dd ?
FMOD_StopSong_addr dd ?
FMOD_FreeSong_addr dd ?
FMOD_MusicIsActive_addr dd ?
FMOD_SetLooping_addr dd ?
FMOD_SetPaused_addr dd ?
FMOD_GetPaused_addr dd ?

InitFMODMOD proc
invoke FindResource,hInstance,IDR_FMOD,addr szResourceType
test eax,eax
jz bail_out
mov hResourceFMOD,eax
invoke LoadResource,hInstance,hResourceFMOD
invoke LockResource,eax
test eax,eax
jz bail_out
mov dwFMODAddrInMem,eax
invoke SizeofResource,hInstance,hResourceFMOD
mov dwSizeOfFMOD,eax
invoke GetTempPath,sizeof szTempPathBuff,addr szTempPathBuff
test eax,eax
jz bail_out
invoke GetTempFileName,addr szTempPathBuff,addr szTempName,0,addr szTempPathBuff
test eax,eax
jz bail_out
invoke CreateFile,addr szTempPathBuff,GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
cmp eax,-1
je bail_out
mov hTempFMOD,eax
invoke WriteFile,hTempFMOD,dwFMODAddrInMem,dwSizeOfFMOD,addr dwBytesWritten,0
invoke CloseHandle,hTempFMOD
invoke LoadLibrary,addr szTempPathBuff
test eax,eax
jz bail_out
mov hFMODLib,eax
invoke GetProcAddress,hFMODLib,addr func1
mov FMOD_SetOutput_addr,eax
invoke GetProcAddress,hFMODLib,addr func2
mov FMOD_SetDriver_addr,eax
invoke GetProcAddress,hFMODLib,addr func3
mov FMOD_Init_addr,eax
invoke GetProcAddress,hFMODLib,addr func4
mov FMOD_LoadSongEx_addr,eax
invoke GetProcAddress,hFMODLib,addr func5
mov FMOD_SetMasterVolume_addr,eax
invoke GetProcAddress,hFMODLib,addr func6
mov FMOD_PlaySong_addr,eax
invoke GetProcAddress,hFMODLib,addr func7
mov FMOD_StopSong_addr,eax
invoke GetProcAddress,hFMODLib,addr func8
mov FMOD_FreeSong_addr,eax
invoke GetProcAddress,hFMODLib,addr func9
mov FMOD_SetLooping_addr,eax
invoke GetProcAddress,hFMODLib,addr func10
mov FMOD_SetPaused_addr,eax
invoke GetProcAddress,hFMODLib,addr func11
mov FMOD_GetPaused_addr,eax
mov eax,1
ret
bail_out:
xor eax,eax
ret
InitFMODMOD endp

push -1
call FMOD_SetOutput_addr
push 0
call FMOD_SetDriver_addr
push FSOUND_INIT_USEDEFAULTMIDISYNTH or FSOUND_INIT_GLOBALFOCUS
push 32
push 44100
call FMOD_Init_addr

[/code:3lobwf3l][/code]

  • You must to post comments
0
0

have you referred to fmoddyn.h to see how it loads fmod.dll dynamically?

  • You must to post comments
0
0

OK, my bad, i ignored all the c headers because i can’t do c for shit, so after like 10 minutes of looking i finally saw what u meant.
Now i have another problem, i’ve defined the constants, but the 0x thing seems to throw the compiler, and if i remove them, the program runs, but no music. Any ideas?
Thanks, Ehtyar
[edit]
The error message is "Missing operator in expression" triggered at the line beneath the one where i push the constants, but it is clearly at the line above.
–snip–
FSOUND_INIT_USEDEFAULTMIDISYNTH equ 0x0001
FSOUND_INIT_GLOBALFOCUS equ 0x0002
FSOUND_LOADMEMORY equ 0x00000002
FSOUND_LOOP_NORMAL equ 0x00008000
–snip–
push FSOUND_INIT_USEDEFAULTMIDISYNTH or FSOUND_INIT_GLOBALFOCUS
push 32 <– error here
push 44100
–snip–
[/edit]

  • You must to post comments
0
0

they are hexidecimal numbers, use
00000001h
instead of
0x00000001

  • You must to post comments
0
0

I’m seriously needing an example for playing from memory here. The hex worked fine thanks, felt like a complete noob :(
The initialisation all goes well now, but when i come to loading the music i hit problems. Im passing LoadSongEx a pointer from LockResource() but it dosn’t seem to like it. Do i have to shuffle stuff around or anything?
Thanks, Ehtyar
[edit]
OK, guess i am a noob. took me about 3 hours to figure out that i had put the sizeofresource in the wrong arg. AAAAANYWAY, everything else is running fine, and the reproduction is pretty damn good, but now im having trouble with GetPaused. My code is thus:

push pHandleFMOD ; put module handle on stack
call FMOD_GetPaused_addr
.IF eax == TRUE ; is it paused?
push FALSE ; unpause
push pHandleFMOD ; put handle on stack
call FMOD_SetPaused_addr
.ELSEIF eax == FALSE ; is it not paused?
push TRUE ; pause
push pHandleFMOD ; put handle on stack
call FMOD_SetPaused_addr
.ENDIF

Nither of the events are being triggered. If anyone has any ideas they’d be much appreciated. Thanks, Ehtyar
P.S. If you think it would be helpful, i’d be happy to create a small example for extracting fmod from resources and playing chips from mem. It would be in masm, but with commenting it should be easy to adapt to high level.
[edit]
OK, built myself workaround for that:
.IF dwPaused == 1
push FALSE
push pHandleFMOD
call FMOD_SetPaused_addr
mov dwPaused, 0
.ELSE
push TRUE
push pHandleFMOD
call FMOD_SetPaused_addr
mov dwPaused, 1
.ENDIF
I know it’s the ugliest hack you’ve ever seen, but it works. Anyway, that offer of the example is still valid, so just reply if you’d like. No more problems for me, so thanks a lot for your your help, and i apologise for any frustration my n00bness may have caused :)

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.