Exemple #1
0
        /// <summary>
        /// Calculates DSP settings for the specified listener and emitter.
        /// </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="sourceChannelCount">The source channel count.</param>
        /// <param name="destinationChannelCount">The destination channel count.</param>
        /// <returns>An instance of <see cref="DspSettings"/> class.</returns>
        public DspSettings Calculate(Listener listener, Emitter emitter, CalculateFlags flags, int sourceChannelCount, int destinationChannelCount)
        {
            var settings = new DspSettings(sourceChannelCount, destinationChannelCount);

            Calculate(listener, emitter, flags, settings);
            return(settings);
        }
Exemple #2
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;

                        _calculateDelegate(ref _handle, listener, emitter, flags, new IntPtr(&settingsNative));
                    }
                }
            }

            settings.__MarshalFrom(ref settingsNative);
        }