コード例 #1
0
ファイル: X3DAudio.cs プロジェクト: ng08000/Vortice.Windows
        /// <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);
        }
コード例 #2
0
 internal IXAudio2(ProcessorSpecifier processorSpecifier, bool registerCallback)
     : base(XAudio2Native.XAudio2Create(0, processorSpecifier))
 {
     // Register engine callback
     if (registerCallback)
     {
         _engineCallback = new EngineCallbackImpl(this);
         RegisterForCallbacks(_engineCallback);
     }
 }
コード例 #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);
            }
        }
コード例 #4
0
ファイル: X3DAudio.cs プロジェクト: ng08000/Vortice.Windows
 /// <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();
 }