1
0

Since this is new and hard to come across good materials to get started, I thought I’d help the cause.

My main information sources were this: [url:180kw96e]http://perttuh.blogspot.com/2013/10/unity-and-fmod-integration.html?showComment=1390266431189#c4026099878662781051[/url:180kw96e] and this [url:180kw96e]http://www.fmod.org/forum/viewtopic.php?f=30&t=18649[/url:180kw96e]. Much of this post will be directly pulled from these resources, but updated and with combined info.

The main reason to use this is that it enables your sound designers to edit, mix and master your game audio using the FMOD Studio interface WHILE THE GAME IS RUNNING. Don’t like that footstep sound? You can change it in REAL TIME while the game is running without recompiling or rebuilding.

  1. Import the fmodstudio.unitypackage from the fmod.org downloads section. To import in Unity editor, select Assets/Import Package/Custom package.
  2. Build your FMOD banks (File/Build), and export your GUIDs (you will have to do this everytime you create/delete an event)
  3. In Unity, select FMOD/Refresh Event List and select the GUIDs.txt from your FMOD project’s Build folder. Note: you need to do this whenever you rebuild the FMOD project and GUIDs. This will create FMODAssets and StreamingAssets folders in the Unity project and copy the FMOD banks to the StreamingAssets folder.
  4. When your scene starts, load a bank (see example below)
  5. Play a sound in through your Unity script (again, see example below). You might also have to sometimes use the lower level API (fmod.cs, fmodstudio.cs), as the unity integration package has been released very recently.
  6. To enable live mixing using FMOD Studio, uncomment the first line of FMOD_StudioSystem.cs, found in the plugins/FMOD folder. Also check the "Run in background" checkbox in Unity Editor, which can be found by selecting Edit/project settings/player and then selecting the Resolution and Presentation panel in the Inspector. Now press play in unity, select File/Connect to game in FMOD Studio and click ok. You can now adjust audio event properties on the fly while the game is running.

My example has a long sound event in the "Master Bank" called "zoomer" with a parameter called "zim" that changes the pitch:
[code:180kw96e]
using UnityEngine;
using System.Collections;
using FMOD.Studio;

public class sound : MonoBehaviour {
FMOD_StudioSystem soundSystem;
FMOD.Studio.EventInstance zoom;
FMOD.Studio.ParameterInstance pitch;
float pos = 0;

// Use this for initialization
void Start () {
    //Cache the FMOD_StudioSystem instance for easier access
    soundSystem = FMOD_StudioSystem.instance;

    //declare a string variable holding the file name. The Application.dataPath is needed so that
    //the sounds work both in the editor and in standalone builds
    string fileName = Application.dataPath + "/StreamingAssets/Master Bank.bank";

    //Load the FMOD bank
    FMOD.Studio.Bank bank;
    FMOD_StudioSystem.ERRCHECK(soundSystem.System.loadBankFile(fileName, out bank));
    //Also load the corresponding strings bank so that we can find the events by their names
    FMOD.Studio.Bank bankStrings;
    FMOD_StudioSystem.ERRCHECK(soundSystem.System.loadBankFile(fileName + ".strings", out bankStrings));

    zoom = soundSystem.getEvent("/zoomer");
    zoom.getParameter("zim", out pitch);
    zoom.start();
}

// Update is called once per frame
void Update () {

}

void OnGUI()
{
    if (GUI.Button(new Rect(100,100,200,30),"Modify sound"))
    {
        //soundSystem.PlayOneShot("/boo",Vector3.zero);
        pos += .1F;
        pitch.setValue(pos);
    }
}

}
[/code:180kw96e]
Attach that script to your main camera.

Now, everytime you click the GUI button, you’ll hear your parameter changing live during playback (assuming you made a parameter called "zim" on the event "zoomer" that does something). And you can also change anything about this sound while its running if you are "connected" from FMOD Studio.

Again, most of this isn’t my original information, but it’s really hard to find a good example of these things right now because this stuff is so new.

This stuff is a total game-changer for video game sound design. THANK YOU FMOD AND UNITY! I can’t wait to see these features grow.

  • You must to post comments
0
0

check to make sure that the methods have not changed in the interim. they’ve been updating the API and not really documenting everything. for example i found that something like:

fmodAmbienceEvent = FMOD_StudioSystem.instance.getEvent(Ambience.path);

which worked fine in older versions of the integration, now suddenly has changed to this:

fmodAmbienceEvent = FMOD_StudioSystem.instance.GetEvent(Ambience.path);

so i wouldn’t be surprised if some other stuff changed in the meantime. incidentally i’m not explicitly loading the bank in my examples as shown here. i believe if you don’t specify a bank, it will load the MasterBank by default. overall that’s worked best for me. also i had trouble with having any other bank created. as far as i can tell it will not import any bank accurately other than the Master Bank. so you might try leaving the bank load statements out and see what happens.

  • You must to post comments
0
0

[quote="arckex":1tiesll6]My example has a long sound event in the "Master Bank" called "zoomer" with a parameter called "zim" that changes the pitch:
[code:1tiesll6]
using UnityEngine;
using System.Collections;
using FMOD.Studio;

