0
0

How do I do this?

I am trying to pass in a resource to the createSound() function of FMOD, but I can’t figure it out. I’m using C# and Visual Studio.net.

The only way I know how to access a resources that I added to Visual Studio.net is to look for it in the Properties.Resources (namespace?). Passing this into createSound() creates problems. What should I do?

For example:

[code:25qj6ss4]FMOD.RESULT result = system.createSound(Properties.Resources.Cut, (FMOD.MODE.OPENMEMORY | FMOD.MODE.HARDWARE), ref sound);[/code:25qj6ss4]

I get error: CS1503: Argument ‘1’: cannot convert from ‘byte[]’ to ‘string’

Whats up. I thought I could pass a memory pointer if I passed FMOD.MODE.OPENMEMORY.

Any help is appreciated. Thx.

  • You must to post comments
0
0

There is an example already in examples_csharp called ‘loadfrommemory’

[code:18sv98xt]
uint version = 0;
FMOD.RESULT result;
int length;
FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();

        /*
            Global Settings
        */
        result = FMOD.Factory.System_Create(ref system);
        ERRCHECK(result);

        result = system.getVersion(ref version);
        ERRCHECK(result);
        if (version < FMOD.VERSION.number)
        {
            MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
            Application.Exit();
        }

        result = system.init(1, FMOD.INITFLAG.NORMAL, (IntPtr)null);
        ERRCHECK(result);       

        length = LoadFileIntoMemory("../../../../examples/media/wave.mp3");

        exinfo.cbsize = Marshal.SizeOf(exinfo);
        exinfo.length = (uint)length;

        result = system.createSound(audiodata, (FMOD.MODE.HARDWARE | FMOD.MODE.OPENMEMORY), ref exinfo, ref sound);
        ERRCHECK(result);

[/code:18sv98xt]

  • You must to post comments
0
0

I guess that one does apply to me. Sorry for the bother, but I REALLY appreciate the help. I really do. Thanks alot. Fmod rocks me out of a jail(huge) made of .wavs.

Its not working for me. The Properties.Resources.Cut that I am referencing is already of type byte[], yet when I pass it to createSound the compiler complains of converting byte[] to string, yet supposedly the function should take a byte[] if you pass in the FMOD.MODE.OPENMEMORY enumeration to the function.

A little more help.

I read through the Loadfrommemory example. They are reading a file into memory and then passing that to the function.

WORKING::

I finally got it to work. I wasn’t passing the 3rd parameter of type exInfo into the createSound function and thus it wasn’t overloading correctly and excepting the byte[].I guess the createSound that only takes 3 parameters won’t overload to excpet a byte[], only a string. The good news is you can pass in your Properties.Resources right in and it will like it. No filestream of LoadfromMemory functions required.

Thx,
Tophor2

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.