0
0

Hello.
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.

  • You must to post comments
0
0

[quote="Sly":3b32kzg2]From my understanding of .NET, there seems to be two ways we can go here.

  1. Provide source files for each language that define the types and import the functions from the DLL. This is like the current FMOD release where each API update means updating several source files with the same change.

  2. Provide one assembly that works for all .NET languages. This assembly declares all the types and the functions in a common manner. One source file to produce one assembly for all .NET languages.[/quote:3b32kzg2]

From past experience of P/Invoke number 2 is likely to be the best answer by far. By picking a language (I always use C# as somehow it feels cleaner with P/Invoke) and then creating objects as you would in C++, you can make the native api available to anyone in any .Net language.

There is really no need to consider number 1, a class defined in C# and put in an assembly is accessible from ALL other .Net capable languages. Nice eh? That’s sort of why when you see ArrayList() used in several different languages it looks kinda freaky.

Generally I always ‘hide’ the native calls inside a class and only ‘allow’ that class to use the calls, making the FMod.Net API just a wrapper over the existing ones. Rather than have one source file you could just group all of the existing FMod calls into a class.

Using P/Invoke allows you to define C# structs to match any C ones you have and then marshall directly between the managed and unmanaged types. DotNet even has IntPtr which you can treat like a void *.

There is a lot of code in C# SDL that you could look at for clues (cssdl.sourceforge.net), it’s fairly obvious in there what is happening.

Feel free to ignore this advice (I’m not sure I’ve clarified anything), I only came here with a MacOS X linking problem … but I can’t resist getting involved in P/Invoke problems :)

  • You must to post comments
0
0

[quote="asmcon":143luq2k]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);
[/quote:143luq2k]
I declare the function exactly the same way except I leave out the [MarshalAs(UnmanagedType.LPStr)]. Still works.

[quote:143luq2k]I am having problems with call backs though. I can get C# to handle a callback as shown below.

The problem is that if I call FSOUND_Stream_Stop(streamID); the FMOD DLL seems to throw an exception AFTER it has handled the callback.
[/quote:143luq2k]
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.

  • You must to post comments
0
0

So far I have got a C# console application loading and playing a stream using a FMOD assembly (fmodnet.dll). The sample code for a simple stream player is below.

David, I found the solution to passing strings to FMOD. Just use String as the parameter type. A class type is already a pointer anyway. It seems to work fine.

I have callbacks working as well, but I get an exception raised if I try to call Fmod.Sound.Stream.GetTime() in the while loop when using the callback. If I do not get the stream time in the while loop, no exception is raised. If I use Fmod.Sound.IsPlaying() instead of the callback, no exception is raised. I can’t work this problem out yet.

Oh, and yes you have to use stdcall version of FMOD to get callbacks working properly.

[code:2pdk2e7a]
using System;
using Fmod;

class MainClass
{
// static bool ended = false;

// public static byte EndStreamCallback(uint stream, uint buff, int len, int param)
// {
// ended = true;
// return 0;
// }

public static void Main(string[] args)
{
Fmod.Sound.Init(44100, 32, 0);
Console.WriteLine("FMOD initialised");

uint stream = Fmod.Sound.Stream.OpenFile("..\\..\\media\\jules.mp3", Fmod.Modes.FSOUND_NORMAL, 0);
if (stream == 0)
  Console.WriteLine("Stream open failed");
else
{
  Console.WriteLine("Stream opened");

// Fmod.Sound.Stream.Callback endCallback = new Fmod.Sound.Stream.Callback(EndStreamCallback);
// Fmod.Sound.Stream.SetEndCallback(stream, endCallback, 0);

  int channel = Fmod.Sound.Stream.Play(Fmod.Misc.FSOUND_FREE, stream);

  while (Fmod.Sound.IsPlaying(channel) != 0)

// while (!ended)
{
Console.Write("\r" + Fmod.Sound.Stream.GetTime(stream) + "ms");
}
Console.WriteLine("\nStream ended");

  Fmod.Sound.Stream.Stop(stream);

  Fmod.Sound.Stream.Close(stream);
  Console.WriteLine("Stream closed");
}
Fmod.Sound.Close();
Console.WriteLine("FMOD closed");

}
}
[/code:2pdk2e7a]

  • You must to post comments
0
0

I doubt the path is wrong, since I am using exactly the same path with CNF and it locates it and confirms it’s there (of course I can’t really load it cause it’s ogg).

\My Documents\Personal\x.ogg

seems like a pretty standard path. I tried setting the current directory to it first. No luck.

Sorry about the thread. I will move the discussion to fmod ce.

  • You must to post comments
0
0

Isn’t it possible to just use the VB wrapper with VB.Net?

  • You must to post comments
0
0

[quote="chuawenching":2ys6b823]1)

FSOUND_LOOP_OFF = 0x00000001
–> why must it be 0x0….1 and not 0x…2 – where you get this info from?
[/quote:2ys6b823]From fmod.h.

[quote:2ys6b823]2)

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.

  • You must to post comments
0
0

Hi experts.

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.

  • You must to post comments
0
0

Hi!

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.

-Marco

  • You must to post comments
0
0

Hi Brett,

When will the next version of fmod released?

Actually i not sure that delegates can be used to replace callback? Is it wrong?

Oops.. sounds off topic to me… Sorry!

Regards,
Chua Wen Ching :p

  • You must to post comments
0
0

So do I have to add any additional references for fmod! I assume you must!

I not sure whether fmod is part of the COM components or not?

I am now not at home, so can’t run vs.net?

Any help?

Thanks.

Regards,
Chua Wen Ching :p

  • You must to post comments
0
0

[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);

Andy[/quote:1dfelk4n]

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.

  • You must to post comments
0
0

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.

  • You must to post comments
0
0

Thanks Sly!

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#!

Thanks.

Regards,
Chua Wen Ching :p

  • You must to post comments
0
0

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?

  • You must to post comments
0
0

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.

  • You must to post comments
0
0

[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?
[/quote:3t8fmme9]

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?

  • You must to post comments
0
0

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.

  • You must to post comments
0
0

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:
[url:mpp7bp8b]http://newtz.homeip.net[/url:mpp7bp8b]

  • You must to post comments
0
0

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.

  • You must to post comments
0
0

Take a look at some of the FMOD samples and the documentation for more information on callbacks. You can do most things without using callbacks, but for some special effects or functionality you do need to use callbacks.

  • You must to post comments
Showing 1 - 20 of 75 results
Your Answer

Please first to submit.