本文整理匯總了C#中Microsoft.Xna.Framework.Audio.AudioListener.ToListener方法的典型用法代碼示例。如果您正苦於以下問題:C# AudioListener.ToListener方法的具體用法?C# AudioListener.ToListener怎麽用?C# AudioListener.ToListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Microsoft.Xna.Framework.Audio.AudioListener
的用法示例。
在下文中一共展示了AudioListener.ToListener方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PlatformApply3D
private void PlatformApply3D(AudioListener listener, AudioEmitter emitter)
{
// If we have no voice then nothing to do.
if (_voice == null)
return;
// Convert from XNA Emitter to a SharpDX Emitter
var e = emitter.ToEmitter();
e.CurveDistanceScaler = SoundEffect.DistanceScale;
e.DopplerScaler = SoundEffect.DopplerScale;
e.ChannelCount = _effect._format.Channels;
// Convert from XNA Listener to a SharpDX Listener
var l = listener.ToListener();
// Number of channels in the sound being played.
// Not actually sure if XNA supported 3D attenuation of sterio sounds, but X3DAudio does.
var srcChannelCount = _effect._format.Channels;
// Number of output channels.
var dstChannelCount = SoundEffect.MasterVoice.VoiceDetails.InputChannelCount;
// XNA supports distance attenuation and doppler.
var dpsSettings = SoundEffect.Device3D.Calculate(l, e, CalculateFlags.Matrix | CalculateFlags.Doppler, srcChannelCount, dstChannelCount);
// Apply Volume settings (from distance attenuation) ...
_voice.SetOutputMatrix(SoundEffect.MasterVoice, srcChannelCount, dstChannelCount, dpsSettings.MatrixCoefficients, 0);
// Apply Pitch settings (from doppler) ...
_voice.SetFrequencyRatio(dpsSettings.DopplerFactor);
}