本文整理汇总了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
}