static void CreateSystem() { UnityEngine.Debug.Log("FMOD Studio: Creating editor system instance"); RuntimeUtils.EnforceLibraryOrder(); FMOD.RESULT result = FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, "fmod_editor.log"); if (result != FMOD.RESULT.OK) { UnityEngine.Debug.LogWarning("FMOD Studio: Cannot open fmod_editor.log. Logging will be disabled for importing and previewing"); } CheckResult(FMOD.Studio.System.create(out system)); FMOD.System lowlevel; CheckResult(system.getLowLevelSystem(out lowlevel)); // Use play-in-editor speaker mode for event browser preview and metering lowlevel.setSoftwareFormat(0, (FMOD.SPEAKERMODE)Settings.Instance.GetSpeakerMode(FMODPlatform.Default), 0); CheckResult(system.initialize(256, FMOD.Studio.INITFLAGS.ALLOW_MISSING_PLUGINS | FMOD.Studio.INITFLAGS.SYNCHRONOUS_UPDATE, FMOD.INITFLAGS.NORMAL, IntPtr.Zero)); FMOD.ChannelGroup master; CheckResult(lowlevel.getMasterChannelGroup(out master)); FMOD.DSP masterHead; CheckResult(master.getDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, out masterHead)); CheckResult(masterHead.setMeteringEnabled(false, true)); }
public Form1() { InitializeComponent(); DoubleBuffered = true; SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); rect = new RectangleF(0, 0, 0, 0); graphics = CreateGraphics(); List <string> vs = Directory.GetFiles("assets\\models\\", "*png").ToList(); if (vs.Count > 0) { float per = 100 / vs.Count; LoadingForm lf = new LoadingForm(); lf.Show(this); lf.progressBar1.Value = 0; lf.label1.Text = ""; for (int i = 0; i < vs.Count; i++) { //vs.ElementAt(i).Substring( textures.Add(new Texture(Image.FromFile(vs.ElementAt(i)), vs.ElementAt(i))); TexturesBox.Items.Add(vs.ElementAt(i)); lf.label1.Text = vs.ElementAt(i); if (lf.progressBar1.Value + Convert.ToInt32(per) < 0) { lf.progressBar1.Value += Convert.ToInt32(per); } lf.Close(); } } for (int i = 0; i < 1; i++) { comboBoxEnt.Items.Add("Player Startpoint"); comboBoxEnt.Items.Add("Sound Reverb"); comboBoxEnt.Items.Add("Trigger Change Layer"); comboBoxEnt.Items.Add("View Layer"); comboBoxEnt.Items.Add("Trigger Damage"); } RESULT res = FMOD.Studio.System.create(out Sound_System); if (res == RESULT.OK) { res = Sound_System.initialize(512, FMOD.Studio.INITFLAGS.NORMAL, INITFLAGS.NORMAL, new IntPtr(0)); if (res != RESULT.OK) { throw (new ApplicationException("Unable to init sound_system")); } } else { throw (new ApplicationException("Unable to create sound_system")); } timer1.Start(); }
public static void Init() { FMOD.Studio.System.create(out _System); _System.getLowLevelSystem(out FMOD.System low); low.setSoftwareFormat(0, FMOD.SPEAKERMODE._7POINT1, 0); _System.initialize(1, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero); _System.loadBankFile(FileSystemManager.RootDirectory + "/Content/Banks/Master_Bank.bank", FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out Bank MainBank); _System.loadBankFile(FileSystemManager.RootDirectory + "/Content/Banks/Master_Bank.strings.bank", LOAD_BANK_FLAGS.NORMAL, out Bank MainBankStrings); MainBank.getEventList(out MainEvents); DumpEventInformation(); }
static void CreateSystem() { UnityEngine.Debug.Log("FMOD Studio: Creating editor system instance"); RuntimeUtils.EnforceLibraryOrder(); CheckResult(FMOD.Studio.System.create(out system)); FMOD.System lowlevel; CheckResult(system.getLowLevelSystem(out lowlevel)); // Use play-in-editor speaker mode for event browser preview and metering lowlevel.setSoftwareFormat(0, (FMOD.SPEAKERMODE)Settings.Instance.GetSpeakerMode(FMODPlatform.PlayInEditor), 0); CheckResult(system.initialize(256, FMOD.Studio.INITFLAGS.ALLOW_MISSING_PLUGINS | FMOD.Studio.INITFLAGS.SYNCHRONOUS_UPDATE, FMOD.INITFLAGS.NORMAL, IntPtr.Zero)); FMOD.ChannelGroup master; CheckResult(lowlevel.getMasterChannelGroup(out master)); FMOD.DSP masterHead; CheckResult(master.getDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, out masterHead)); CheckResult(masterHead.setMeteringEnabled(false, true)); }
public Game(Player player, World world, int PlayerViewRadius) { RESULT res = FMOD.Studio.System.create(out Sound_System); if (res == RESULT.OK) { res = Sound_System.initialize(512, FMOD.Studio.INITFLAGS.NORMAL, INITFLAGS.NORMAL, new IntPtr(0)); if (res != RESULT.OK) { throw (new ApplicationException("Unable to init sound_system")); } } else { throw (new ApplicationException("Unable to create sound_system")); } this.player = player; this.PlayerViewRadius = PlayerViewRadius; PlayerViewArea.Height = PlayerViewRadius * 2; PlayerViewArea.Width = PlayerViewRadius * 2; this.world = world; }
FMOD.RESULT Initialize() { #if UNITY_EDITOR #if UNITY_2017_2_OR_NEWER AssemblyReloadEvents.beforeAssemblyReload += HandleBeforeAssemblyReload; 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(fmodSettings.LoggingLevel, FMOD.DEBUG_MODE.CALLBACK, DEBUG_CALLBACK, null); 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; advancedSettings.profilePort = fmodSettings.LiveUpdatePort; } 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::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] 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); }
FMOD.RESULT Initialize() { 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 #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); }
FMOD.RESULT Initialize() { #if UNITY_EDITOR EditorApplication.playModeStateChanged += HandlePlayModeStateChange; #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); 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.UtcNow.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 || DEVELOPMENT_BUILD result = FMOD.Debug.Initialize(fmodSettings.LoggingLevel, FMOD.DEBUG_MODE.CALLBACK, DEBUG_CALLBACK, null); if (result == FMOD.RESULT.ERR_UNSUPPORTED) { Debug.LogWarning("[FMOD] Unable to initialize debug logging: Logging will be disabled.\nCheck the Import Settings of the FMOD libs to enable the logging library."); } 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; advancedSettings.profilePort = fmodSettings.LiveUpdatePort; } retry: result = FMOD.Studio.System.create(out studioSystem); CheckInitResult(result, "FMOD.Studio.System.create"); cachedStudioSystemHandle = (long)studioSystem.handle; result = studioSystem.getCoreSystem(out coreSystem); CheckInitResult(result, "FMOD.Studio.System.getCoreSystem"); result = coreSystem.setOutput(outputType); CheckInitResult(result, "FMOD.System.setOutput"); result = coreSystem.setSoftwareChannels(realChannels); CheckInitResult(result, "FMOD.System.setSoftwareChannels"); result = coreSystem.setSoftwareFormat(sampleRate, speakerMode, 0); CheckInitResult(result, "FMOD.System.setSoftwareFormat"); result = coreSystem.setAdvancedSettings(ref advancedSettings); CheckInitResult(result, "FMOD.System.setAdvancedSettings"); if (!string.IsNullOrEmpty(Settings.Instance.EncryptionKey)) { FMOD.Studio.ADVANCEDSETTINGS studioAdvancedSettings = new FMOD.Studio.ADVANCEDSETTINGS(); result = studioSystem.setAdvancedSettings(studioAdvancedSettings, Settings.Instance.EncryptionKey); CheckInitResult(result, "FMOD.Studio.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::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] 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); #if (UNITY_IOS || UNITY_TVOS) && !UNITY_EDITOR RegisterSuspendCallback(HandleInterrupt); #endif return(initResult); }
void Initialiase(bool forceNoNetwork) { UnityEngine.Debug.Log("FMOD Studio: Creating runtime system instance"); FMOD.RESULT result; result = FMOD.Studio.System.create(out studioSystem); CheckInitResult(result, "Creating System Object"); studioSystem.getLowLevelSystem(out lowlevelSystem); Settings fmodSettings = Settings.Instance; fmodPlatform = RuntimeUtils.GetCurrentPlatform(); #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) { #if UNITY_5_X 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 Debug.LogWarning(string.Format("FMOD Studio: Cannot open FMOD debug log file '{0}', logs will be missing for this session.", System.IO.Path.Combine(Application.dataPath, RuntimeUtils.LogFileName))); #endif } else { CheckInitResult(result, "Applying debug settings"); } #endif int realChannels = fmodSettings.GetRealChannels(fmodPlatform); realChannels = Math.Min(realChannels, 256); // Prior to 1.08.10 we didn't clamp this properly in the settings screen result = lowlevelSystem.setSoftwareChannels(realChannels); CheckInitResult(result, "Set software channels"); result = lowlevelSystem.setSoftwareFormat( fmodSettings.GetSampleRate(fmodPlatform), (FMOD.SPEAKERMODE)fmodSettings.GetSpeakerMode(fmodPlatform), 0 // raw not supported ); CheckInitResult(result, "Set software format"); // Setup up the platforms recommended codec to match the real channel count FMOD.ADVANCEDSETTINGS advancedsettings = new FMOD.ADVANCEDSETTINGS(); #if UNITY_EDITOR || UNITY_STANDALONE advancedsettings.maxVorbisCodecs = realChannels; #elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8_1 || UNITY_PSP2 || UNITY_WII advancedsettings.maxFADPCMCodecs = realChannels; #elif UNITY_XBOXONE advancedsettings.maxXMACodecs = realChannels; #elif UNITY_PS4 advancedsettings.maxAT9Codecs = realChannels; #endif #if UNITY_5_0 || UNITY_5_1 if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform) && !forceNoNetwork) { UnityEngine.Debug.LogWarning("FMOD Studio: Detected Unity 5, running on port 9265"); advancedsettings.profilePort = 9265; } #endif advancedsettings.randomSeed = (uint)DateTime.Now.Ticks; result = lowlevelSystem.setAdvancedSettings(ref advancedsettings); CheckInitResult(result, "Set advanced settings"); FMOD.INITFLAGS lowlevelInitFlags = FMOD.INITFLAGS.NORMAL; FMOD.Studio.INITFLAGS studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS; if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform) && !forceNoNetwork) { studioInitFlags |= FMOD.Studio.INITFLAGS.LIVEUPDATE; } FMOD.RESULT initResult = studioSystem.initialize( fmodSettings.GetVirtualChannels(fmodPlatform), studioInitFlags, lowlevelInitFlags, IntPtr.Zero ); CheckInitResult(initResult, "Calling initialize"); // Dummy flush and update to get network state studioSystem.flushCommands(); FMOD.RESULT updateResult = studioSystem.update(); // Restart without liveupdate if there was a socket error if (updateResult == FMOD.RESULT.ERR_NET_SOCKET_ERROR) { studioSystem.release(); UnityEngine.Debug.LogWarning("FMOD Studio: Cannot open network port for Live Update, restarting with Live Update disabled. Check for other applications that are running FMOD Studio"); Initialiase(true); } else { // Load plugins (before banks) #if (UNITY_IOS || UNITY_TVOS) && !UNITY_EDITOR FmodUnityNativePluginInit(lowlevelSystem.getRaw()); #else foreach (var pluginName in fmodSettings.Plugins) { string pluginPath = RuntimeUtils.GetPluginPath(pluginName); uint handle; result = lowlevelSystem.loadPlugin(pluginPath, out handle); #if UNITY_64 || UNITY_EDITOR_64 // Add a "64" suffix and try again if (result == FMOD.RESULT.ERR_FILE_BAD || result == FMOD.RESULT.ERR_FILE_NOTFOUND) { string pluginPath64 = RuntimeUtils.GetPluginPath(pluginName + "64"); result = lowlevelSystem.loadPlugin(pluginPath64, out handle); } #endif CheckInitResult(result, String.Format("Loading plugin '{0}' from '{1}'", pluginName, pluginPath)); loadedPlugins.Add(pluginName, handle); } #endif if (fmodSettings.ImportType == ImportType.StreamingAssets) { // Always load strings bank try { LoadBank(fmodSettings.MasterBank + ".strings", fmodSettings.AutomaticSampleLoading); } catch (BankLoadException e) { UnityEngine.Debug.LogException(e); } if (fmodSettings.AutomaticEventLoading) { try { LoadBank(fmodSettings.MasterBank, fmodSettings.AutomaticSampleLoading); } catch (BankLoadException e) { UnityEngine.Debug.LogException(e); } foreach (var bank in fmodSettings.Banks) { try { LoadBank(bank, fmodSettings.AutomaticSampleLoading); } catch (BankLoadException e) { UnityEngine.Debug.LogException(e); } } WaitForAllLoads(); } } }; FMOD.ChannelGroup master; lowlevelSystem.getMasterChannelGroup(out master); master.getDSP(0, out mixerHead); mixerHead.setMeteringEnabled(false, true); }
void Initialiase(bool forceNoNetwork) { FMOD.RESULT result; result = FMOD.Studio.System.create(out studioSystem); CheckInitResult(result, "Creating System Object"); studioSystem.getLowLevelSystem(out lowlevelSystem); Settings fmodSettings = Settings.Instance; FMODPlatform fmodPlatform = RuntimeUtils.GetCurrentPlatform(); #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); CheckInitResult(result, "Applying debug settings"); #endif int realChannels = fmodSettings.GetRealChannels(fmodPlatform); result = lowlevelSystem.setSoftwareChannels(realChannels); CheckInitResult(result, "Set software channels"); result = lowlevelSystem.setSoftwareFormat( fmodSettings.GetSampleRate(fmodPlatform), (FMOD.SPEAKERMODE)fmodSettings.GetSpeakerMode(fmodPlatform), 0 // raw not supported ); CheckInitResult(result, "Set software format"); // Setup up the platforms recommended codec to match the real channel count FMOD.ADVANCEDSETTINGS advancedsettings = new FMOD.ADVANCEDSETTINGS(); #if UNITY_EDITOR || UNITY_STANDALONE advancedsettings.maxVorbisCodecs = realChannels; #elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8_1 || UNITY_PSP2 || UNITY_WII advancedsettings.maxFADPCMCodecs = realChannels; #elif UNITY_XBOXONE advancedsettings.maxXMACodecs = realChannels; #elif UNITY_PS4 advancedsettings.maxAT9Codecs = realChannels; #endif #if UNITY_5_0 || UNITY_5_1 if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform) && !forceNoNetwork) { UnityEngine.Debug.LogWarning("FMOD Studio: Detected Unity 5, running on port 9265"); advancedsettings.profilePort = 9265; } #endif advancedsettings.randomSeed = (uint)DateTime.Now.Ticks; result = lowlevelSystem.setAdvancedSettings(ref advancedsettings); CheckInitResult(result, "Set advanced settings"); FMOD.INITFLAGS lowlevelInitFlags = FMOD.INITFLAGS.NORMAL; FMOD.Studio.INITFLAGS studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS; if (fmodSettings.IsLiveUpdateEnabled(fmodPlatform) && !forceNoNetwork) { studioInitFlags |= FMOD.Studio.INITFLAGS.LIVEUPDATE; } FMOD.RESULT initResult = studioSystem.initialize( fmodSettings.GetVirtualChannels(fmodPlatform), studioInitFlags, lowlevelInitFlags, IntPtr.Zero ); CheckInitResult(initResult, "Calling initialize"); // Dummy flush and update to get network state studioSystem.flushCommands(); FMOD.RESULT updateResult = studioSystem.update(); // Restart without liveupdate if there was a socket error if (updateResult == FMOD.RESULT.ERR_NET_SOCKET_ERROR) { studioSystem.release(); UnityEngine.Debug.LogWarning("FMOD Studio: Cannot network port for Live Update, restarting with Live Update disabled. Check for other applications that are running FMOD Studio"); Initialiase(true); } else { try { // Always load strings bank LoadBank(fmodSettings.MasterBank + ".strings", fmodSettings.AutomaticSampleLoading); if (fmodSettings.AutomaticEventLoading) { LoadBank(fmodSettings.MasterBank, fmodSettings.AutomaticSampleLoading); foreach (var bank in fmodSettings.Banks) { LoadBank(bank, fmodSettings.AutomaticSampleLoading); } } } catch (BankLoadException e) { throw new SystemNotInitializedException(e.Result, String.Format("Loading Bank '{0}'", e.Path)); } foreach (var pluginName in fmodSettings.Plugins) { string pluginPath = RuntimeUtils.GetPluginPath(pluginName); uint handle; result = lowlevelSystem.loadPlugin(pluginPath, out handle); CheckInitResult(result, String.Format("Loading plugin '{0}' from '{1}'", pluginName, pluginPath)); loadedPlugins.Add(pluginName, handle); } }; }