示例#1
0
            public void Process(AudioPluginDissonanceNative.SampleRates inputSampleRate, float[] input, float[] output)
            {
                if (Enabled)
                {
                    using (var handle = _handle.Lock())
                    {
                        if (handle.Value == IntPtr.Zero)
                        {
                            throw Log.CreatePossibleBugException("Attempted to access a null WebRtc Rnnoise", "1014ecad-f1cf-4377-a2cd-31e46df55b08");
                        }

                        // Allocate a temporary buffer to store the output of rnnoise
                        if (_temp == null || _temp.Length != output.Length)
                        {
                            _temp = new float[output.Length];
                        }

                        if (!AudioPluginDissonanceNative.Dissonance_RnnoiseProcessFrame(handle.Value, input.Length, (int)inputSampleRate, input, _temp))
                        {
                            Log.Warn("Dissonance_RnnoiseProcessFrame returned false");
                        }

                        // Linear crossfade between input(dry) and _temp(wet). This is a linear crossfade instead of an
                        // equal power crossfade because input and wet are very highly correlated in most cases. Also
                        // the AGC runs after this, so a slight drop in amplitude won't really matter.
                        var wetmix = _wetMix;
                        var drymix = 1 - wetmix;
                        for (var i = 0; i < input.Length; i++)
                        {
                            output[i] = input[i] * drymix + _temp[i] * wetmix;
                        }
                    }
                }
                else
                {
                    if (input != output)
                    {
                        Array.Copy(input, output, input.Length);
                    }
                }
            }
示例#2
0
            public bool Process(AudioPluginDissonanceNative.SampleRates inputSampleRate, float[] input, float[] output, int estimatedStreamDelay, bool isOutputMuted)
            {
                using (var handle = _handle.Lock())
                {
                    if (handle.Value == IntPtr.Zero)
                    {
                        throw Log.CreatePossibleBugException("Attempted  to access a null WebRtc Preprocessor encoder", "5C97EF6A-353B-4B96-871F-1073746B5708");
                    }

                    AudioPluginDissonanceNative.Dissonance_SetAgcIsOutputMutedState(handle.Value, isOutputMuted);
                    Log.Trace("Set IsOutputMuted to `{0}`", isOutputMuted);

                    var result = AudioPluginDissonanceNative.Dissonance_PreprocessCaptureFrame(handle.Value, (int)inputSampleRate, input, output, estimatedStreamDelay);
                    if (result != AudioPluginDissonanceNative.ProcessorErrors.Ok)
                    {
                        throw Log.CreatePossibleBugException(string.Format("Preprocessor error: '{0}'", result), "0A89A5E7-F527-4856-BA01-5A19578C6D88");
                    }

                    return(AudioPluginDissonanceNative.Dissonance_GetVadSpeechState(handle.Value));
                }
            }