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. INTERNATIONAL CONCEPT OF WORK FROM HOME
    Work from home theory is fast gaining popularity because of the freedom and flexibility that comes with it. Since one is not bound by fixed working hours, they can schedule their work at the time when they feel most productive and convenient to them. Women & Men benefit a lot from this concept of work since they can balance their home and work perfectly. People mostly find that in this situation, their productivity is higher and stress levels lower. Those who like isolation and a tranquil work environment also tend to prefer this way of working. Today, with the kind of communication networks available, millions of people worldwide are considering this option.

    Women & Men who want to be independent but cannot afford to leave their responsibilities at home aside will benefit a lot from this concept of work. It makes it easier to maintain a healthy balance between home and work. The family doesn't get neglected and you can get your work done too. You can thus effectively juggle home responsibilities with your career. Working from home is definitely a viable option but it also needs a lot of hard work and discipline. You have to make a time schedule for yourself and stick to it. There will be a time frame of course for any job you take up and you have to fulfill that project within that time frame.

    There are many things that can be done working from home. A few of them is listed below that will give you a general idea about the benefits of this concept.

    Baby-sitting
    This is the most common and highly preferred job that Women & Men like doing. Since in today's competitive world both the parents have to work they need a secure place to leave behind their children who will take care of them and parents can also relax without being worried all the time. In this job you don't require any degree or qualifications. You only have to know how to take care of children. Parents are happy to pay handsome salary and you can also earn a lot without putting too much of an effort.

    Nursery
    For those who have a garden or an open space at your disposal and are also interested in gardening can go for this method of earning money. If given proper time and efforts nursery business can flourish very well and you will earn handsomely. But just as all jobs establishing it will be a bit difficult but the end results are outstanding.

    Freelance
    Freelance can be in different wings. Either you can be a freelance reporter or a freelance photographer. You can also do designing or be in the advertising field doing project on your own. Being independent and working independently will depend on your field of work and the availability of its worth in the market. If you like doing jewellery designing you can do that at home totally independently. You can also work on freelancing as a marketing executive working from home. Wanna know more, email us on workfromhome.otr@gmail.com and we will send you information on how you can actually work as a marketing freelancer.


    Internet related work
    This is a very vast field and here sky is the limit. All you need is a computer and Internet facility. Whatever field you are into work at home is perfect match in the software field. You can match your time according to your convenience and complete whatever projects you get. To learn more about how to work from home, contact us today on workfromhome.otr@gmail.comand our team will get you started on some excellent work from home projects.


    Diet food
    Since now a days Women & Men are more conscious of the food that they eat hence they prefer to have homemade low cal food and if you can start supplying low cal food to various offices then it will be a very good source of income and not too much of efforts. You can hire a few ladies who will help you out and this can be a good business.

    Thus think over this concept and go ahead.

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

    ReplyDelete
  11. 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