Exemplo n.º 1
0
        public unsafe void Calculate(Listener listener, Emitter emitter, CalculateFlags flags, DspSettings *result)
        {
            Debug.Assert((flags & CalculateFlags.Delay) == 0 || (result->DelayTimesPointer != IntPtr.Zero), "When CalculateFlags.Delay is specified, DelayTimesPointer must point to float[DstChannelCount]");
            Debug.Assert((flags & CalculateFlags.Matrix) == 0 || (result->MatrixCoefficientsPointer != IntPtr.Zero), "When CalculateFlags.Matrix is specified, MatrixCoefficientsPointer must point to float[SrcChannelCount*DstChannelCount]");

            Cone emitterCone;

            Emitter.Native nativeEmitter = new Emitter.Native();

            Cone listenerCone;

            Listener.Native nativeListener = new Listener.Native();

            {
                if (emitter.Cone.HasValue)
                {
                    emitterCone = emitter.Cone.Value;
                    nativeEmitter.ConePointer = new IntPtr(&emitterCone);
                }
                else
                {
                    nativeEmitter.ConePointer = IntPtr.Zero;
                }
                nativeEmitter.OrientFront            = emitter.OrientFront;
                nativeEmitter.OrientTop              = emitter.OrientTop;
                nativeEmitter.Position               = emitter.Position;
                nativeEmitter.Velocity               = emitter.Velocity;
                nativeEmitter.InnerRadius            = emitter.InnerRadius;
                nativeEmitter.InnerRadiusAngle       = emitter.InnerRadiusAngle;
                nativeEmitter.ChannelCount           = emitter.ChannelCount;
                nativeEmitter.ChannelRadius          = emitter.ChannelRadius;
                nativeEmitter.ChannelAzimuthsPointer = emitter.ChannelAzimuths.ToPointer();
                nativeEmitter.VolumeCurvePointer     = emitter.VolumeCurve.ToPointer();
                nativeEmitter.LFECurvePointer        = emitter.LFECurve.ToPointer();
                nativeEmitter.LPFDirectCurvePointer  = emitter.LPFDirectCurve.ToPointer();
                nativeEmitter.LPFReverbCurvePointer  = emitter.LPFReverbCurve.ToPointer();
                nativeEmitter.ReverbCurvePointer     = emitter.ReverbCurve.ToPointer();
                nativeEmitter.CurveDistanceScaler    = emitter.CurveDistanceScaler;
                nativeEmitter.DopplerScaler          = emitter.DopplerScaler;

                if (listener.Cone.HasValue)
                {
                    listenerCone = listener.Cone.Value;
                    nativeListener.ConePointer = new IntPtr(&listenerCone);
                }
                else
                {
                    nativeListener.ConePointer = IntPtr.Zero;
                }
                nativeListener.OrientFront = listener.OrientFront;
                nativeListener.OrientTop   = listener.OrientTop;
                nativeListener.Position    = listener.Position;
                nativeListener.Velocity    = listener.Velocity;

                fixed(X3DAudioHandle *handle = &m_x3dAudioHandle)
                {
                    X3DAudioCalculate_(handle, &nativeListener, &nativeEmitter, (int)flags, result);
                }
            }
        }
Exemplo n.º 2
0
        public unsafe void Calculate(Listener listener, Emitter emitter, CalculateFlags flags, DspSettings* result)
        {
            Debug.Assert((flags & CalculateFlags.Delay) == 0 || (result->DelayTimesPointer != IntPtr.Zero), "When CalculateFlags.Delay is specified, DelayTimesPointer must point to float[DstChannelCount]");
            Debug.Assert((flags & CalculateFlags.Matrix) == 0 || (result->MatrixCoefficientsPointer != IntPtr.Zero), "When CalculateFlags.Matrix is specified, MatrixCoefficientsPointer must point to float[SrcChannelCount*DstChannelCount]");

            Cone emitterCone;
            Emitter.Native nativeEmitter = new Emitter.Native();

            Cone listenerCone;
            Listener.Native nativeListener = new Listener.Native();

            {
                if (emitter.Cone.HasValue)
                {
                    emitterCone = emitter.Cone.Value;
                    nativeEmitter.ConePointer = new IntPtr(&emitterCone);
                }
                else
                {
                    nativeEmitter.ConePointer = IntPtr.Zero;
                }
                nativeEmitter.OrientFront = emitter.OrientFront;
                nativeEmitter.OrientTop = emitter.OrientTop;
                nativeEmitter.Position = emitter.Position;
                nativeEmitter.Velocity = emitter.Velocity;
                nativeEmitter.InnerRadius = emitter.InnerRadius;
                nativeEmitter.InnerRadiusAngle = emitter.InnerRadiusAngle;
                nativeEmitter.ChannelCount = emitter.ChannelCount;
                nativeEmitter.ChannelRadius = emitter.ChannelRadius;
                nativeEmitter.ChannelAzimuthsPointer = emitter.ChannelAzimuths.ToPointer();
                nativeEmitter.VolumeCurvePointer = emitter.VolumeCurve.ToPointer();
                nativeEmitter.LFECurvePointer = emitter.LFECurve.ToPointer();
                nativeEmitter.LPFDirectCurvePointer = emitter.LPFDirectCurve.ToPointer();
                nativeEmitter.LPFReverbCurvePointer = emitter.LPFReverbCurve.ToPointer();
                nativeEmitter.ReverbCurvePointer = emitter.ReverbCurve.ToPointer();
                nativeEmitter.CurveDistanceScaler = emitter.CurveDistanceScaler;
                nativeEmitter.DopplerScaler = emitter.DopplerScaler;

                if (listener.Cone.HasValue)
                {
                    listenerCone = listener.Cone.Value;
                    nativeListener.ConePointer = new IntPtr(&listenerCone);
                }
                else
                {
                    nativeListener.ConePointer = IntPtr.Zero;
                }
                nativeListener.OrientFront = listener.OrientFront;
                nativeListener.OrientTop = listener.OrientTop;
                nativeListener.Position = listener.Position;
                nativeListener.Velocity = listener.Velocity;

                fixed (X3DAudioHandle* handle = &m_x3dAudioHandle)
                {
                    X3DAudioCalculate_(handle, &nativeListener, &nativeEmitter, (int)flags, result);
                }
            }
        }