当前位置: 首页>>代码示例>>C#>>正文


C# AudioContext.GetInstanceField方法代码示例

本文整理汇总了C#中OpenTK.Audio.AudioContext.GetInstanceField方法的典型用法代码示例。如果您正苦于以下问题:C# AudioContext.GetInstanceField方法的具体用法?C# AudioContext.GetInstanceField怎么用?C# AudioContext.GetInstanceField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenTK.Audio.AudioContext的用法示例。


在下文中一共展示了AudioContext.GetInstanceField方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitAL

        public static void InitAL()
        {
#if !NO_AUDIO
            var paramList = new int[]
            {
                (int) AlcContextAttributes.StereoSources, TR_AUDIO_STREAM_NUMSOURCES,
                (int) AlcContextAttributes.MonoSources,
                TR_AUDIO_MAX_CHANNELS - TR_AUDIO_STREAM_NUMSOURCES,
                (int) AlcContextAttributes.Frequency, 44100, 0
            };

            Sys.DebugLog(LOG_FILENAME, "Probing OpenAL devices...");

            IList<string> devlist = null;

            var t = new Thread(() =>
            {
                var tmp = Alc.GetString(IntPtr.Zero, AlcGetStringList.DeviceSpecifier);
                devlist = tmp;
            });
            t.Start();
            if (!t.Join(10000))
            {
                t.Abort();
                if (devlist == null || devlist.Count == 0)
                {
                    Sys.DebugLog(LOG_FILENAME, "InitAL: Error while probing OpenAL devices. Exiting.");
                    Shutdown(1);
                }
            }

            if (devlist.Count == 0)
            {
                Sys.DebugLog(LOG_FILENAME, "InitAL: No AL audio devices!");
                return;
            }

            foreach (var s in devlist)
            {
                Sys.DebugLog(LOG_FILENAME, " Device: {0}", s);

                try
                {
                    ALContext = new AudioContext(s, 44100, 0, false, true);
                    ALDevice = (IntPtr) ALContext.GetInstanceField("device_handle");
                    break;
                }
                catch (Exception e)
                {
                    Sys.DebugLog(LOG_FILENAME, "Failed to create OpenAL Context on device '{0}': {1}", s, e.Message);
                }

                /*var dev = Alc.OpenDevice(s);

                    if(Global.AudioSettings.UseEffects)
                    {
                        if(Alc.IsExtensionPresent(dev, "ALC_EXT_EFX"))
                        {
                            Sys.DebugLog(LOG_FILENAME, " EFX supported!");
                            ALDevice = dev;
                            ALContext = Alc.CreateContext(dev, paramList);
                            // fails e.g. with Rapture3D, where EFX is supported
                            if(ALContext != ContextHandle.Zero)
                            {
                                break;
                            }
                        }
                        Alc.CloseDevice(dev);
                    }
                    else
                    {
                        ALDevice = dev;
                        ALContext = Alc.CreateContext(dev, paramList);
                        break;
                    }*/
            }

            /*if(ALContext == ContextHandle.Zero)
                {
                    Sys.DebugLog(LOG_FILENAME, " Failed to create OpenAL context.");
                    Alc.CloseDevice(ALDevice);
                    ALDevice = IntPtr.Zero;
                    return;
                }*/

            var driver = "OpenAL library: " + Alc.GetString(ALDevice, AlcGetString.DeviceSpecifier);
            ConsoleInfo.Instance.AddLine(driver, FontStyle.ConsoleInfo);

            AL.SpeedOfSound(330.0f * 512.0f);
            AL.DopplerVelocity(330.0f * 510.0f);
            AL.DistanceModel(ALDistanceModel.LinearDistanceClamped);

            Audio.EffectsExtension = new EffectsExtension();
#endif
        }
开发者ID:zdimension,项目名称:FreeRaider,代码行数:95,代码来源:Engine.cs


注:本文中的OpenTK.Audio.AudioContext.GetInstanceField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。