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

Wow, even Microsoft, a company that seems to like using proprietary technology, has taken note of FMOD? That’s surprising… then again, I guess it’s all in due time. Microsoft is now using Inno Setup, one of the best [b:1nt96nu1]completely free[/b:1nt96nu1] installation systems out there… wouldn’t it be something to see MS start using all third-party technologies?

  • You must to post comments
0
0

I do not have the wrapper with me at the moment. It is at home. I am using C# and the PInvoke directive provided by System.Runtime.InteropServices. Look for PInvoke in the .NET documentation. That has been my sole source of information in regards to writing this wrapper.

I can send the wrapper once I get home tonight.

  • You must to post comments
0
0

[quote="Sly":37q4mtxp]How do you not use Interop when all you have is a DLL?[/quote:37q4mtxp]

You use the header ( fmod.h) and library ( fmodvc.lib ) files from the SDK distribution. When programming in C/C++ that is what you usually do. I guess you could go directly against the DLL utilizing the LoadLibrary and GetProcAddress Win32 functions, but you would still need to have the header file for structures and constants ( #defines in this case ). The only reason I see doing it this way is if you wish to determine at runtime which sound system to use. For example allowing the user to choose between FMod, OpenAL or Direct3D. There would be a lot more to it though.

Note: If all you have is the DLL then you probably just downloaded the binary distribution. Therefore you need to download the SDK distribution. It is the same distribution that includes the VB and Delphi interfaces.

Hope this helps,
Rob

  • You must to post comments
0
0

That only means it cannot be used like an Active-X DLL. But it can be used as API just like in any other language e.g. VB6. (DllImport).
Prem.

  • You must to post comments
0
0

Its fairly easy to write your wrapper from the FMOD documentation as well, thats usually where I start out…that way you get explanations about the purpose of the method and its parameters. Something else I’ve done to start out writing wrappers is to re-write one of the samples – like a simple MP3 player – that helps in keeping you focused on what functions you need to implement to get that working, then you just build on it from there.

  • You must to post comments
0
0

I don’t think any of them are available for download just yet.

FMOD can use DirectSound for sound output, but it provides extra functionality over DirectSound.

  • You must to post comments
0
0

Hi.
I have programmed in C# with asmcom’s code-snippet and also the callback works perfectly. No crash. In the callback I start a new song, after the last song I return 0. In no situation does fmod crash.
Thanks, asmcom.
There is one problem left for me: it is a lot of work to migrate fmod.h to C#. And this has to be done now with every new version of fmod? How about a listing of changes or something like that?

  • You must to post comments
0
0

They’re using Inno Setup .. that is amazing – I started using that over 2 years ago … and it IS good

  • You must to post comments
0
0

Okay i will look into P/Invoke..

Pretty thanks…

just email me at chuawenching@lycos.com and chuawenching@yahoo.com as a backup!

Wow.. what i know about PInvoke is that they uses DllImport!

Something like that… but really thanks alot.. hehe! Finally i can learn to write my first wrapper…

How long you took to write that wrapper?

Thank you.

Regards,
Chua Wen Ching :p

  • You must to post comments
0
0

Yeah, I always get the full distribution having helped maintain the Delphi interface for a couple of years now.

I didn’t realise what you meant in the original message. Now it makes sense in a “the lib is just another interface to the DLL” kind of way. If I’m right, using Managed C++ could make an assembly that interfaces to the DLL without using Interop?

I’m just keen to try FMOD in Delphi for .NET.

  • You must to post comments
0
0

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.
  • You must to post comments
0
0

Hi fellow FMOD developers,

I’ve had a good read through this conversation topic and have followed a simple enough path. i.e. Learn a bit about c#, write a wrapper for FMOD.

I can get FMOD playing, stopping, closing no problem.

I don’t know what you guys have got in your wrappers, but for information, I have declard Stream_OpenFile as below. I like how you can convert a normal unicode string type directly into a pointer to a ascii string in c#.

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

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.

A snippet of my code (with error checking and other stuff removed for clarity) is below. It is based on the good old fmod.bas file for VB6 users.

[code:1ruyxsi0]using System.IO;
using System;
using System.Runtime.InteropServices;
using FMODWRAP;
using System.Diagnostics;

namespace FMODWRAP
{
public class FSOUND
{
public enum FSOUND_MODES : int
{
FSOUND_LOOP_OFF = 0x01, // For non looping samples.
FSOUND_8BITS = 0x08, // For 8 bit samples.
FSOUND_16BITS = 0x10, // For 16 bit samples.
FSOUND_MONO = 0x20, // For mono samples.
FSOUND_STEREO = 0x40, // For stereo samples.
FSOUND_2D = 0x2000, // Ignores any 3d processing. overrides FSOUND_HW3D. Located in software.
FSOUND_NORMAL = FSOUND_LOOP_OFF | FSOUND_16BITS | FSOUND_STEREO | FSOUND_2D
}

    public enum FSOUND_INITMODES : int
    {
        FSOUND_INIT_GLOBALFOCUS = 0x02
    }

    [ DllImport( "fmod.dll", CharSet=CharSet.Auto) ]
    public static extern byte FSOUND_Init(int mixrate, int maxchannels, FSOUND_INITMODES Flags);

    [ DllImport( "fmod.dll", CharSet=CharSet.Auto )]
    public static extern byte FSOUND_Close();

    [ DllImport( "fmod.dll", CharSet=CharSet.Auto )]
    public static extern int FSOUND_Stream_OpenFile([MarshalAs(UnmanagedType.LPStr)] string FileName, FSOUND_MODES mode, int memlength);

    [ DllImport( "fmod.dll", CharSet=CharSet.Auto )]
    public static extern int FSOUND_Stream_Play(int channel, int stream);

    [ DllImport( "fmod.dll", CharSet=CharSet.Auto )]
    public static extern byte FSOUND_Stream_Stop(int stream);

    [ DllImport( "fmod.dll", CharSet=CharSet.Auto )]
    public static extern byte FSOUND_Stream_Close(int stream);

    public delegate byte STREAMCALLBACK(IntPtr stream, IntPtr buff, int len, int param);

    [ DllImport( "fmod.dll", CharSet=CharSet.Auto )]
    public static extern byte FSOUND_Stream_SetEndCallback(int stream, STREAMCALLBACK x, int userdata);

    const int FSOUND_FREE = -1;


    public bool Initialise(int BitRate, int Channels, FSOUND.FSOUND_INITMODES modes)
    {
        return FSOUND_Init(BitRate, Channels, modes) == 1;
    }

    public int StreamOpenFile(string filename, FSOUND_MODES mode, int memlength)
    {
        //Note that the OpenFile DLL definition uses the MarshalAs attribute ([MarshalAs(UnmanagedType.LPStr)] string FileName)
        return FSOUND_Stream_OpenFile(filename, mode, memlength);
    }

    public class Stream
    {
        public int StreamID = -1;
        public int ChannelID = -1;

        public Stream(string f)
        {
            StreamID = FSOUND_Stream_OpenFile(f, FSOUND.FSOUND_MODES.FSOUND_NORMAL, 0);
        }

        public void Play()
        {
            ChannelID = FSOUND_Stream_Play(FSOUND_FREE, StreamID);
            STREAMCALLBACK myCallBack = new STREAMCALLBACK(StreamEndCallback);
            FSOUND_Stream_SetEndCallback(StreamID, myCallBack, 0);
            Debug.WriteLine("FSOUND_Stream_SetEndCallback called.");
        }
        public byte StreamEndCallback(IntPtr stream, IntPtr buff, int len, int param)
        {
            Debug.WriteLine("StreamEndCallback fired.");
            FSOUND_Stream_Close(StreamID);
            return 0;
        }

        public void Stop()
        {              
            FSOUND_Stream_Stop(StreamID);
        }
    }
}

}[/code:1ruyxsi0]

I’ve tried making the callback static, didn’t make any difference.

Does anyone have any ideas what I might me doing wrong?

Would anyone care to send me thier wrapper if they have callbacks working?

Many thanks,

Andy

  • You must to post comments
0
0

[quote="Sly":1nhbx6fy]I just tried to do a small test in C#. I got a small assembly going with init and close working, but got stuck at trying to pass a String to a function that expects a char *.

Not that I’m really serious about using C#. To me it still feels like too much work to do the simplest thing.[/quote:1nhbx6fy]

I know exactly what you mean. I had this problem however a quick look in Petzold managed to shed some light on it. You need to use a StringBuilder found in System.Text.

David Glover

  • You must to post comments
0
0

Sweet! I’m assuming that Seth knows a bit more about .NET than us .NET newbies. :)

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

Please first to submit.