C# 2D Events


I am trying to play 2D FMOD Studio Events via the FMOD API/FMOD Studio API. I need to be able to:

-Play studio events
-Have sound played reflect the position of the sound played, as well as the player’s current position (surround sound)
-Support multiple sounds playing at the same time/mixing together

How would I do this via the API, in C#?

We have a C# wrapper available either in our Unity Integration or in the API download. It is made to be a direct wrapper for our LowLevel and Studio API’s, allowing you to use them in the same way you would in C++.

We also have examples included in our API downloads, these are in C++ but they can give you an understanding of the workflow. Our documentation includes C++, C, C# and JavaScript syntax for all functions.

Sorry for the late response, life got busy: I realize this, have been utilizing them, and have even managed to use FMOD for playing normal sound events. Now however, I am trying to play this sound events in a 2D fashion. I have made several attempts at using a “listener”, or an “object spatializer”, but to no avail. Are there any tutorials, code samples, or resources that cover exactly what I am trying to do?

I have searched the internet thoroughly, but could not find any code examples to learn from that use both FMOD events, AND a method of playing the sound at a particular position in 2D.


Our API downloads come with many different example projects you can use as a guide.

2D sounds normally refers to sounds that aren’t spatialized or have a origin in the world. Eg. Background music or environmental ambience.

3D sounds have a position in the world even in a 2D game, although one plane can be ignored/set to zero.

Oh, I didn’t know that 2D sound referred to that. I figured it just meant sound with an X & Y position. I’ll have a go at adapting some of the tutorials/samples that I skipped over as I thought they were for 3D only, not positioning with an X & Y. Thanks!

I now have sound that gets louder and softer when approaching random points in my map (what?).

Here’s what I am using right now to allow for event based sound in a 2D map.

    public static void RaiseEvent(string eventPath, string parameterName, int value, Point2D screenPosition)
        _System.getEvent(eventPath, out EventDescription _event);
        _event.createInstance(out EventInstance instance);
        instance.setParameterValue(parameterName, value);

        _3D_ATTRIBUTES D3 = new _3D_ATTRIBUTES();

        FMOD.VECTOR forward = new FMOD.VECTOR();
        forward.x = 1;
        forward.y = 1;
        forward.z = 0;

        FMOD.VECTOR up = new FMOD.VECTOR();
        up.x = 1;
        up.y = 1;
        up.z = -1;

        FMOD.VECTOR position = new FMOD.VECTOR();
        position.x = screenPosition.X;
        position.y = screenPosition.Y;
        position.z = 0;

        D3.forward = forward;
        D3.up = up;
        D3.position = position;


My listener update call:

        _3D_ATTRIBUTES atts = new _3D_ATTRIBUTES();
        atts.forward.x = 1;
        atts.forward.y = 1;
        atts.forward.z = 0;

        Point2D camera = RenderInfo.GetCameraCenter();
        atts.position.x = camera.X;
        atts.position.y = camera.Y;
        atts.position.z = 0;

        atts.up.x = 1;
        atts.up.y = 1;
        atts.up.z = -1;

        System.setListenerAttributes(0, atts);

Any suggestions why this doesn’t work correctly?

The forward and up vectors must be of unit length (1).
atts.forward.x = 1;
atts.forward.y = 0;
atts.forward.z = 0;
atts.up.x = 0;
atts.up.y = 1;
atts.up.z = 0;