initialize() public method

public initialize ( int maxchannels, INITFLAGS studioFlags, FMOD flags, IntPtr extradriverdata ) : RESULT
maxchannels int
studioFlags INITFLAGS
flags FMOD
extradriverdata System.IntPtr
return RESULT
Beispiel #1
0
 static void Main(string[] args)
 {
     FmodErrorCheck(FMOD.Studio.System.create(out FmodSystem));
     FMOD.System lls;
     FmodErrorCheck(FmodSystem.getLowLevelSystem(out lls));
     FmodErrorCheck(FmodSystem.initialize(1024, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero));
     ConsoleMain();
 }
Beispiel #2
0
        static void Main()
        {
            FmodErrorCheck(FMOD.Studio.System.create(out FmodSystem));
            FMOD.System lls;
            FmodErrorCheck(FmodSystem.getLowLevelSystem(out lls));
            //FmodErrorCheck(lls.setDSPBufferSize(480, 2), "System.setDSPBufferSize");
            FmodErrorCheck(FmodSystem.initialize(1024, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero));

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(mainForm = new MainForm());
        }
Beispiel #3
0
        public void InitializeFmod()
        {
            LoadNativeLibrary("fmod");
            LoadNativeLibrary("fmodstudio");

            RESULT res;

            res = FMOD.Studio.System.create(out _system);
            res = _system.getCoreSystem(out _coresystem);
            res = _coresystem.setSoftwareFormat(0, SPEAKERMODE.DEFAULT, 0);
            res = _system.initialize(1024, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
        }
    static bool CreateSystem()
    {
        if (!FMOD.Studio.UnityUtil.ForceLoadLowLevelBinary())
        {
            return(false);
        }

        if (!ERRCHECK(FMOD.Studio.System.create(out sFMODSystem)))
        {
            return(false);
        }

        // Note plugins wont be used when auditioning inside the Unity editor
        ERRCHECK(sFMODSystem.initialize(256, FMOD.Studio.INITFLAGS.ALLOW_MISSING_PLUGINS, FMOD.INITFLAGS.NORMAL, System.IntPtr.Zero));

        return(true);
    }
Beispiel #5
0
    void Init()
    {
        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: Initialize");

        if (isInitialized)
        {
            return;
        }

        DontDestroyOnLoad(gameObject);

        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: System_Create");
        ERRCHECK(FMOD.Studio.System.create(out system));

        FMOD.Studio.INITFLAGS flags = FMOD.Studio.INITFLAGS.NORMAL;

#if FMOD_LIVEUPDATE
        flags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;
#endif

        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: system.init");
        FMOD.RESULT result = FMOD.RESULT.OK;
        result = system.initialize(1024, flags, FMOD.INITFLAGS.NORMAL, global::System.IntPtr.Zero);

        if (result == FMOD.RESULT.ERR_NET_SOCKET_ERROR)
        {
#if false && FMOD_LIVEUPDATE
            FMOD.Studio.UnityUtil.LogWarning("LiveUpdate disabled: socket in already in use");
            flags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
            result = system.init(1024, flags, FMOD.INITFLAGS.NORMAL, (System.IntPtr)null);
#else
            FMOD.Studio.UnityUtil.LogError("Unable to initalize with LiveUpdate: socket is already in use");
#endif
        }
        else if (result == FMOD.RESULT.ERR_HEADER_MISMATCH)
        {
            FMOD.Studio.UnityUtil.LogError("Version mismatch between C# script and FMOD binary, restart Unity and reimport the integration package to resolve this issue.");
        }
        else
        {
            ERRCHECK(result);
        }

        isInitialized = true;
    }
        public static void Initialize()
        {
            CheckResult(FMOD.Studio.System.create(out system));
            CheckResult(system.initialize(512, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero));
            CheckResult(system.loadBankFile(@"assets\Audio\Desktop\Master.bank", LOAD_BANK_FLAGS.NORMAL, out _));
            CheckResult(system.loadBankFile(@"assets\Audio\Desktop\Master.strings.bank", LOAD_BANK_FLAGS.NORMAL, out _));

            cachedEventDescriptions = new Dictionary <string, EventDescription>();
            attributes3d            = new ATTRIBUTES_3D
            {
                forward = new VECTOR {
                    x = 0f, y = 0f, z = 1f
                },
                up = new VECTOR {
                    x = 0f, y = 1f, z = 0f
                }
            };
        }
Beispiel #7
0
        public System(int maxChannels = 1024, InitFlags flags = InitFlags.LiveUpdate, LowLevelInitFlags lowLevelFlags = LowLevelInitFlags.Normal, AdvancedInitializationSettings advancedSettings = default(AdvancedInitializationSettings), Action <IPreInitilizeLowLevelSystem> preInit = null)
        {
            //Load native dependencies
            Native.Load();

            //Create studio system
            FMOD.Studio.System.create(out _system).Check();

            //Create low level system
            FMOD.System lowLevel;
            _system.getLowLevelSystem(out lowLevel).Check();
            LowLevelSystem = new LowLevelSystem(lowLevel);

            if (preInit != null)
            {
                preInit(LowLevelSystem);
            }

            //Set advanced settings
            LowLevelSystem.SetAdvancedSettings(advancedSettings);

            //Initialize
            _system.initialize(maxChannels, (INITFLAGS)flags, (FMOD.INITFLAGS)lowLevelFlags, IntPtr.Zero).Check();
        }
Beispiel #8
0
    void Init()

    {
        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: Initialize");



        if (isInitialized)

        {
            return;
        }



        DontDestroyOnLoad(gameObject);



        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: System_Create");

        ERRCHECK(FMOD.Studio.System.create(out system));



        FMOD.Studio.INITFLAGS flags = FMOD.Studio.INITFLAGS.NORMAL;



#if FMOD_LIVEUPDATE
        flags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;
#endif



#if true //UNITY_ANDROID && !UNITY_EDITOR
         // Force the system sample rate to the output rate to allow for the fast mixer

        if (FMOD.VERSION.number >= 0x00010500)

        {
            FMOD.System sys;

            ERRCHECK(system.getLowLevelSystem(out sys));

            int outputRate = 48000;

            {
                System.Text.StringBuilder str = new System.Text.StringBuilder();

                FMOD.GUID guid;

                FMOD.SPEAKERMODE speakermode;

                int speakermodechannels;

                ERRCHECK(sys.getDriverInfo(0, str, str.Capacity, out guid, out outputRate, out speakermode, out speakermodechannels));
            }



            ERRCHECK(sys.setSoftwareFormat(outputRate, FMOD.SPEAKERMODE.DEFAULT, 0));
        }
#endif



        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: system.init");

        FMOD.RESULT result = FMOD.RESULT.OK;

        result = system.initialize(1024, flags, FMOD.INITFLAGS.NORMAL, global::System.IntPtr.Zero);



        if (result == FMOD.RESULT.ERR_NET_SOCKET_ERROR)

        {
#if false && FMOD_LIVEUPDATE
            FMOD.Studio.UnityUtil.LogWarning("LiveUpdate disabled: socket in already in use");

            flags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;

            result = system.init(1024, flags, FMOD.INITFLAGS.NORMAL, (System.IntPtr)null);
#else
            FMOD.Studio.UnityUtil.LogError("Unable to initalize with LiveUpdate: socket is already in use");
#endif
        }

        else if (result == FMOD.RESULT.ERR_HEADER_MISMATCH)

        {
            FMOD.Studio.UnityUtil.LogError("Version mismatch between C# script and FMOD binary, restart Unity and reimport the integration package to resolve this issue.");
        }

        else

        {
            ERRCHECK(result);
        }



        isInitialized = true;
    }
 /// <summary>
 /// Creates the fmod studio system, and initializes the system
 /// </summary>
 private void InitializeFmodStudio()
 {
     FMOD.Studio.System.create(out _fmodStudioSystem);
     _fmodStudioSystem.initialize(512, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
 }
Beispiel #10
0
    void Init()
    {
        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: Initialize");

        if (isInitialized)
        {
            return;
        }

        DontDestroyOnLoad(gameObject);

        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: System_Create");
        ERRCHECK(FMOD.Studio.System.create(out system));

        FMOD.Studio.INITFLAGS flags = FMOD.Studio.INITFLAGS.NORMAL;

#if FMOD_LIVEUPDATE
        flags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;

        // Unity 5 liveupdate workaround
        if (Application.unityVersion.StartsWith("5"))
        {
            FMOD.Studio.UnityUtil.LogWarning("FMOD_StudioSystem: detected Unity 5, running on port 9265");
            FMOD.System sys;
            ERRCHECK(system.getLowLevelSystem(out sys));
            FMOD.ADVANCEDSETTINGS advancedSettings = new FMOD.ADVANCEDSETTINGS();
            advancedSettings.profilePort = 9265;
            ERRCHECK(sys.setAdvancedSettings(ref advancedSettings));
        }
#endif

        int outputRate = 48000;
#if true //UNITY_ANDROID && !UNITY_EDITOR
        // Force the system sample rate to the output rate to allow for the fast mixer
        if (FMOD.VERSION.number >= 0x00010500)
        {
            FMOD.System sys;
            ERRCHECK(system.getLowLevelSystem(out sys));
            {
                System.Text.StringBuilder str = new System.Text.StringBuilder();
                FMOD.GUID        guid;
                FMOD.SPEAKERMODE speakermode;
                int speakermodechannels;
                ERRCHECK(sys.getDriverInfo(0, str, str.Capacity, out guid, out outputRate, out speakermode, out speakermodechannels));
            }

            ERRCHECK(sys.setSoftwareFormat(outputRate, FMOD.SPEAKERMODE.DEFAULT, 0));
        }
#endif

        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: system.init");
        FMOD.RESULT result = FMOD.RESULT.OK;
        result = system.initialize(1024, flags, FMOD.INITFLAGS.NORMAL, global::System.IntPtr.Zero);

        if (result == FMOD.RESULT.ERR_HEADER_MISMATCH)
        {
            FMOD.Studio.UnityUtil.LogError("Version mismatch between C# script and FMOD binary, restart Unity and reimport the integration package to resolve this issue.");
        }
        else
        {
            ERRCHECK(result);
        }

        // Dummy flush and update to get network state
        ERRCHECK(system.flushCommands());
        result = system.update();

        // Restart without liveupdate if there was a socket error
        if (result == FMOD.RESULT.ERR_NET_SOCKET_ERROR)
        {
            FMOD.Studio.UnityUtil.LogWarning("LiveUpdate disabled: socket in already in use");
            flags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
            ERRCHECK(system.release());
            ERRCHECK(FMOD.Studio.System.create(out system));
            FMOD.System sys;
            ERRCHECK(system.getLowLevelSystem(out sys));
            ERRCHECK(sys.setSoftwareFormat(outputRate, FMOD.SPEAKERMODE.DEFAULT, 0));
            result = system.initialize(1024, flags, FMOD.INITFLAGS.NORMAL, global::System.IntPtr.Zero);
            ERRCHECK(result);
        }

        isInitialized = true;
    }
    void Init()
    {
        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: Initialize");

        if (isInitialized)
        {
            return;
        }

        DontDestroyOnLoad(gameObject);

        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: System_Create");
        ERRCHECK(FMOD.Studio.System.create(out system));

        FMOD.Studio.INITFLAGS flags = FMOD.Studio.INITFLAGS.NORMAL;

        FMOD.System sys;
        ERRCHECK(system.getLowLevelSystem(out sys));
        FMOD.ADVANCEDSETTINGS advancedSettings = new FMOD.ADVANCEDSETTINGS();
        advancedSettings.randomSeed = (uint)DateTime.Now.Ticks;

#if FMOD_LIVEUPDATE
        flags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;

        // Unity 5 liveupdate workaround
        if (Application.unityVersion.StartsWith("5"))
        {
            FMOD.Studio.UnityUtil.LogWarning("FMOD_StudioSystem: detected Unity 5, running on port 9265");
            advancedSettings.profilePort = 9265;
        }
#endif

        ERRCHECK(sys.setAdvancedSettings(ref advancedSettings));

                #if FMOD_DEBUG
        FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, "fmod.log");
                #endif

        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: system.init");
        FMOD.RESULT result = FMOD.RESULT.OK;
        result = system.initialize(1024, flags, FMOD.INITFLAGS.NORMAL, global::System.IntPtr.Zero);

        if (result == FMOD.RESULT.ERR_HEADER_MISMATCH)
        {
            FMOD.Studio.UnityUtil.LogError("Version mismatch between C# script and FMOD binary, restart Unity and reimport the integration package to resolve this issue.");
        }
        else
        {
            ERRCHECK(result);
        }

        // Dummy flush and update to get network state
        ERRCHECK(system.flushCommands());
        result = system.update();

        // Restart without liveupdate if there was a socket error
        if (result == FMOD.RESULT.ERR_NET_SOCKET_ERROR)
        {
            FMOD.Studio.UnityUtil.LogWarning("LiveUpdate disabled: socket in already in use");
            flags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
            ERRCHECK(system.release());
            ERRCHECK(FMOD.Studio.System.create(out system));
            ERRCHECK(system.getLowLevelSystem(out sys));
            advancedSettings            = new FMOD.ADVANCEDSETTINGS();
            advancedSettings.randomSeed = (uint)DateTime.Now.Ticks;
            ERRCHECK(sys.setAdvancedSettings(ref advancedSettings));
            result = system.initialize(1024, flags, FMOD.INITFLAGS.NORMAL, global::System.IntPtr.Zero);
            ERRCHECK(result);
        }

        #if UNITY_EDITOR && FMOD_DEBUG
        var fileStream = new FileStream("fmod.log", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
        logReader = new StreamReader(fileStream);
        #endif

        isInitialized = true;
    }
Beispiel #12
0
    void Init()
    {
        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: Initialize");

        if (isInitialized)
        {
            return;
        }

        DontDestroyOnLoad(gameObject);

        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: System_Create");
        ERRCHECK(FMOD.Studio.System.create(out system));

        FMOD.Studio.INITFLAGS flags = FMOD.Studio.INITFLAGS.NORMAL;

#if FMOD_LIVEUPDATE
        flags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;

        // Unity 5 liveupdate workaround
        if (Application.unityVersion.StartsWith("5"))
        {
            FMOD.Studio.UnityUtil.LogWarning("FMOD_StudioSystem: detected Unity 5, running on port 9265");
            FMOD.System sys;
            ERRCHECK(system.getLowLevelSystem(out sys));
            FMOD.ADVANCEDSETTINGS advancedSettings = new FMOD.ADVANCEDSETTINGS();
            advancedSettings.profilePort = 9265;
            ERRCHECK(sys.setAdvancedSettings(ref advancedSettings));
        }
#endif

                #if FMOD_DEBUG
                        #if UNITY_XBOXONE
        // Can't go managed -> native -> managed apparently so log to a file
        FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, "fmod.log");
                        #else
        FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.CALLBACK, LogCallback, null);
                        #endif
                #endif


        FMOD.Studio.UnityUtil.Log("FMOD_StudioSystem: system.init");
        FMOD.RESULT result = FMOD.RESULT.OK;
        result = system.initialize(1024, flags, FMOD.INITFLAGS.NORMAL, global::System.IntPtr.Zero);

        if (result == FMOD.RESULT.ERR_HEADER_MISMATCH)
        {
            FMOD.Studio.UnityUtil.LogError("Version mismatch between C# script and FMOD binary, restart Unity and reimport the integration package to resolve this issue.");
        }
        else
        {
            ERRCHECK(result);
        }

        // Dummy flush and update to get network state
        ERRCHECK(system.flushCommands());
        result = system.update();

        // Restart without liveupdate if there was a socket error
        if (result == FMOD.RESULT.ERR_NET_SOCKET_ERROR)
        {
            FMOD.Studio.UnityUtil.LogWarning("LiveUpdate disabled: socket in already in use");
            flags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
            ERRCHECK(system.release());
            ERRCHECK(FMOD.Studio.System.create(out system));
            FMOD.System sys;
            ERRCHECK(system.getLowLevelSystem(out sys));
            result = system.initialize(1024, flags, FMOD.INITFLAGS.NORMAL, global::System.IntPtr.Zero);
            ERRCHECK(result);
        }

        isInitialized = true;
    }
