예제 #1
0
 private void BackupOldParameters()
 {
     _oldFreqeuncy = _radio.Frequency();
     _oldAgc       = _radio.Agc();
     _oldIfGain    = _radio.IfGain();
     //_oldSagc = _radio.Demodulator().SoftwareAgc();
 }
예제 #2
0
        /// <summary>
        /// Constructs an instance of the WebRtcFilter.
        /// </summary>
        /// <param name="expectedAudioLatency">The expected audio latency in milliseconds</param>
        /// <param name="filterLength">The length of the echo cancellation filter in milliseconds</param>
        /// <param name="recordedAudioFormat">The audio format into which the recorded audio has been transformed prior to encoding (e.g., not the raw audio)</param>
        /// <param name="playedAudioFormat">The audio format which the audio must be transformed after decoding and before playing</param>
        /// <param name="enableAec">Whether to enable acoustic echo cancellation</param>
        /// <param name="enableDenoise">Whether to enable denoising</param>
        /// <param name="enableAgc">Whether to enable automatic gain control</param>
        /// <param name="playedResampler">The resampler which should be used on played audio</param>
        /// <param name="recordedResampler">The resampler which should be used on recorded audio</param>
        public WebRtcFilter(int expectedAudioLatency, int filterLength,
                            AudioFormat recordedAudioFormat, AudioFormat playedAudioFormat,
                            bool enableAec, bool enableDenoise, bool enableAgc,
                            IAudioFilter playedResampler = null, IAudioFilter recordedResampler = null) :
            base(expectedAudioLatency, filterLength, recordedAudioFormat, playedAudioFormat, playedResampler, recordedResampler)
        {
            // Default settings.
            var aecConfig = new AecConfig(FilterLength, recordedAudioFormat.SamplesPerFrame, recordedAudioFormat.SamplesPerSecond)
            {
                NlpMode     = AecNlpMode.KAecNlpModerate,
                SkewMode    = false,
                MetricsMode = false
            };

            _ns  = new NoiseSuppressor(recordedAudioFormat);
            _aec = new AecCore(aecConfig);

            if (aecConfig.NlpMode != AecNlpMode.KAecNlpConservative &&
                aecConfig.NlpMode != AecNlpMode.KAecNlpModerate &&
                aecConfig.NlpMode != AecNlpMode.KAecNlpAggressive)
            {
                throw new ArgumentException();
            }

            _aec.targetSupp   = WebRtcConstants.targetSupp[(int)aecConfig.NlpMode];
            _aec.minOverDrive = WebRtcConstants.minOverDrive[(int)aecConfig.NlpMode];

            if (aecConfig.MetricsMode && aecConfig.MetricsMode != true)
            {
                throw new ArgumentException();
            }
            _aec.metricsMode = aecConfig.MetricsMode;
            if (_aec.metricsMode)
            {
                _aec.InitMetrics();
            }
            _enableAec     = enableAec;
            _enableDenoise = enableDenoise;
            _enableAgc     = enableAgc;

            _agc = new Agc(0, 255, Agc.AgcMode.AgcModeAdaptiveDigital, (uint)recordedAudioFormat.SamplesPerSecond);
        }
예제 #3
0
        /// <summary>
        /// Sets Automatic gain control mode.
        /// </summary>
        /// <param name="value"><see cref="G313.Agc"/> Specified mode</param>
        /// <returns>Returns <see cref="G313Radio"/> radio instance.</returns>
        public G313Radio Agc(Agc value)
        {
            var result = TryAgc(value);

            return(CheckFluent(result, string.Format("failed to set agc, value:'{0}'", value)));
        }
예제 #4
0
 /// <summary>
 /// Sets Automatic gain control mode.
 /// </summary>
 /// <param name="value"><see cref="G313.Agc"/> Specified mode</param>
 /// <returns>Returns true if the specified mode is set.</returns>
 public bool TryAgc(Agc value)
 {
     return(G313Api.SetAGC(GetHandle(), (int)value));
 }