Thursday, October 17, 2013

Unity and FMOD Studio integration

Edit 12 June 2014: This post was based on the very first FMOD Unity integration from fall 2013. There's been changes and the project file should probably be updated. Please (also) check some more recent tutorials.

There's finally an official FMOD Studio integration for Unity, available from http://www.fmod.org/download/. It has just been released and contains no Unity examples, so I prepared a bare bones Unity project and an example FMOD Studio project that you can download from here https://www.dropbox.com/s/vyk29kyhmvm22dc/part6_sound.zip

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. Using FMOD studio, you can also create, e.g., a footstep sound event that will randomize the pitch and selected sound sample without the game having to know anything else than the name of the event. Using FMOD is free for non-commercial purposes and the license prices are also pretty reasonable for commercial work.

Most commercial games with decent sound design use such live mixing and centralized sound management approach, either using FMOD, WWise or some custom tools. Unity does use fmod for its own sound, but it does not provide any mixing tools and a sound designer will go insane if he/she has to manage hundreds of sound objects in the Unity editor. The main limitation of the FMOD Studio integration is that it only supports iOS, Android, Windows, Mac but no web player. If you want your sounds to work in the web player, I suggest you check out the Clockstone Audio Toolkit that provides mixing and management on top of Unity's internal sound system.

Here are the steps you need to add FMOD Studio support to your Unity project. These instructions can also be found in the readme.txt of the .zip above.

  1. Import the fmodstudio10203.unitypackage from this folder. You can also check for a later version from fmod.org. To import in Unity editor, select Assets/Import Package/Custom package.
  2. build your FMOD banks (File/Build)
  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. 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 the Start() method in main.cs)
  5. Use the FMOD_StudioSystem helpers such as PlayOneShot() to play sound. See the OnGUI() method of main.cs. You might also have to use the lower level API (fmod.cs, fmodstudio.cs), as the unity integration package has been released very recently. The integration package doesn't contain any examples, and for example code, you should consult the c++ examples in the FMOD Studio API install, which you  can download from fmod.org.
  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. You'll find that 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. 

13 comments:

  1. on android device, it doesnt' works.. what should i do?

    ReplyDelete
    Replies
    1. I'm sorry, but I can't help you. I've only tested it on Windows, and I supposed it should work on other platforms based on what's claimed at fmod.org and because the project's plugins folder does have the plugins for all platforms.

      Delete
  2. I think
    soundSystem.System.load
    is now
    soundSystem.System.loadBankFile

    Also, I had trouble opening your Unity project by itself, it complained about needing a Pro license for Unity and got me worried. But using your info, I was able to tie in a new Unity project to your FMOD project and it works beautifully. So thank so much, I'm really excited about live FMOD stuff in Unity.

    ReplyDelete
  3. also, i think in step 2 you need to keep "exporting GUIDs" as well. i dont think that file is automatically regenerated in the build process

    ReplyDelete
  4. This was exactly what I was looking for, thank yo so much!
    I had the same 2 issues as andy mule, but was also able to fix them using his steps.

    1) I had an error saying the plugin needed a unity pro license, but when I created a blank project and copied over your scene and main.cs script, I was up and running.

    2) I had an error saying it didn't recognize "load" but when I changed it to ".loadBankFile" it worked.

    Cheers,

    ReplyDelete
  5. I think you all have to take a look to this documentation. At the time being, if you want things to work, this is the correct implementation! http://www.fmod.org/files/UnityDocumentation.pdf

    ReplyDelete
  6. Hey There I am having a problem with my integration. I have managed to get FMOD into unity, and after i go to FMOD/Refresh Event List it creates a streaming assets folder, but not an FMODAssets. So there are no imported events for me to put into to the event emmiter script so i can play audio. I have very little knowledge about scripting or unity in general so not sure if theres something I'm missing. Any help would be great

    ReplyDelete
  7. Hi there,
    Thanks for this awesome article. I managed to integrate FMod with Unity, and I am also manging to control parameters of events. However I ran into the following problem and was wondering wheter you can help me.

    In one of my events, I have an event sound (which is kind of like an event within another event) which has it's own parameter. Is there a way to get a handle on that parameter and control it?

    ReplyDelete
  8. I think you all have to take a look to this documentation. At the time being, if you want things to work, this is the correct implementation! http://www.fmod.org/files/UnityDocumentation.Thanks.
    Angry Birds Games

    ReplyDelete
  9. You wrote have been too good, I agreed that your viewpoint, my idea was I likes very much
    office installation companies Chicago

    ReplyDelete
  10. Thanks for sharing it. It is extremely valuable information for all. I will recommend my friends to read this for sure.
    If you love gaming for unity games kindly visit….
    Unity game templates

    ReplyDelete
  11. This is so amazing post very interesting.Keep sharing dude.Well done.
    Download Latest Version Unity Pro Crack

    ReplyDelete