Beispiel #13
0
        private RESULT Initialize()
        {
            initializedSuccessfully = false;
            RESULT   rESULT   = RESULT.OK;
            RESULT   rESULT2  = RESULT.OK;
            Settings settings = Settings.Instance;

            fmodPlatform = RuntimeUtils.GetCurrentPlatform();
            int         sampleRate      = settings.GetSampleRate(fmodPlatform);
            int         num             = Math.Min(settings.GetRealChannels(fmodPlatform), 256);
            int         virtualChannels = settings.GetVirtualChannels(fmodPlatform);
            SPEAKERMODE speakerMode     = (SPEAKERMODE)settings.GetSpeakerMode(fmodPlatform);
            OUTPUTTYPE  output          = OUTPUTTYPE.AUTODETECT;

            FMOD.ADVANCEDSETTINGS settings2 = default(FMOD.ADVANCEDSETTINGS);
            settings2.randomSeed      = (uint)DateTime.Now.Ticks;
            settings2.maxVorbisCodecs = num;
            FMOD.Studio.INITFLAGS iNITFLAGS = FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;
            if (settings.IsLiveUpdateEnabled(fmodPlatform))
            {
                iNITFLAGS |= FMOD.Studio.INITFLAGS.LIVEUPDATE;
            }
            while (true)
            {
                rESULT = FMOD.Studio.System.create(out studioSystem);
                CheckInitResult(rESULT, "FMOD.Studio.System.create");
                rESULT = studioSystem.getLowLevelSystem(out lowlevelSystem);
                CheckInitResult(rESULT, "FMOD.Studio.System.getLowLevelSystem");
                rESULT = lowlevelSystem.setOutput(output);
                CheckInitResult(rESULT, "FMOD.System.setOutput");
                rESULT = lowlevelSystem.setSoftwareChannels(num);
                CheckInitResult(rESULT, "FMOD.System.setSoftwareChannels");
                rESULT = lowlevelSystem.setSoftwareFormat(sampleRate, speakerMode, 0);
                CheckInitResult(rESULT, "FMOD.System.setSoftwareFormat");
                rESULT = lowlevelSystem.setAdvancedSettings(ref settings2);
                CheckInitResult(rESULT, "FMOD.System.setAdvancedSettings");
                rESULT = studioSystem.initialize(virtualChannels, iNITFLAGS, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
                if (rESULT != 0 && rESULT2 == RESULT.OK)
                {
                    rESULT2 = rESULT;
                    output  = OUTPUTTYPE.NOSOUND;
                    Debug.LogWarningFormat("FMOD Studio: Studio::System::initialize returned {0}, defaulting to no-sound mode.", rESULT.ToString());
                }
                else
                {
                    CheckInitResult(rESULT, "Studio::System::initialize");
                    if ((iNITFLAGS & FMOD.Studio.INITFLAGS.LIVEUPDATE) == FMOD.Studio.INITFLAGS.NORMAL)
                    {
                        break;
                    }
                    studioSystem.flushCommands();
                    rESULT = studioSystem.update();
                    if (rESULT != RESULT.ERR_NET_SOCKET_ERROR)
                    {
                        break;
                    }
                    iNITFLAGS = (FMOD.Studio.INITFLAGS)((int)iNITFLAGS & -2);
                    Debug.LogWarning("FMOD Studio: Cannot open network port for Live Update (in-use), restarting with Live Update disabled.");
                    rESULT = studioSystem.release();
                    CheckInitResult(rESULT, "FMOD.Studio.System.Release");
                }
            }
            LoadPlugins(settings);
            LoadBanks(settings);
            initializedSuccessfully = (rESULT == RESULT.OK);
            return(rESULT2);
        }
Beispiel #14
0
        FMOD.RESULT Initialize()
        {
            #if UNITY_EDITOR
                #if UNITY_2017_2_OR_NEWER
            EditorApplication.playModeStateChanged += HandlePlayModeStateChange;
                #elif UNITY_2017_1_OR_NEWER
            EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged;
                #endif // UNITY_2017_2_OR_NEWER
            #endif     // UNITY_EDITOR

            FMOD.RESULT result       = FMOD.RESULT.OK;
            FMOD.RESULT initResult   = FMOD.RESULT.OK;
            Settings    fmodSettings = Settings.Instance;
            fmodPlatform = RuntimeUtils.GetCurrentPlatform();

            int sampleRate               = fmodSettings.GetSampleRate(fmodPlatform);
            int realChannels             = Math.Min(fmodSettings.GetRealChannels(fmodPlatform), 256); // Prior to 1.08.10 we didn't clamp this properly in the settings screen
            int virtualChannels          = fmodSettings.GetVirtualChannels(fmodPlatform);
            FMOD.SPEAKERMODE speakerMode = (FMOD.SPEAKERMODE)fmodSettings.GetSpeakerMode(fmodPlatform);
            FMOD.OUTPUTTYPE  outputType  = FMOD.OUTPUTTYPE.AUTODETECT;

            FMOD.ADVANCEDSETTINGS advancedSettings = new FMOD.ADVANCEDSETTINGS();
            advancedSettings.randomSeed = (uint)DateTime.Now.Ticks;
            #if UNITY_EDITOR || UNITY_STANDALONE
            advancedSettings.maxVorbisCodecs = realChannels;
            #elif UNITY_XBOXONE
            advancedSettings.maxXMACodecs = realChannels;
            #elif UNITY_PS4
            advancedSettings.maxAT9Codecs = realChannels;
            #else
            advancedSettings.maxFADPCMCodecs = realChannels;
            #endif

            SetThreadAffinity();

            #if UNITY_EDITOR || ((UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX) && DEVELOPMENT_BUILD)
            result = FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, RuntimeUtils.LogFileName);
            if (result == FMOD.RESULT.ERR_FILE_NOTFOUND)
            {
                UnityEngine.Debug.LogWarningFormat("FMOD Studio: Cannot open FMOD debug log file '{0}', logs will be missing for this session.", System.IO.Path.Combine(Application.dataPath, RuntimeUtils.LogFileName));
            }
            else
            {
                CheckInitResult(result, "FMOD.Debug.Initialize");
            }
            #endif

            FMOD.Studio.INITFLAGS studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;
            if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform))
            {
                studioInitFlags |= FMOD.Studio.INITFLAGS.LIVEUPDATE;

                #if UNITY_5_0 || UNITY_5_1 // These versions of Unity shipped with FMOD4 profiling enabled consuming our port number.
                UnityEngine.Debug.LogWarning("FMOD Studio: Live Update port in-use by Unity, switching to port 9265");
                advancedSettings.profilePort = 9265;
                #endif
            }

