I would like to know if there is any support (existing or planned) for .NET.
I intend to use FMOD with Visual C# or if necessary with VB .NET.
I got a sample-program to run under Visual C#, but I had to migrate everything by hand.
Thanks for any information. Prem.
- Prem asked 15 years ago
FSOUND_LOOP_OFF = 0x00000001
–> why must it be 0x0….1 and not 0x…2 – where you get this info from?
All the enums are also based on the orginal fmod?
[/quote:2ys6b823]Copied straight across from fmod.h.
[quote:2ys6b823]3) Did you refer to any fmod API when you create the wrapper? Just wonder how you get to know how many functions and types that available in fmod!
[/quote:2ys6b823]I referred solely to fmod.h.
[quote:2ys6b823]4) Once i compile the wrapper, i can add references to fmod? So the Fmod.Sound.cs is a different project with Main.cs right?
[/quote:2ys6b823]Use Fmod.Sound.cs to compile an assembly. I called my assembly fmodnet. Then use Main.cs to compile a console application. I called my application fmodtest. Add fmodnet as a reference in the fmodtest project. Put fmodnet.dll and fmod.dll (use the stdcall version of fmod.dll available on the downloads page if you wish to use callbacks) in the same directory as fmodtest.exe. Now run fmodtest.exe.
[quote:2ys6b823]5) Lastly, i can implement fmod in a game engine! Coz the game engine sound is lousy!
[/quote:2ys6b823]Of course you can. You can do anything the FMOD license allows you to do.
[quote:2ys6b823]6) Must i place the fmod.dll in the windows/system32 folder?
[/quote:2ys6b823]You can put fmod.dll anywhere in the search path. When a DLL is loaded, Windows searches paths in the following order…
1. The directory from which the application loaded.
2. The current directory.
3. The Windows system directory.
4. The Windows directory.
5. The directories that are listed in the PATH environment variable.
Just remember to use the stdcall version of fmod.dll if you wish to use callbacks. I have had some problems getting callbacks working properly so far, so I would recommend not using them just yet.
I am not a Windows-expert. So i don’t really understand how to use fmod.dll without Interop. But I am sure that I have some performance-problems in my C#-player. It works. But basically the whole .NET is a very slow thing. I regret that I ever started using it. Whenever I start the sample FMOD-player, I am just envious.
Could anybody please give an example how to use fmod.dll in a more performant way than with Interop?
- Prem answered 14 years ago
I have some experience with wrapping C-libraries into Managed Interfaces using .NET. I’m currently twiddling a bit with wrapping Lua 5.0. Anyways, here’s my two cents. The easiest way to do it is with P/Invoke using the DLLImport stuff, but that only allows you to basically port the FMOD API to .NET, which (IMHO) does feel very kludgy to use from .NET languages. Those people want nice classes and objects to work with. Another minus point is, that you will have two DLLs floating around. FMOD.DLL and FMODNET.DLL or whatever … it would be nicer to have just a single DLL. The solution to this is to create a managed wrapper using Managed C++. You create a class library which includes the entire FMOD source code. Then you wrap the necessary parts into Managed classes. It is quite easy to communicate with native code this way. Basically, the managed wrapper code is like an application which just ‘uses’ FMOD … simple as that.
Once a basic wrapper is set up, you can then extend it with some neat .NET features, such as Properties, Delegates, etc… to make it easier/cooler to use.
Thanks to the simple FMOD API it should be very, very easy to create such a wrapper. Obviously, some parts are a bit trickier (DSPs, etc…) but a wrapper for basic functionality should be a weekend project. I think I might even give it a try tonight … just to get some MP3 playback.
If you (Brett) or anybody else want to know more, feel free to ask.
[quote="asmcon":1dfelk4n]Hi fellow FMOD developers,
Just out of interest, Is this how other people do it?
[ DllImport( “fmod.dll”, CharSet=CharSet.Auto )]
public static extern int FSOUND_Stream_OpenFile([MarshalAs(UnmanagedType.LPStr)] string FileName, FSOUND_MODES mode, int memlength);
Actually, I don’t put any MarshallAs attributes and it works fine. I think it might do LPStr by default for PInvoke.
All I have is EntryPoint, nothing else.
- doughboy answered 14 years ago
Yes, a long time ago I have tried to use the vb6->vb.net converter to open fmod.bas in .net, and I thought only a few manual changes were needed after that to get it working.
Once you have the fmod commands available from .net, you can also make an object oriented wrapper class to make fmod available oo.
- Adion answered 15 years ago
Anyway i never really use C++
I know C++ got callback!
But what does callback means and had to do with fmod.dll?
Can’t i live without it? What is so special about it?
Can i do callback in c# too? I never tried callback before in c#!
Chua Wen Ching :p
Theres been a lot of postings about the “FMOD .NET” and the FMOD4, but I can’t find any releases regarding these?
Is the .NET wrapper developed? When will it be released?
And how about FMOD4? When? Can it also be easy integrated into .NET without PInvoke?
- djerik answered 14 years ago
I cannot see Brett wanting to go to that effort for the 3.xx series since all his efforts are on FMOD4 for the foreseeable future. So, if we want .NET usability for the 3.xx series, then we will have to go with the PInvoke approach and have the two DLLs. That’s a small price to pay for being able to easily use FMOD in any .NET language.
[quote:3t8fmme9]Are you using the stdcall version of FMOD? That is a requirement since .NET does not how to handle cdecl functions. As for the error when returning from the callback, yes we are all getting that. Not sure how to handle that one. But we will keep trying.[/quote:3t8fmme9]
I thought I had tried both DLL versions, but I’m not sure as I am still not 100% with .NET 2003. I will go over this again later and be sure. I’ve got the feeling that both DLL versions manage to play files, set/receive callbacks and then crash when leaving the callback.
To get me going for now I am just ignoring the error in a Try block. I’m sure you all have tried this, did you get a long delay before the system came back every time the callback fired?
[quote:3t8fmme9]Chua Wen Ching
Actually i not sure that delegates can be used to replace callback? Is it wrong?
I’m not sure what you mean, the delegate does work to the point of firing the callback (the difficult bit!), it’s just when the callback returns that a problem occurs.
Brett, any ideas?
- asmcon answered 15 years ago
FMOD is not a COM component. To use FMOD from a .NET language, you must use the PInvoke mechanism (System.Runtime.InteropServices) to call unmanaged functions in DLLs from managed code. I have started wrapping the FMOD 3.63 functions into an assembly that can be used from any .NET language. It is nowhere near complete yet though.
Just to help everyone out, I found this c# wrapper for FMOD while on the net one day, but I can’t remember where I found it (I thought I found it here!). Anyways, I can’t take any credit for it as it’s not my work, but unfortunately, the author left no hint of who he was in the source code.
Since it was freely downloadable when I got it, I wouldn’t imagine there would be any problem with me posting a link to it on my webserver. If you are the author and happen to see this and want me to take it down though, I will.
You can get it here:
- Datac0re answered 14 years ago
The code for Delphi for .NET is very similar to C#. The DllImport directive is exactly the same bar the double quotes. The only thing different is the function declaration.[code:1gtbv4dn][DllImport(’fmod.dll’, EntryPoint = ‘_FSOUND_Init@12’)]
function FSOUND_Init(mixrate, maxsoftwarechannels: Integer; flags: Cardinal); external;[/code:1gtbv4dn]FMOD would be considered unsafe code due to the use of pointers. Managed code does not allow the use of pointers so that the CLR (Common Language Runtime) can perform garbage collection and keep everything nice and orderly.
[quote="djerik":bb2z39zu]Theres been a lot of postings about the “FMOD .NET” and the FMOD4, but I can’t find any releases regarding these?
Is the .NET wrapper developed? When will it be released?
And how about FMOD4? When? Can it also be easy integrated into .NET without PInvoke?[/quote:bb2z39zu]
Well, it’s been a few months, and I’d like to know the answers to these questions, too.
- Grimolfr answered 14 years ago
Well, you might be right … I sent him a very small/limited/hacked together sample of how I would do it yesterday evening (the wrapper in Managed C++ and the test-sample in C#). The effort is really not that much more. Even if it is not done for the 3.xx series, he should consider it for FMOD 4. It is much cleaner, IMHO. I guess, this decision is really governed by other factors. How long will it be until version 4 comes around? Does he still want to have version 3.xx floating around?
Everybody using C# should be able to write their own P/Invoke wrapper anyways. Using P/Invoke you should be able to wrap FMOD in its entirety over a weekend. I haven’t looked much into the DSP stuff, but that should also be possible, having FMOD callback C# or VB.NET code … although this requires the FMOD version, which uses stdcall for callbacks.
Thanks a lot…
Oh is return back the values having problem.. hmm!
Is there any complete website out there that compare C++ and C# entirely.. based on features…
use Callback in C++ and use Delegates in C#
even compare functions, etc!
I am having much problem understanding c++.. never intend to learn c++
Chua Wen Ching :p
Please login first to submit.