First I must state I am fairly new to C++. I know enough to get by and I have been writing a dll wrapper for Fmod to use in a program called Game Maker.I have no problems at all getting Fmod working using my dll. As a matter of fact I have been loading and playing songs all day but I have run into a few problems which I cannot seem to get working properly.
Note – All my export functions are either doubles or char types because that is all that Game Maker allows.
Problem – Ok so, my load function takes a file name as an argument obviously, however I need to return a variable back to Game Maker which will allow me to use that particular sound in other calls. For example, when I use my play function I can pass that sound index in Game Maker as an argument and my dll will tell Fmod which sound I am referring to.
See I want to be able to preload a number of sounds when the game starts and then be able to play them or whatever only when I’m ready. I have struggled with this for a few days now. How can I return this value so Fmod knows exactly what file to play back. I appreciate your time and thank you for helping out the little guy on the totem pole
- Jess Horton asked 9 years ago
Haha yes I understand how it went from simple to what it is today. Using your dll in GM is simple though and that’s the idea. Just as a side note … after type casting the double it worked like a charm. I really appreciate your advice … I was lost on how to work it out but now it’s all good. Thanks again
Welcome to the forums Jess,
[quote:3f7r53fx]All my export functions are either doubles or char types because that is all that Game Maker allows.[/quote:3f7r53fx]
That sounds like a strange limitation, you might find how other people work around this on the Game Maker forums.
Assuming your application is 32-bit all FMOD pointers need to be 32-bit, you can cast them to other types along the way if need be, as long as the data remains unchanged and they’re cast to the appropriate type before being passed to FMOD.
There are FMOD wrappers for Game Maker out there so it’s definately possible. An active forum member here icuurd maintains this one:
- Guest answered 9 years ago
Yea, the creator of Game Make only provided 2 types of argument in his external API definition. The double is big enough to hold most datatype. Though progressive down casts is required so to prevent your dll from misbehaving.
export void func(double data)
char a = (char) (short) (int) (DWORD) data
Type cast the double to a DWORD, then to your object or memory pointer.
export export void free_sound(double sound)
or if using the c++ interface
((Sound *) (DWORD))->Release();
to return an object, you do the reverse
export double create_sound(char * filename)
FMOD_SOUND *sound = NULL;
FMOD_System_CreateSound(<yoursystem>, filename, <yourflags>, 0, &sound);
return (double) (DWORD) sound;
the important bit is the interim DWORD casting in the case of a pointer.
Peter, Thanks for your help sir. It is frustrating at times but limitations provide challenges I suppose
Icuurd, I am familiar with your dll and Shaltif’s dll. I don’t plan on releasing this as it’s just for learning purposes. I am just starting to get a feel for C++ and I’ve used GM for about 5 or 6 years so I’d thought I’d take a crack at mixing the two. I greatly appreciate your help and I downloaded your example to examine the source. To me it’s complicated but only because I am not fluent in C++. I will try to work out what you have suggested.
Thanks alot guys, have a good day
Believe me, mine started with very simple features which the name reflected.
Anyhow, fmod is a great way to learn stuff. It’s easy to wrap arround it. It’s all the bells and wistle that gradually makes it harder for the uninitiate.
Please login first to submit.