private void PlatformApply3D(AudioListener listener, AudioEmitter emitter)
        {
            // If we have no voice then nothing to do.
            if (_voice == null || SoundEffect.MasterVoice == null)
            {
                return;
            }

            // Convert from XNA Emitter to a SharpDX Emitter
            var e = ToDXEmitter(emitter);

            e.CurveDistanceScaler = SoundEffect.DistanceScale;
            e.DopplerScaler       = SoundEffect.DopplerScale;
            e.ChannelCount        = _effect._format.Channels;

            //stereo channel
            if (e.ChannelCount > 1)
            {
                e.ChannelRadius   = 0;
                e.ChannelAzimuths = _defaultChannelAzimuths;
            }

            // Convert from XNA Listener to a SharpDX Listener
            var l = ToDXListener(listener);

            // 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);
        }
        private Emitter ToDXEmitter(AudioEmitter emitter)
        {
            // Pulling out Vector properties for efficiency.
            var pos     = emitter.Position;
            var vel     = emitter.Velocity;
            var forward = emitter.Forward;
            var up      = emitter.Up;

            // From MSDN:
            //  X3DAudio uses a left-handed Cartesian coordinate system,
            //  with values on the x-axis increasing from left to right, on the y-axis from bottom to top,
            //  and on the z-axis from near to far.
            //  Azimuths are measured clockwise from a given reference direction.
            //
            // From MSDN:
            //  The XNA Framework uses a right-handed coordinate system,
            //  with the positive z-axis pointing toward the observer when the positive x-axis is pointing to the right,
            //  and the positive y-axis is pointing up.
            //
            // Programmer Notes:
            //  According to this description the z-axis (forward vector) is inverted between these two coordinate systems.
            //  Therefore, we need to negate the z component of any position/velocity values, and negate any forward vectors.

            forward *= -1.0f;
            pos.Z   *= -1.0f;
            vel.Z   *= -1.0f;

            if (_dxEmitter == null)
            {
                _dxEmitter = new Emitter();
            }

            _dxEmitter.Position      = new RawVector3(pos.X, pos.Y, pos.Z);
            _dxEmitter.Velocity      = new RawVector3(vel.X, vel.Y, vel.Z);
            _dxEmitter.OrientFront   = new RawVector3(forward.X, forward.Y, forward.Z);
            _dxEmitter.OrientTop     = new RawVector3(up.X, up.Y, up.Z);
            _dxEmitter.DopplerScaler = emitter.DopplerScale;
            return(_dxEmitter);
        }
 private void PlatformApply3D(AudioListener listener, AudioEmitter emitter)
 {
 }