Sign in to follow this  
cockroach92

How to add fmodex.dll in xna?

Recommended Posts

Hi, I'm working on a rhythm game written in C# and I'm thinking about using fmod to handle the audio.
I've read some posts here and there about getting fmod to work in xna but I'm still having trouble adding fmodex.dll to my project.
The fmodex.dll from Program Files/FMOD Programmers API Windows/api has been copied to my project directory, but whenver I try to add it using Add Reference, an error pops up saying "...fmodex.dll could no be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
I have some simple fmod code written and compiled but when I run the game playSound doesn't play any music, so I'm guessing it's because of fmodex.dll is not added.
Below is what I have:
[code]fmodSystem = new FMOD.System();
channel = new FMOD.Channel();
fmodSound = new FMOD.Sound();
fmodSystem.createSound("song.mp3", FMOD.MODE.HARDWARE, ref fmodSound);
fmodSystem.playSound(CHANNELINDEX.FREE, fmodSound, false, ref channel);[/code]
I'm pretty new to xna and fmod so I appreciate any help.
If this question has been answered, it'd be great if you could direct me to the related posts.
Thanks a lot!

Share this post


Link to post
Share on other sites
Fmod is unmanaged C++ and thus can't be referenced directly into .Net. You have to use their wrapper, located in [b][color="#444444"][font="Arial,"]%install dir%\api\csharp\[/font][/color][/b][color="#444444"][font="Arial,"].
[/font][/color]

Share this post


Link to post
Share on other sites
Thank you!
So as long as I add those .cs files in api\csharp to my project fmod will work?
I still feel like my fmod is missing something. For example FMOD.Factory.Create_System generates an error "'FMOD.Factory' does not contain a definition for 'Create_System'."
All I want to do right now is to let fmod play the background music....

[quote name='AverageMidget' timestamp='1318279156' post='4871203']
Fmod is unmanaged C++ and thus can't be referenced directly into .Net. You have to use their wrapper, located in [b][color="#444444"][font="Arial,"]%install dir%\api\csharp\[/font][/color][/b][color="#444444"][font="Arial,"].
[/font][/color]
[/quote]

Share this post


Link to post
Share on other sites
[quote name='cockroach92' timestamp='1318292920' post='4871272']
Thank you!
So as long as I add those .cs files in api\csharp to my project fmod will work?
I still feel like my fmod is missing something. For example FMOD.Factory.Create_System generates an error "'FMOD.Factory' does not contain a definition for 'Create_System'."
All I want to do right now is to let fmod play the background music....
[/quote]

I believe that's because it's actually FMOD.Factory.System_Create()

[quote name='cockroach92' timestamp='1318292920' post='4871272'][color="#1C2837"][size="2"]So as long as I add those .cs files in api\csharp to my project fmod will work?[/quote][/size][/color]
[color="#1C2837"][size="2"]I'm not sure. To be honest, I've never used FMOD or XNA. I found this info via google. There's apparently an example that ships with FMOD named "loadfrommemory". Or here is a link to the files. [url="http://delirium-wars.googlecode.com/svn/trunk/sdk/FMOD%20SoundSystem/FMOD%20Programmers%20API%20Win32/examples/loadfrommemory/"]http://delirium-wars...loadfrommemory/[/url] Maybe that'll help you see how it is done, then it's a matter of porting it to c#.[/size][/color]

Share this post


Link to post
Share on other sites


another way to work with unmanaged modules is to use unmanaged C++ function as a middle translator but it will be very hard and may be not applicable in huge namespaces.

if u just wanna play a background music , you may find a better sound engine.

Share this post


Link to post
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

Sign in to follow this