FMODUnity plugin released

John McCormick has finished the FMOD plugin for Unity, and we are releasing it open source. The plugin allows sound designers to use the FMOD designer to create interactive audio for Unity projects. FMOD is a library and toolkit for the creation and playback of interactive audio, widely used in the games industry. Unity is a multiplatform game development tool. The plugin works in the “indie” and “pro” versions of Unity on both Mac and Windows. You can download the plugin from our FMODUnity Plugin page. It is released under the MIT open source license, which allows anybody to use and/or modify the software without restriction. We hope the wider community benefits from this plugin. If anyone has any questions, comments or feedback please leave them in the comments of this post. If demand is sufficient, we’ll set up a dedicated forum, but in the meantime, this should suffice.

Tags: , , , , , ,

49 Responses to “FMODUnity plugin released”

  1. Adam says:

    Testing the comments. We’re very proud to release this plugin to the community, and hope it is of benefit to sound designers, artists and programmers everywhere! Adam

  2. andrew says:

    thanks so much for this… finally the potential for real audio occlusion (amongst so many other possibilities) in Unity… This plugin is pretty much the missing link that enables Unity to be a solid tool for artists (etc.) interested in using audio in their projects. Thanks again for sharing your work. andrew

  3. Adam says:

    Thanks Andrew, it’s good to hear you find it so useful. Please let us know how it performs in production, or if you make any mods to it – we’re very keen to hear how well it serves the needs of artists. Cheers. Adam

  4. Luke says:

    I’m really excited by this project, good work. However I do have some issues with it.

    My main issue that is stopping me from using the library is I can’t seem to return any spectrum data using the getSpectrum functions. Are you aware of any problems in this area? Is anyone else able to return spectrum data? Any help would be greatly appreciated! Luke

  5. Adam says:

    Hi Luke,
    Thanks for the feedback. We haven’t really looked at the getSpectrum functions, but John is going to have a look and get back to you with an example if he can. Time is a rare resource at the moment though :) In the meantime, check out this thread in the Unity forums, where a user has been working in Unity with spectrum data from FMOD, assumedly using our plugin:
    http://forum.unity3d.com/viewtopic.php?t=30300&postdays=0&postorder=asc&highlight=fmod&start=15
    and check back here for an example, or let us know how to contact you and we’ll let you know when we’ve got one. Cheers,
    Adam.

  6. Luke says:

    Hi Adam,
    Thanks for the reply! Sorry to waste your time but it seems as though that in my excitement I was using the incorrect spectrum sizes (not 512, 1024 etc), and the function actually works fine! So thanks again for putting this all together and I look forward to working with the wrapper some more.
    Luke

  7. GuitarGuy91403 says:

    Hello, your FMOD plugin for Unity is great! Thank you! I’m trying to use it for my indie software development. Does FMOD for Unity support recording sounds?
    I’m trying to use system.createSound, but it’s asking for a string as the first parameter:

    system.createSound(0, FMOD.MODE.SOFTWARE, ref exinfo, ref sound);

    however, the C++ examples documentation has an integer:

    system->createSound(0, FMOD_SOFTWARE, &exinfo, &sound);

    how do I work around this?

    Thanks again, maximum respect,
    GuitarGuy91403

  8. Johnny Tangle says:

    Hi GuitarGuy91403,
    here is how i use it from the example in C#:
    result = system.createSound(“Assets/FMOD/drumloop.wav”, FMOD.MODE.HARDWARE, ref sound1);
    ERRCHECK(result);
    the first parameter is a string containing the file to play.

    You could also do:
    private string soundFile = “Assets/FMOD/jaguar.wav”;

    result = system.createSound(soundfile, FMOD.MODE.HARDWARE, ref sound1);

    If you can, download the windows version of FMOD and extract the C# examples. They should be better for use in unity than the C++ examples.
    jt

  9. GuitarGuy91403 says:

    Hi this is a followup to the above post:

    I’ve been using the FMOD/Unity plugin and so far so good! Really cool.
    DSP, multi-channel, getSpectrum all work –

    However, I can’t get the following to work:

    C++ code, provided in the FMOD examples:

    system->createSound(0, FMOD_2D | FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);

    The above works fine, when I build & run from Mac OS X 10.5.8 XCode.

    However, when I convert the above C++ to C# to be used with Unity, here is the C# code:

    system.createSound( 0 , FMOD.MODE._2D | FMOD.MODE.SOFTWARE | FMOD.MODE.OPENUSER , ref exinfo, ref sound);

    I get errors:

    Argument 1: Cannot convert type `int’ to `string’

    What is the proper way to create the sound?

    Thank you, maximum respect, GuitarGuy91403

  10. GuitarGuy91403 says:

    jt,

    thank you for the reply. The plugin is great…

    “If you can, download the windows version of FMOD and extract the C# examples. They should be better for use in unity than the C++ examples.”

    …giving it a try right now… thank you again

    maximum respect,
    GuitarGuy91403

  11. GuitarGuy91403 says:

    jt

    thank you for the tip. I downloaded the C# examples and did get it to work, but it was not as the example given.

    Here’s the code as provided in the pitchdetection csharp example:
    result = system.createSound((string)null, (FMOD.MODE._2D | FMOD.MODE.SOFTWARE | FMOD.MODE.OPENUSER), ref exinfo, ref sound);

    Here’s my work around to get Unity3D to accept it:
    result = system.createSound(“loadshort.wav”, (FMOD.MODE.SOFTWARE | FMOD.MODE.LOOP_NORMAL), ref sound);

    And after the system plays “loadshort.wav” it plays the computer system’s input with a slight latency.

    So it’s just a stop gap for now. I admit that I’m probably doing something wrong – I hope that I can discover what that is while I’m pushing forward on other things – maybe the solution will present itself.

    thanks again jt.

    Maximum respect
    GuitarGuy91403

  12. broodriech says:

    Thanks again for doing this. I’m a sound designer with some basic scripting experience, trying to extend your PlayExEvent script so that I can enter banks, categories, and events as public variables, to be able to use this script as a generic event playback script.

    I’m getting an FMOD initialization error in my project when using your plug-in and code samples, where FMOD cannot initialize (in the Start() function) because it says it’s being called after System::init. Do I need to include this script somewhere or reference something else to get it to work with a different project?

    thanks,
    b

  13. johnny tangle says:

    Hi GuitarGuy91403,
    I did a project with pitch detection. worked ok. I’ll look through the project and post the relevant parts shortly. maybe you already got this figured.
    @broodriech I’ve had this error before, sorry can’t remember the circumstances. make sure you copy the fmod libraries (not our plugin, the original libraries) into the root of your project. if you still have trouble, let me know.
    best
    jt

  14. hajasal_sk says:

    Has anyone here been able to get interactive-music playing with this plugin inside Unity?

    Everything runs without error here, but I can’t get the music to actually play.

  15. Adam says:

    Hi hajasal_sk, apologies for delay in reply, we’ve been travelling. Unfortunately, I’m having the same trouble as you – the code runs without error, but no music actually plays! Working on it now, will let you know when we work it out. Please let us know if you work it out in the meantime :)
    cheers,
    Adam

  16. hajasal_cr says:

    Hey Adam,
    Just want to let you know that hajasal_sk and I got it working. The confusion was actually just because of the iterator which I think may have been returning a pointer when using getCues(). Hard-coding a 1 fixed it. I’m not sure if this is working as intended or if something was lost in fmod_event.cs.

  17. Adam says:

    Thanks hajasal_cr, I had the same problem and also fixed it by giving the Id of the Music Cue as an integer (which can be found in the programmer’s report generated when building the FMOD project) in the argument to prepareCue().

    For everybody’s reference, here’s how to get the Interactive Music system working (refer to the FMOD_Event_Test script in the FMODUnity demo for usage):

    Initialise it with:
    private FMOD.MusicSystem musicsystem = null;
    private FMOD.MusicPrompt musiccue = null;

    prepare it with:
    result = eventsystem.getMusicSystem(ref musicsystem);
    ERRCHECK(result);

    result = musicsystem.prepareCue(1, ref musiccue); //find the cue number in the programmer’s report generated when building the fmod project
    ERRCHECK(result);

    then play the cue with:
    result = musiccue.begin();
    ERRCHECK(result);

    and stop it with:
    result = musiccue.end();
    ERRCHECK(result);

    Cheers,
    Adam

  18. songclass says:

    Hello.

    I need to record voice in Unity3D, so I plugin with FMOD.
    However, I can’t use well since there aren’t enough example code in website.
    I found methods in FMOD about recording.

    public RESULT getRecordNumDrivers (ref int numdrivers)
    {
    return FMOD_System_GetRecordNumDrivers(systemraw, ref numdrivers);
    }
    public RESULT getRecordDriverInfo (int id, StringBuilder name, int namelen, ref GUID guid)
    {
    return FMOD_System_GetRecordDriverInfo(systemraw, id, name, namelen, ref guid);
    }

    public RESULT getRecordPosition (int id, ref uint position)
    {
    return FMOD_System_GetRecordPosition(systemraw, id, ref position);
    }
    public RESULT recordStart (int id, Sound sound, bool loop)
    {
    return FMOD_System_RecordStart(systemraw, id, sound.getRaw(), loop);
    }
    public RESULT recordStop (int id)
    {
    return FMOD_System_RecordStop(systemraw, id);
    }
    public RESULT isRecording (int id, ref bool recording)
    {
    return FMOD_System_IsRecording(systemraw, id, ref recording);
    }

    Please give me some example code that I can use these methods.
    I need to record my voice in Unity. Please help me!

  19. Richard Dekkard says:

    Does using this require the dll to be downloaded to the user at runtime if they are playing through a web browser?

  20. Adam says:

    Hi Richard, you won’t be able to use this with the Unity web player. We haven’t had a chance to look at that side of things yet, since we ourselves are working with standalone Unity apps. The code is completely open though, so you’re welcome to play around with it. Let us know if you do manage to get it working. Cheers, Adam.

  21. hajasal_cr says:

    Hey guys,
    I figured out the problem with the MUSIC_ITERATOR and getCues. It’s also a problem with getParameters, which I really needed to work(hard coding a 1 wasn’t going to cut it). Anyway, the IntPtr MUSIC_ITERATOR.value is pointing into some unmanaged struct that needs to be copied into a managed MUSIC_ENTITY. I stuck this little function into the musicSystem to make it easier for myself:

    public MUSIC_ENTITY getMusicEntity(MUSIC_ITERATOR it){
    return (MUSIC_ENTITY)Marshal.PtrToStructure(it.value,typeof(MUSIC_ENTITY));
    }

    Not a lot of code but it took me long enough to figure out that I figured it would be worth sharing here. You guys might want to add something a little more elegant to the API. I guess you’d need a MUSIC_INTERATOR_RAW with the IntPtr and then have MUSIC_ITERATOR.value actually point to a MUSIC_ENTITY that you can marshal in behind the scenes. If I end up coding something like that in the next few days I’ll post it as a patch here.

    -Clayton Rabenda

  22. marco says:

    hi guys,
    thanks for your plugin. i have a problem initializing it with a custom library. when i just run your demo it works like a charm. as soon as i change anything i get the same error broodriech has experienced:

    “…where FMOD cannot initialize (in the Start() function) because it says it’s being called after System::init…”

    is this because of unity2.6.1 or something else!?

    thanks in advance!
    marco

  23. Marbar says:

    @ marco (and whoever else has been having this problem)

    I have only just begun experimenting with this plugin, and I have been experiencing the same problems. I have discovered, through experimentation, that replacing the prebuilt “AudioManager.asset” in the library folder with SquareTangle’s makes it mysteriously begin to work. It may be because of newer versions of Unity changing the way it works. I would try that, and if it doesn’t work, well maybe we could get a proper users manual here sometime??? Instead of a vague “put these files here and it should work”.

  24. Graeme says:

    Hi, I’m a sound designer who has been using FMOD for a while now but am integrating it into Unity for the first time for a game I’m working on. My only experience with programming is MAX/MSP. I don’t understand how to get my FMOD Designer events into Unity. There is no instructions on how to do this. Can anyone help me? Be as patronising as you want!

  25. Graeme says:

    Oh yeah I’m currently in the prestigious Dare to be Digital game development competition so a quick response would be huuuugely appreciated!

  26. Adam says:

    @Graeme, here is some C# script that demonstrates how to get your FMOD Designer events working in Unity. Once you’ve output a .fev file from your FMOD Designer, you can access any parameters you’ve defined. In this example, there is one parameter called “myDistance” and the script maps the First Person Controller’s Z position to the scale (0-100) defined in the myDistance parameter in FMOD Designer. Apologies for the lack of documentation, but we really threw this together for the specific needs of a project we are working on, and released it here so that others can build on it.
    [begin code]

    using UnityEngine;
    using System;
    using System.Collections;

    public class Brain : MonoBehaviour {
    private FMOD.EventSystem eventsystem = null;
    private FMOD.EventGroup eventgroup = null;
    private FMOD.EventCategory mastercategory = null;
    private FMOD.Event synth = null;
    private FMOD.EventParameter proximity = null;
    float rangemin, rangemax;
    public FMOD.RESULT result;
    new GameObject myPlayer;
    float playerZ;

    // Use this for initialization
    void Start () {

    result = FMOD.Event_Factory.EventSystem_Create(ref eventsystem);
    ERRCHECK(result);

    result = eventsystem.init(64, FMOD.INITFLAG.NORMAL, (IntPtr)null, FMOD.EVENT_INIT.NORMAL);
    ERRCHECK(result);
    if (result == FMOD.RESULT.OK)
    {
    Debug.Log("FMOD init! " + result );
    }

    result = eventsystem.setMediaPath("Assets/Media/");
    ERRCHECK(result);

    result = eventsystem.load("linz1.fev"); //.fev file output from FMOD Designer
    ERRCHECK(result);

    result = eventsystem.getCategory("master", ref mastercategory);
    ERRCHECK(result);

    result = eventsystem.getGroup("linz1/linz1", false, ref eventgroup);
    ERRCHECK(result);

    result = eventgroup.getEvent("linz1_1", FMOD.EVENT_MODE.DEFAULT, ref synth);
    ERRCHECK(result);

    result = synth.getParameter("myDistance", ref proximity); //paramter defined in FMOD Designer
    ERRCHECK(result);

    result = proximity.getRange(ref rangemin, ref rangemax);
    ERRCHECK(result);

    result = proximity.setValue(0.0f);
    ERRCHECK(result);

    myPlayer = GameObject.Find("First Person Controller");

    }

    // Update is called once per frame
    void Update () {
    if(Input.GetKeyDown("s")){ result = synth.start();ERRCHECK(result); }
    else if(Input.GetKeyDown("x")){ result = synth.stop();ERRCHECK(result); }
    playerZ = myPlayer.transform.position.z;
    if(playerZ < 0) {
    result=proximity.setValue(0.0f);ERRCHECK(result);
    }
    else if(playerZ<100) {
    result=proximity.setValue(playerZ);ERRCHECK(result);
    }
    if(playerZ > 100) {
    result=proximity.setValue(100.0f);ERRCHECK(result);
    }

    result=eventsystem.update();
    ERRCHECK(result);

    }

    void OnDisable() {
    //cleanup routine here
    /*
    Shut down
    */
    FMOD.RESULT result;
    result = eventgroup.freeEventData();
    ERRCHECK(result);
    result = eventsystem.release();
    ERRCHECK(result);
    }

    void ERRCHECK(FMOD.RESULT result)
    {
    if (result != FMOD.RESULT.OK)
    {
    Debug.Log("FMOD error! " + result + " - " + FMOD.Error.String(result));
    }
    }
    }

    [end code]

  27. Graeme says:

    @Adam, Thanks for the quick response! I’ve tried creating a similar project with the same filenames etc as your example just to get something working for my programmers to get an idea of how to use it. I keep getting a Nullreference error on line 61 of your script. I don’t think this is actually the problem as I don’t see anything wrong with that line. What version of Unity and FMOD are you using? Which parts of your script do I need to change for my own use? Sorry, I’m very new to Unity and my programmers are very new to FMOD!

  28. Graeme says:

    Sorry, it’s a NullReferenceException error

  29. Adam says:

    @Graeme – not sure, I’m currently working on a different project, but will be back on using FMOD and Unity within the next couple of days, so you and your programmers are going to have to battle on until then I’m afraid :( In the meantime, some students have been using the plugin in a game project, and have documented their process here:
    https://www.assembla.com/wiki/show/BlindGame/FMOD_Scripts_Usage
    and you can download the support scripts they wrote here:
    https://www.assembla.com/spaces/BlindGame/documents/aXpXfWCgir35WeeJe5cbLA/download/FMODUnity_Examples.zip
    Once again, sorry for the lack of docs, but I’ll try to update all this once I’m back working in the Unity environment full time.
    Best of luck!
    Adam

  30. Graeme says:

    @Adam – Thanks so much for all your help. I’m slowly getting over hurdles but unfortunately keep encountering new ones. The BlindGame guy (Keiren) seems to know what he is doing and has written a load of useful looking scripts. Unfortunately I can’t seem to get them to work and have no way of contacting him. I now have your FMODEvent example working just don’t know how to apply it to my own work. Do you know if there is any way of finding the Blindgame peoples contact details through Assembla? An example project would do wonders for helping me understand their scripts.

  31. Graeme says:

    @Adam – Just to let you know I seem to have gotten my events up and running in Unity. Let us know when you’re back on FMOD/Unity!

  32. KEN says:


    Medicamentspot.com. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Best quality drugs. High quality drugs. Buy drugs online

    Buy:Viagra Super Force.Viagra Soft Tabs.Levitra.Cialis.Viagra Super Active+.Soma.Zithromax.Cialis Super Active+.Super Active ED Pack.Cialis Soft Tabs.Maxaman.Viagra Professional.Tramadol.Viagra.Cialis Professional.Propecia.VPXL….

  33. David Plans says:

    Hey Adam

    Just wondering if you’re back working on FMOD/Unity. I’m testing out FMOD’s new iphone target, which works great…and I would love to get the pitchdetection example working in Unity using it…so I can teach it this Fall term.

    But of course, the last compile you guys did targeted Unity standalone, etc.

    Are you planning to do another release at all?

    david

  34. Adam says:

    Hi David,
    We haven’t had much of a chance to look at this recently, being super busy with projects, and the current build of the FMODUnity plugin suits our needs just fine as we’re only targeting the standalone. It will be a while before we’re able to update it, but the code is open source (MIT license), and quite simple, so please feel free to update it. Let us know if you get something working, and we can post it here or link to you if you’d like. Good luck with it, and we’ll let you know when we get time to look at it again.
    Kind regards,
    Adam

  35. David Plans says:

    Ok thanks Adam, we’ll give it a try and report if we get something working.

    David

  36. 380SL says:

    380SL http://fxr.5jp.ll0.co : Sale…

    Mercedes…

  37. David Plans says:

    Hi Adam…been working with the FMOD Unity plugin, having fun. thanks again.

    Just now, I’m trying to compile the .dll using the iphone FMOD target, so I went into fmod.cs and changed public class VERSION to:

    public const string dll = “libfmodexL_iphoneos”;

    and gave the monodevelop project a .config file with:

    tried both libfmodex.dylib and libfmodexL_iphoneos.a but both give me:

    Exception: Failed AOT cross compiling FMODUnity.dll

    when I try to build from unity iphone pro…

    I know you guys are busy elsewhere, but I’d really appreciate any thoughts you might have on how to solve this?

    David

  38. David Plans says:

    sorry, the config file I mention (but fail to paste) above is:

  39. David Plans says:

    ARGH. xml being excepted. anyway, I made a config file that points to right libs…

  40. johnny says:

    Hi David
    we haven’t looked into fmod for iphone as we have focused on larger screen environments. i will have a look soon to see what might be possible. there are some limitations in that i believe unity iphone is .NET 1.1 only, so some things in the plugin may not work and there are memory limitations when using the iphone platform. again i can’t speak with authority at this stage having not looked into it yet. i will let you know if we have any success with iphone fmod, please let us know if you have same.
    best
    jt

  41. David Plans says:

    Great, thanks Johnny. I’ll keep looking into it. Let me know if you manage to compile an iphone version…I’ll keep trying.

  42. toltoly says:

    App randomly get null exception error when it calls release function at OnDisable()

    this is release function.
    public void release()
    {
    //cleanup routine here

    //Shut down
    FMOD.RESULT result;

    if (fmod_sounds != null)
    {
    for (int i=0; i<fmod_sounds.Length; i++)
    {
    if (fmod_sounds[i] != null)
    {
    result = fmod_sounds[i].release();
    fmod_sounds[i] = null;
    ERRCHECK(result);
    }
    }
    }

    if (system != null)
    {

    result = system.close();
    ERRCHECK(result);
    result = system.release();
    system = null;
    ERRCHECK(result);
    Debug.Log("FMOD release! " + result );

    }
    }

    and this is error log.

    at (wrapper managed-to-native) FMOD.System.FMOD_System_Close (intptr)
    at (wrapper managed-to-native) FMOD.System.FMOD_System_Close (intptr)
    at FMOD.System.close ()
    at FMOD_AudioControl.release ()
    at AudioControl.OnDisable ()
    at (wrapper runtime-invoke) EulaManager.runtime_invoke_void (object,intptr,intptr,intptr)
    Receiving unhandled NULL exception
    Trying to recover from null exception

  43. CLYDE says:

    Cialis UK

    Buygeneric meds…

  44. SERGIO says:

    aloe@vera.gel.indicatii” rel=”nofollow”>…

    Buygeneric drugs…

  45. ENRIQUE says:

    Aricept@official.site” rel=”nofollow”>.

    Buynow…

  46. JORDAN says:

    < a href="http://my.gardenguides.com/members/buy-Cialis? buy@Cialis.now

    Buydrugs without prescription…

  47. RON says:

    cheap@Viagra.now” rel=”nofollow”>…

    Buygeneric pills…

  48. Adam says:

    Disabling comments on the blog – too much spam. As much as I love sentences like “This will be an exceedingly heavy imagination that you are furnishing”, it’s too much to keep up with. If you really have a comment or question please send it to info at squaretangle dot com

    Adam