Esempio n. 1
0
        /// <summary>
        /// Calculates DSP settings for the specified listener and emitter. See remarks.
        /// </summary>
        /// <param name="listener">The <see cref="Listener"/>.</param>
        /// <param name="emitter">The <see cref="Emitter"/>.</param>
        /// <param name="flags">The <see cref="CalculateFlags"/>.</param>
        /// <param name="settings">The <see cref="DspSettings"/>.</param>
        /// <remarks>The source and destination channel count must be set on <see cref="DspSettings" /> before calling this method.</remarks>
        public void Calculate(Listener listener, Emitter emitter, CalculateFlags flags, DspSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            DspSettings.__Native settingsNative;
            settingsNative.SrcChannelCount = settings.SourceChannelCount;
            settingsNative.DstChannelCount = settings.DestinationChannelCount;

            unsafe
            {
                fixed(void *pMatrix = settings.MatrixCoefficients)
                {
                    fixed(void *pDelays = settings.DelayTimes)
                    {
                        settingsNative.MatrixCoefficientsPointer = (IntPtr)pMatrix;
                        settingsNative.DelayTimesPointer         = (IntPtr)pDelays;

                        XAudio2Native.X3DAudioCalculate(ref _handle, listener, emitter, flags, new IntPtr(&settingsNative));
                    }
                }
            }

            settings.__MarshalFrom(ref settingsNative);
        }
Esempio n. 2
0
 internal IXAudio2(ProcessorSpecifier processorSpecifier, bool registerCallback)
     : base(XAudio2Native.XAudio2Create(0, processorSpecifier))
 {
     // Register engine callback
     if (registerCallback)
     {
         _engineCallback = new EngineCallbackImpl(this);
         RegisterForCallbacks(_engineCallback);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Create new instance of <see cref="IXAudio2"/> class.
        /// </summary>
        /// <param name="processorSpecifier"></param>
        /// <param name="registerCallback">Whether to register for callback, uses native RegisterForCallbacks.</param>
        public IXAudio2(
            ProcessorSpecifier processorSpecifier = ProcessorSpecifier.UseDefaultProcessor,
            bool registerCallback = true)
            : base(IntPtr.Zero)
        {
            NativePointer = XAudio2Native.XAudio2Create(0, processorSpecifier);

            // Register engine callback
            if (registerCallback)
            {
                _engineCallback = new EngineCallbackImpl(this);
                RegisterForCallbacks(_engineCallback);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X3DAudio"/> class.
 /// </summary>
 /// <param name="speakers">The speakers config.</param>
 /// <param name="speedOfSound">The speed of sound.</param>
 public X3DAudio(Speakers speakers, float speedOfSound)
 {
     XAudio2Native.X3DAudioInitialize(speakers, speedOfSound, out _handle).CheckError();
 }