private void SetFilterPreprocessor(IntPtr preprocessor)
            {
                using (var handle = _handle.Lock())
                {
                    if (handle.Value == IntPtr.Zero)
                    {
                        throw Log.CreatePossibleBugException("Attempted  to access a null WebRtc Preprocessor encoder", "3BA66D46-A7A6-41E8-BE38-52AFE5212ACD");
                    }

                    Log.Debug("Exchanging preprocessor instance in playback filter...");

                    if (!Dissonance_PreprocessorExchangeInstance(IntPtr.Zero, handle.Value))
                    {
                        throw Log.CreatePossibleBugException("Cannot associate preprocessor with Playback filter - one already exists", "D5862DD2-B44E-4605-8D1C-29DD2C72A70C");
                    }

                    Log.Debug("...Exchanged preprocessor instance in playback filter");

                    var state = (FilterState)Dissonance_GetFilterState();
                    if (state == FilterState.FilterNotRunning)
                    {
                        Log.Debug("Associated preprocessor with playback filter - but filter is not running");
                    }

                    Bind(s => s.DenoiseAmount, "DenoiseAmount", v => NoiseSuppressionLevel             = (NoiseSuppressionLevels)v);
                    Bind(s => s.AecSuppressionAmount, "AecSuppressionAmount", v => AecSuppressionLevel = (AecSuppressionLevels)v);
                    Bind(s => s.AecmRoutingMode, "AecmRoutingMode", v => AecmSuppressionLevel          = (AecmRoutingMode)v);
                    Bind(s => s.VadSensitivity, "VadSensitivity", v => VadSensitivityLevel             = v);
                }
            }
            public WebRtcPreprocessor(bool useMobileAec)
            {
                _useMobileAec = useMobileAec;
                _handle       = new LockedValue <IntPtr>(IntPtr.Zero);

                NoiseSuppressionLevel = VoiceSettings.Instance.DenoiseAmount;
                AecSuppressionLevel   = VoiceSettings.Instance.AecSuppressionAmount;
                AecmSuppressionLevel  = VoiceSettings.Instance.AecmRoutingMode;
            }
 public static extern IntPtr Dissonance_CreatePreprocessor(
     NoiseSuppressionLevels nsLevel,
     AecSuppressionLevels aecLevel,
     bool aecDelayAgnostic,
     bool aecExtended,
     bool aecRefined,
     AecmRoutingMode aecmRoutingMode,
     bool aecmComfortNoise
     );
            public WebRtcPreprocessor(bool useMobileAec)
            {
                _useMobileAec = useMobileAec;

                _nsLevel   = VoiceSettings.Instance.DenoiseAmount;
                _aecLevel  = VoiceSettings.Instance.AecSuppressionAmount;
                _aecmLevel = VoiceSettings.Instance.AecmRoutingMode;

                _handle = new LockedValue <IntPtr>(CreatePreprocessor());

                using (var handle = _handle.Lock())
                    SetFilterPreprocessor(handle.Value);
            }
 private static extern void Dissonance_ConfigureAecSuppression(IntPtr handle, AecSuppressionLevels aecLevel, AecmRoutingMode aecmRouting);