0
0

I’m trying to get some audio that was generated by the FMOD designer to play in code and something isn’t working right. In the designer I have set event to be 2D but want the sound to play out of only the LFE which has a value of 13.96 and the other channels are -60db. In the designer, everything works as expected and the sound is only playing in the LFE. However, when I try to play the sound in code it’s playing the sound through the Center channel and not the LFE like it is in the designer.

Here is my initialization code:
[code:37xukmu7]
public bool Intialize()
{
_result = Event_Factory.EventSystem_Create(ref _eventSystem);
Error(_result);

        _result = FMOD.Factory.System_Create(ref _system);
        Error(_result);

        _result = _system.getVersion(ref _version);
        Error(_result);
        if (_version < FMOD.VERSION.number)
            Console.WriteLine("Error!  You are using an old version of FMOD " + _version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");

        FMOD.SPEAKERMODE speakermode = FMOD.SPEAKERMODE._5POINT1;
        _result = _system.setSpeakerMode(speakermode);                          
        Error(_result);

        FMOD.CAPS caps = FMOD.CAPS.NONE;
        int minfrequency = 0, maxfrequency = 0;
        _result = _system.getDriverCaps(0, ref caps, ref minfrequency, ref maxfrequency, ref speakermode);
        Error(_result);

        if ((caps & FMOD.CAPS.HARDWARE_EMULATED) == FMOD.CAPS.HARDWARE_EMULATED)
        {
            _result = _system.setDSPBufferSize(1024, 10);                       
            Error(_result);
        }

        FMOD.GUID guid = new FMOD.GUID();
        StringBuilder driverName = new StringBuilder();
        _result = _system.getDriverInfo(0, driverName, driverName.Capacity, ref guid);
        Error(_result);

        _result = Load();
        Error(_result);

        return initialized = true;
    }


    public RESULT Load()
    {
        if (!_scenarioIsLoaded)
        {

            _result = _eventSystem.init(124, FMOD.INITFLAG.NORMAL, (IntPtr)null, FMOD.EVENT_INIT.NORMAL);
            Error(_result);

            //TODO: read this path from config file:
            _result = _eventSystem.setMediaPath(@"C:\Audio\");
            Error(_result);

            _result = _eventSystem.load("sounds.fev");
            Error(_result);

            _result = _eventSystem.getGroup("sounds/big", true, ref _truckGroup);
            Error(_result);

            _result = _eventSystem.getCategory("master", ref _master);
            Error(_result);

        }

        return _result;
    }

[/code:37xukmu7]

And the code I’m using to start/stop the event:
[code:37xukmu7]
if (!_events.ContainsKey("lowsound"))
StartEvent("lowsound_grind", true);

            fmodEvent = _events["lowsound_grind"];
            fmodEvent.getParameter("frequency", ref eventParam);
            eventParam.setValue((float)_audioBuffer.TransFreqControl);

            fmodEvent.getParameter("amplitude", ref eventParam);
            eventParam.setValue((float)_audioBuffer.TransAmpControl);

[/code:37xukmu7]

Not really sure what the problem is, any suggestions would be great.

Thanks in advance.

  • You must to post comments
0
0

You’ll need to use the recommended start up sequence to get fmod into the right speaker mode.

http://52.88.2.202/forum/viewtopic.php?t=9305

  • You must to post comments
0
0

Made a couple of changes so that my startup code is the same as what you have in the in the link you posted, but nothing has changed in the behavior.

The event sound is playing correctly and cleanly, just not out of the correct speaker (Center rather then LFE). Works great in the designer, but not in the application.

Nothing in the link you posted made reference to the event system. Is there anything I need to set to get this to work with events? The mode of the event that I’m trying to play is set to be a stereo, does it need to be something else? I tried a few different settings, and it didn’t seem to make a difference. Also, not sure if it makes a difference (hope it doesn’t), I am using the C# wrapper.

Do you have any other suggestions?

Bellow is my latest init code:
[code:1vxh10ct]
_result = Event_Factory.EventSystem_Create(ref _eventSystem);
Error(_result);

        _result = FMOD.Factory.System_Create(ref _system);
        Error(_result);

        _result = _system.getVersion(ref _version);
        Error(_result);
        if (_version < FMOD.VERSION.number)
            Console.WriteLine("Error!  You are using an old version of FMOD " + _version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");

        int numDrivers = 0;
        _result = _system.getNumDrivers(ref numDrivers);
        Error(_result);

        if (numDrivers == 0)
        {
            _result = _system.setOutput(FMOD.OUTPUTTYPE.NOSOUND);
            Error(_result);
        }
        else
        {

            FMOD.SPEAKERMODE speakermode = SPEAKERMODE.STEREO;// = FMOD.SPEAKERMODE._5POINT1;
            FMOD.CAPS caps = FMOD.CAPS.NONE;
            int minfrequency = 0, maxfrequency = 0;
            _result = _system.getDriverCaps(0, ref caps, ref minfrequency, ref maxfrequency, ref speakermode);
            Error(_result);

            _result = _system.setSpeakerMode(speakermode);                             /* Set the user selected speaker mode. */
            Error(_result);

            if ((caps & FMOD.CAPS.HARDWARE_EMULATED) == FMOD.CAPS.HARDWARE_EMULATED) /* The user has the 'Acceleration' slider set to off!  This is really bad for latency!. */
            {
                _result = _system.setDSPBufferSize(1024, 10);                        /* At 48khz, the latency between issuing an fmod command and hearing it will now be about 213ms. */
                Error(_result);
            }

            FMOD.GUID guid = new FMOD.GUID();
            StringBuilder driverName = new StringBuilder();
            _result = _system.getDriverInfo(0, driverName, driverName.Capacity, ref guid);
            Error(_result);
        }

         _result = _eventSystem.init(64, FMOD.INITFLAG.NORMAL, (IntPtr)null, FMOD.EVENT_INIT.NORMAL);
         Error(_result);

         _result = _eventSystem.setMediaPath(@"C:\Audio\");
         Error(_result);

         _result = _eventSystem.load("sounds.fev");
         Error(_result);

         _result = _eventSystem.getGroup("sounds/deep", true, ref _deepGroup);
         Error(_result);

         _result = _eventSystem.getCategory("master", ref _master);
         Error(_result);

[/code:1vxh10ct]

  • You must to post comments
0
0

Figured this out and thought I would post what I found.

Because I’m using the event system, you have to feed the event system a reference to the FMOD engine by calling getSytemObject in the init code:

[code:cm9jl72j]
...

_result = FMOD.Factory.System_Create(ref _system);
Error(_result);

_eventSystem.getSystemObject(ref _system);
Error(_result);

_result = _system.getVersion(ref _version);
Error(_result);

...
[/code:cm9jl72j]

Once this was done, everything behaved just as it should!

Hope it helps.

  • You must to post comments
0
0

Hi Blue Solitare,

In your first post I didn’t notice that your system object was separate to the event system. The second code you posted is correct, you need to get the FMOD::System object from the event system and do your custom init code before calling EventSystem::init().

-Pete

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.