retry:
            result = FMOD.Studio.System.create(out studioSystem);
            CheckInitResult(result, "FMOD.Studio.System.create");

            result = studioSystem.getLowLevelSystem(out lowlevelSystem);
            CheckInitResult(result, "FMOD.Studio.System.getLowLevelSystem");

            result = lowlevelSystem.setOutput(outputType);
            CheckInitResult(result, "FMOD.System.setOutput");

            result = lowlevelSystem.setSoftwareChannels(realChannels);
            CheckInitResult(result, "FMOD.System.setSoftwareChannels");

            result = lowlevelSystem.setSoftwareFormat(sampleRate, speakerMode, 0);
            CheckInitResult(result, "FMOD.System.setSoftwareFormat");

            result = lowlevelSystem.setAdvancedSettings(ref advancedSettings);
            CheckInitResult(result, "FMOD.System.setAdvancedSettings");

            result = studioSystem.initialize(virtualChannels, studioInitFlags, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
            if (result != FMOD.RESULT.OK && initResult == FMOD.RESULT.OK)
            {
                initResult = result; // Save this to throw at the end (we'll attempt NO SOUND to shield ourselves from unexpected device failures)
                outputType = FMOD.OUTPUTTYPE.NOSOUND;
                UnityEngine.Debug.LogErrorFormat("FMOD Studio: Studio::System::initialize returned {0}, defaulting to no-sound mode.", result.ToString());

                goto retry;
            }
            CheckInitResult(result, "Studio::System::initialize");

            // Test network functionality triggered during System::update
            if ((studioInitFlags & FMOD.Studio.INITFLAGS.LIVEUPDATE) != 0)
            {
                studioSystem.flushCommands(); // Any error will be returned through Studio.System.update

                result = studioSystem.update();
                if (result == FMOD.RESULT.ERR_NET_SOCKET_ERROR)
                {
                    studioInitFlags &= ~FMOD.Studio.INITFLAGS.LIVEUPDATE;
                    UnityEngine.Debug.LogWarning("FMOD Studio: Cannot open network port for Live Update (in-use), restarting with Live Update disabled.");

                    result = studioSystem.release();
                    CheckInitResult(result, "FMOD.Studio.System.Release");

                    goto retry;
                }
            }

            LoadPlugins(fmodSettings);
            LoadBanks(fmodSettings);

            return(initResult);
        }