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

I’d imagine you would have things like Fmod.Sound, Fmod.Music, etc.? I’m just starting to read stuff about .NET for both C# and Delphi for .NET.

  • You must to post comments
0
0

An hour or two to learn how to use it properly in C# (with no prior C# experience). Another couple of hours to get several FMOD functions into the wrapper along with the test app while playing around with different ways of implementing them.

  • You must to post comments
0
0

[quote="Sly":hhguwgex]If I’m right, using Managed C++ could make an assembly that interfaces to the DLL without using Interop?[/quote:hhguwgex]

That is correct. Like I said, I have done this quite a bit for projects at work.

For FMod I was thinking of just wrapping the C structs in managed structs, using constants for the C #defines and possibly two other structs; one for the Sound functions and one for the Music functions. I would just create static methods on the structs that coincide with each of the FMod function calls. This would be the most direct way without having to come up with a good class design. In the future it would be nice to move to something more OO but, as a first pass, I think it would work well.

What do people think about that? If anything else has been done in this area I would also like to know about it. I don’t want to reinvent the wheel if I do not have to.

Rob

  • You must to post comments
0
0

Hello all,
I’m new to the forums, new to the FMOD SDK and looking forward to doing some development with it in C#. I’ve found that with some good documentation, porting the function calls with PInvoke to C# is relatively easy. I’ve already done media applications with BASS and Miles in C#. – 3 – 8 band equalizers, Shoutcast playback, etc. DirectX 9 is seriously lacking features of an audio SDK like FMOD. I’d be happy to post my results/source code to the list if anyone is interested and if there is a place to do so.

  • You must to post comments
0
0

Coding callback in c#, you need to use delegates… (correct me if i am wrong)

you replace c++ pointers in c# to ref

Hope it helps…

still thinking of my wrapper…

Regards,
Chua Wen Ching :p

  • You must to post comments
0
0

Okay. Since i can’t play much fmod with c#!

I will come back next time, when fmod is ready!

😆

Thank you.

Regards,
Chua Wen Ching :p

  • You must to post comments
0
0

I am using Compact .NET Framework on pocket pc 2002 in c#.

I used win32 version of fmod.dll for testing on my xp using Compact .NET Framework and everything worked. However, downloading the app to my pocket pc and using ARM version of fmodce.dll(3.63), the .ogg file(any file) refuses to load. I am using the following to load:

[code:2vb5ni0e]
[DllImport("fmod.dll", EntryPoint="FSOUND_Sample_Load", SetLastError=false)]
private static extern IntPtr FSOUND_Sample_Load(int index, string name_or_data, uint inputmode, int memlength);
[/code:2vb5ni0e]

MarshallAs attribute is not supported by CNF of course, and CharSet attribyte also doesn’t seem to affect the outcome.

The error code I do get is 9. I assume it’s “File Not Found” error. CNF code just right before the pinvoke confirms that the file exists, and I am wondering why FMOD is not able to. I suspect the function is not getting the filename correctly. Note that the code works perfectly on my xp using the same CNF. The culprit must be either FMOD itself or how CNF is passing the filename string to FMOD.

Any ideas? 😡

  • You must to post comments
0
0

The .NET port does not have to be done in C#. .NET assemblies can be made in any .NET language. Borland has a Delphi for .NET compiler preview available and Microsoft is bringing out Visual C++ for .NET soon.

  • You must to post comments
0
0

Thanks!

I receive your files!

Just wondering..

I definitely need fmod.dll right!

How do you know:

1)

FSOUND_LOOP_OFF = 0x00000001
–> why must it be 0x0….1 and not 0x…2 – where you get this info from?

2)

All the enums are also based on the orginal fmod?

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!

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?

5) Lastly, i can implement fmod in a game engine! Coz the game engine sound is lousy!

6) Must i place the fmod.dll in the windows/system32 folder?

Just to confirm!

Thanks anyway!

Regards,
Chua Wen Ching :p

  • You must to post comments
0
0

I had started on a class-based C# wrapper (yes, it used PInvoke). Hadn’t finished it because I really don’t have much interest in .NET as yet.

  • 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
Showing 1 - 20 of 75 results
Your Answer

Please first to submit.