Ejemplo n.º 1
0
            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 (!AudioPluginDissonanceNative.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 = (AudioPluginDissonanceNative.FilterState)AudioPluginDissonanceNative.Dissonance_GetFilterState();
                    if (state == AudioPluginDissonanceNative.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);
                }
            }
Ejemplo n.º 2
0
            private bool ClearFilterPreprocessor(bool throwOnError = true)
            {
                using (var handle = _handle.Lock())
                {
                    if (handle.Value == IntPtr.Zero)
                    {
                        throw Log.CreatePossibleBugException("Attempted to access a null WebRtc Preprocessor encoder", "2DBC7779-F1B9-45F2-9372-3268FD8D7EBA");
                    }

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

                    //Clear binding in native code
                    if (!AudioPluginDissonanceNative.Dissonance_PreprocessorExchangeInstance(handle.Value, IntPtr.Zero))
                    {
                        if (throwOnError)
                        {
                            throw Log.CreatePossibleBugException("Cannot clear preprocessor from Playback filter. Editor restart required!", "6323106A-04BD-4217-9ECA-6FD49BF04FF0");
                        }
                        else
                        {
                            Log.Error("Failed to clear preprocessor from playback filter. Editor restart required!", "CBC6D727-BE07-4073-AA5A-F750A0CC023D");
                        }

                        return(false);
                    }

                    //Clear event handlers from voice settings
                    var settings = VoiceSettings.Instance;
                    for (var i = 0; i < _subscribed.Count; i++)
                    {
                        settings.PropertyChanged -= _subscribed[i];
                    }
                    _subscribed.Clear();

                    Log.Debug("...Cleared preprocessor instance in playback filter");
                    return(true);
                }
            }