public class sound : MonoBehaviour {
FMOD_StudioSystem soundSystem;
FMOD.Studio.EventInstance zoom;
FMOD.Studio.ParameterInstance pitch;
float pos = 0;

// Use this for initialization
void Start () {
    //Cache the FMOD_StudioSystem instance for easier access
    soundSystem = FMOD_StudioSystem.instance;

    //declare a string variable holding the file name. The Application.dataPath is needed so that
    //the sounds work both in the editor and in standalone builds
    string fileName = Application.dataPath + "/StreamingAssets/Master Bank.bank";

    //Load the FMOD bank
    FMOD.Studio.Bank bank;
    FMOD_StudioSystem.ERRCHECK(soundSystem.System.loadBankFile(fileName, out bank));
    //Also load the corresponding strings bank so that we can find the events by their names
    FMOD.Studio.Bank bankStrings;
    FMOD_StudioSystem.ERRCHECK(soundSystem.System.loadBankFile(fileName + ".strings", out bankStrings));

    zoom = soundSystem.getEvent("/zoomer");
    zoom.getParameter("zim", out pitch);
    zoom.start();
}

// Update is called once per frame
void Update () {

}

void OnGUI()
{
    if (GUI.Button(new Rect(100,100,200,30),"Modify sound"))
    {
        //soundSystem.PlayOneShot("/boo",Vector3.zero);
        pos += .1F;
        pitch.setValue(pos);
    }
}

}
[/code:1tiesll6]
Attach that script to your main camera.
[/quote:1tiesll6]

I copied your code verbatim, and then changed the variable, event, and parameter names to suit my project, and I’m getting the following error:
[code:1tiesll6] error CS1501: No overload for method loadBankFile' takes2′ arguments[/code:1tiesll6]
This is in reference to [code:1tiesll6]FMOD_StudioSystem.ERRCHECK(soundSystem.System.loadBankFile(fileName, out bank));[/code:1tiesll6].

Also, are you sure I want to attach that script to the camera and not the FMOD_Listener script?

I’m also getting these error messages in addition:
[img:1tiesll6]http://i.imgur.com/5lFu6Ck.png[/img:1tiesll6]

Any help? :[

  • You must to post comments
0
0

Very cool, thank you! I was just about to get into this myself.You probably saved me a LOT of time.

  • You must to post comments
0
0

Thanks for posting this I’m sure a lot of users will find it very helpful, I will sticky this thread so people see it.

The resources for the Unity integration are rather scarce at the moment, but I assure you we are working on it and expect to have documentation and examples coming soon.

  • You must to post comments
0
0

thanks very much for this information! i do have to say, though that i’m a little confused. i learned my method using instance.getEvent, and this seems to work, but only for 2D sounds. i tried the OneShot approach earlier in a different way and i wasn’t apparently instancing correctly, so i gave up and tried this approach instead. will this OneShot method outlined work on 3D Events? in my example i set up my code like this:

fmodEvent = FMOD_StudioSystem.instance.getEvent(selectedClass.path);
fmodEvent.start();

and

fmodEvent.stop();

but my sounds cannot be 3D sounds in this way. or at least my experimenting leads me to that conclusion. what’s a simple solution to play and stop 3D sounds?

Update – i did not put the ‘using FMOD.Studio;’ namespace inclusion at the top of my test file, but i did explicitly call Studio functions like PLAYBACK_STATE with no issue. don’t know if that could be a factor in not getting 3D?

any help appreciated – wasn’t sure if posting on a stickied topic is OK – some forums have issues with it….

scott

  • You must to post comments
0
0

This should be a different topic, but this should help:
I’m [code:2b8eh6pb]using FMOD.Studio;[/code:2b8eh6pb]

"zoom" below is a[code:2b8eh6pb]FMOD.Studio.EventInstance zoom;
zoom = soundSystem.getEvent("/Rocks/rockShoot");[/code:2b8eh6pb]
or similar

[code:2b8eh6pb]Vector3 pos = new Vector3(20,0,0); //sound is at x=20 relative to listener
Vector3 up = new Vector3(0,1,0); //y is up
Vector3 vel = new Vector3(0,0,0); // not moving
_3D_ATTRIBUTES my3dPos = new _3D_ATTRIBUTES();
my3dPos.position=FMOD.Studio.UnityUtil.toFMODVector(pos);
my3dPos.up=FMOD.Studio.UnityUtil.toFMODVector(up);
my3dPos.velocity=FMOD.Studio.UnityUtil.toFMODVector(vel);
zoom.set3DAttributes(my3dPos);[/code:2b8eh6pb]

and
the included FMOD_StudioEventEmitter class (which is a good general basis to use/look at) passes the game object directly like this
[code:2b8eh6pb]var attributes = UnityUtil.to3DAttributes (gameObject);
ERRCHECK (evt.set3DAttributes(attributes));[/code:2b8eh6pb]

which i dont fully understand, but i’m sure it’s doing the same things, just behind the scenes and with a lot of trust

i didn’t actually test this, but I’m 85% sure I did this one time and it works. You should post your results here

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.