Пример #1
0
        public void Apply3D(AudioListener listener, AudioEmitter emitter)
        {
            if (listener == null)
            {
                throw new ArgumentNullException("listener");
            }
            if (emitter == null)
            {
                throw new ArgumentNullException("emitter");
            }
            if (IsDisposed)
            {
                throw new ObjectDisposedException(
                          "SoundEffectInstance"
                          );
            }

            is3D = true;
            SoundEffect.FAudioContext dev = SoundEffect.Device();
            emitter.emitterData.CurveDistanceScaler = dev.CurveDistanceScaler;
            emitter.emitterData.ChannelCount        = dspSettings.SrcChannelCount;
            FAudio.F3DAudioCalculate(
                dev.Handle3D,
                ref listener.listenerData,
                ref emitter.emitterData,
                (
                    FAudio.F3DAUDIO_CALCULATE_MATRIX |
                    FAudio.F3DAUDIO_CALCULATE_DOPPLER
                ),
                ref dspSettings
                );
            if (handle != IntPtr.Zero)
            {
                UpdatePitch();
                FAudio.FAudioVoice_SetOutputMatrix(
                    handle,
                    SoundEffect.Device().MasterVoice,
                    dspSettings.SrcChannelCount,
                    dspSettings.DstChannelCount,
                    dspSettings.pMatrixCoefficients,
                    0
                    );
            }
        }