/// <summary> /// Initializes a new instance of the <see cref="AudioEngine"/> class. /// </summary> /// <param name="creationFlags">The creation flags.</param> /// <param name="settings">Settings for this audio engine</param> public AudioEngine(CreationFlags creationFlags, AudioEngineSettings settings) { bool debug = (creationFlags == CreationFlags.DebugMode); bool audition = (creationFlags == CreationFlags.AuditionMode); var debugRegistryKey = Registry.LocalMachine.OpenSubKey(DebugEngineRegistryKey); // If neither the debug nor audition flags are set, see if the debug registry key is set if (!debug && !audition && debugRegistryKey != null) { var value = debugRegistryKey.GetValue(DebugEngineRegistryValue); if (value is Int32 && ((int)value) != 0) debug = true; debugRegistryKey.Close(); } var selectedEngineCLSID = (debug) ? DebugEngineGuid : (audition) ? AuditionEngineGuid : EngineGuid; Utilities.CreateComInstance(selectedEngineCLSID, Utilities.CLSCTX.ClsctxInprocServer, Utilities.GetGuidFromType(typeof(AudioEngine)), this); unsafe { unmanagedDelegate = new NotificationCallbackDelegate(NotificationCallbackDelegateImpl); unmanagedDelegatePointer = Marshal.GetFunctionPointerForDelegate(unmanagedDelegate); } // Initialize the engine PreInitialize(settings); Initialize(settings); }
/// <summary> /// Initializes a new instance of the <see cref="AudioEngine"/> class. /// </summary> /// <param name="creationFlags">The creation flags.</param> /// <param name="settings">Settings for this audio engine</param> public AudioEngine(CreationFlags creationFlags, AudioEngineSettings settings) { bool debug = (creationFlags == CreationFlags.DebugMode); bool audition = (creationFlags == CreationFlags.AuditionMode); var debugRegistryKey = Registry.LocalMachine.OpenSubKey(DebugEngineRegistryKey); // If neither the debug nor audition flags are set, see if the debug registry key is set if (!debug && !audition && debugRegistryKey != null) { var value = debugRegistryKey.GetValue(DebugEngineRegistryValue); if (value is Int32 && ((int)value) != 0) { debug = true; } debugRegistryKey.Close(); } var selectedEngineCLSID = (debug) ? DebugEngineGuid : (audition) ? AuditionEngineGuid : EngineGuid; Utilities.CreateComInstance(selectedEngineCLSID, Utilities.CLSCTX.ClsctxInprocServer, Utilities.GetGuidFromType(typeof(AudioEngine)), this); unsafe { unmanagedDelegate = new NotificationCallbackDelegate(NotificationCallbackDelegateImpl); unmanagedDelegatePointer = Marshal.GetFunctionPointerForDelegate(unmanagedDelegate); } // Initialize the engine PreInitialize(settings); Initialize(settings); }
/// <summary> /// Initializes this instance from a settings file and a renderer index. /// </summary> /// <unmanaged>IXACT3Engine::Initialize</unmanaged> private unsafe void PreInitialize(AudioEngineSettings runtimeParameters) { if (runtimeParameters.LookAheadTime == 0) { runtimeParameters.LookAheadTime = AudioEngineSettings.DefaultLookAhead; } runtimeParameters.FnNotificationCallback = unmanagedDelegatePointer; var settingsFile = runtimeParameters.Settings; // Init from a settings file if (settingsFile != null) { settingsFile.Position = 0; var settingsData = new byte[settingsFile.Length]; settingsFile.Read(settingsData, 0, settingsData.Length); runtimeParameters.GlobalSettingsBufferPointer = Marshal.AllocCoTaskMem(settingsData.Length); runtimeParameters.GlobalSettingsBufferSize = settingsData.Length; runtimeParameters.GlobalSettingsFlags = 1; Utilities.Write(runtimeParameters.GlobalSettingsBufferPointer, settingsData, 0, settingsData.Length); } }
/// <summary> /// Initializes this instance from a settings file and a renderer index. /// </summary> /// <unmanaged>IXACT3Engine::Initialize</unmanaged> private unsafe void PreInitialize(AudioEngineSettings runtimeParameters) { if (runtimeParameters.LookAheadTime == 0) runtimeParameters.LookAheadTime = AudioEngineSettings.DefaultLookAhead; runtimeParameters.FnNotificationCallback = unmanagedDelegatePointer; var settingsFile = runtimeParameters.Settings; // Init from a settings file if (settingsFile != null) { settingsFile.Position = 0; var settingsData = new byte[settingsFile.Length]; settingsFile.Read(settingsData, 0, settingsData.Length); runtimeParameters.GlobalSettingsBufferPointer = Marshal.AllocCoTaskMem(settingsData.Length); runtimeParameters.GlobalSettingsBufferSize = settingsData.Length; runtimeParameters.GlobalSettingsFlags = 1; Utilities.Write(runtimeParameters.GlobalSettingsBufferPointer, settingsData, 0, settingsData.Length); } }