Exemplo n.º 1
0
        private unsafe void Configure()
        {
            this._osc.SampleRate = this._sampleRate;
            this._osc.Frequency  = 57000.0;
            int i;

            for (i = 0; this._sampleRate >= (double)(20000 << i); i++)
            {
            }
            this._decimationFactor       = 1 << i;
            this._demodulationSampleRate = this._sampleRate / (double)this._decimationFactor;
            this._decimator = new DownConverter(this._demodulationSampleRate, this._decimationFactor);
            float[] coefficients = FilterBuilder.MakeLowPassKernel(this._demodulationSampleRate, 200, 2500.0, WindowType.BlackmanHarris4);
            this._baseBandFilter        = new IQFirFilter(coefficients, 1);
            this._pll->SampleRate       = (float)this._demodulationSampleRate;
            this._pll->DefaultFrequency = 0f;
            this._pll->Range            = 12f;
            this._pll->Bandwidth        = 1f;
            this._pll->Zeta             = 0.707f;
            this._pll->LockTime         = 0.5f;
            this._pll->LockThreshold    = 3.2f;
            int length = (int)(this._demodulationSampleRate / 1187.5) | 1;

            coefficients        = FilterBuilder.MakeSin(this._demodulationSampleRate, 1187.5, length);
            this._matchedFilter = new FirFilter(coefficients, 1);
            this._syncFilter->Init(IirFilterType.BandPass, 1187.5, this._demodulationSampleRate, 500.0);
        }
Exemplo n.º 2
0
 public void Dispose()
 {
     if (this._dec != IntPtr.Zero)
     {
         DownConverter.ddc_destroy(this._dec);
         this._dec = IntPtr.Zero;
     }
 }
Exemplo n.º 3
0
        private void Configure(bool refreshOnly = true)
        {
            if (this._sampleRate != 0.0)
            {
                this._actualDetectorType = this._detectorType;
                bool refresh = false;
                this._baseBandDecimationStageCount = StreamControl.GetDecimationStageCount(this._sampleRate, this._actualDetectorType);
                this._audioDecimationStageCount    = this._decimationStageCount - this._baseBandDecimationStageCount;
                int    num  = 1 << this._baseBandDecimationStageCount;
                double num2 = this._sampleRate / (double)num;
                if (!refreshOnly || this._mainDownConverter == null || this._mainDownConverter.SampleRate != this._sampleRate || this._mainDownConverter.DecimationRatio != num)
                {
                    this._mainDownConverter = new DownConverter(this._sampleRate, num);
                    refresh = true;
                    this.ConfigureHookSampleRates();
                }
                this._mainDownConverter.Frequency = (double)this._frequency;
                if (!refreshOnly || this._ifOffsetTranslator == null || this._ifOffsetTranslator.SampleRate != num2)
                {
                    this._ifOffsetTranslator = new FrequencyTranslator(num2);
                }
                this._ifOffsetTranslator.Frequency = (double)(-this._ifOffset);
                this.UpdateFilters(refresh);
                this._carrierLocker.SampleRate    = num2;
                this._cwDetector.SampleRate       = num2;
                this._fmDetector.SampleRate       = num2;
                this._fmDetector.SquelchThreshold = this._squelchThreshold;
                this._amDetector.SquelchThreshold = this._squelchThreshold;
                this._stereoDecoder.Configure(this._fmDetector.SampleRate, this._audioDecimationStageCount);
                this._rdsDecoder.SampleRate   = this._fmDetector.SampleRate;
                this._stereoDecoder.ForceMono = !this._fmStereo;
                switch (this._actualDetectorType)
                {
                case DetectorType.CW:
                    this._cwDetector.BfoFrequency = this._cwToneShift;
                    break;

                case DetectorType.NFM:
                    this._fmDetector.Mode = FmMode.Narrow;
                    break;

                case DetectorType.WFM:
                    this._fmDetector.Mode = FmMode.Wide;
                    break;
                }
                this._agc.SampleRate = this._sampleRate / (double)(1 << this._decimationStageCount);
                this._agc.Decay      = this._agcDecay;
                this._agc.Slope      = this._agcSlope;
                this._agc.Threshold  = this._agcThreshold;
                this._agc.UseHang    = this._agcUseHang;
                this._needConfigure  = false;
            }
        }
Exemplo n.º 4
0
        private void Configure()
        {
            _actualDetectorType = _detectorType;
            var multiThreaded = _sampleRate >= _minThreadedSampleRate;
            if (_downConverter == null || (multiThreaded && _downConverter.PhaseCount > 1))
            {
                _downConverter = new DownConverter(multiThreaded ? Environment.ProcessorCount : 1);
            }
            _downConverter.SampleRate = _sampleRate;
            _downConverter.Frequency = _frequency;
            if (_needNewDecimators || _baseBandDecimator == null)
            {
                _needNewDecimators = false;
                if (_actualDetectorType == DetectorType.WFM)
                {
                    var afSamplerate = _sampleRate / Math.Pow(2.0, _decimationStageCount);
                    _audioDecimationStageCount = 0;
                    while (afSamplerate * Math.Pow(2.0, _audioDecimationStageCount) < DefaultWFMBandwidth && _audioDecimationStageCount < _decimationStageCount)
                    {
                        _audioDecimationStageCount++;
                    }
                    _baseBandDecimationStageCount = _decimationStageCount - _audioDecimationStageCount;
                }
                else
                {
                    _baseBandDecimationStageCount = _decimationStageCount;
                    _audioDecimationStageCount = 0;
                }
                _baseBandDecimator = new IQDecimator(_baseBandDecimationStageCount, _sampleRate, false, Environment.ProcessorCount > 1);
                _needNewFilters = true;
            }
            if (_needNewFilters)
            {
                _needNewFilters = false;
                InitFilters();
            }
            var baseBandSampleRate = _sampleRate / Math.Pow(2.0, _baseBandDecimationStageCount);
            _usbDetector.SampleRate = baseBandSampleRate;
            _lsbDetector.SampleRate = baseBandSampleRate;
            _cwDetector.SampleRate = baseBandSampleRate;
            _fmDetector.SampleRate = baseBandSampleRate;
            _fmDetector.SquelchThreshold = _squelchThreshold;
            _amDetector.SquelchThreshold = _squelchThreshold;
            _stereoDecoder.Configure(_fmDetector.SampleRate, _audioDecimationStageCount);
            _rdsDecoder.SampleRate = _fmDetector.SampleRate;
            _stereoDecoder.ForceMono = !_fmStereo;
            switch (_actualDetectorType)
            {
                case DetectorType.USB:
                    _usbDetector.BfoFrequency = -_bandwidth / 2;
                    _downConverter.Frequency -= _usbDetector.BfoFrequency;
                    break;

                case DetectorType.LSB:
                    _lsbDetector.BfoFrequency = -_bandwidth / 2;
                    _downConverter.Frequency += _lsbDetector.BfoFrequency;
                    break;

                case DetectorType.CW:
                    _cwDetector.BfoFrequency = _cwToneShift;
                    break;

                case DetectorType.NFM:
                    _fmDetector.Mode = FmMode.Narrow;
                    break;

                case DetectorType.WFM:
                    _fmDetector.Mode = FmMode.Wide;
                    break;
            }

            _agc.SampleRate = _sampleRate / Math.Pow(2.0, _decimationStageCount);
            _agc.Decay = _agcDecay;
            _agc.Slope = _agcSlope;
            _agc.Threshold = _agcThreshold;
            _agc.UseHang = _agcUseHang;

            _decimationModeHasChanged = false;
        }
Exemplo n.º 5
0
 public unsafe int Process(Complex *buffer, int length)
 {
     return(DownConverter.ddc_process(this._dec, buffer, length));
 }
Exemplo n.º 6
0
 public DownConverter(double sampleRate, int decimationRatio)
 {
     this._sampleRate      = sampleRate;
     this._decimationRatio = decimationRatio;
     this._dec             = DownConverter.ddc_create(this._sampleRate, this._decimationRatio);
 }
Exemplo n.º 7
0
        private void Configure()
        {
            _actualDetectorType = _detectorType;
            var multiThreaded = _sampleRate >= _minThreadedSampleRate;

            if (_downConverter == null || (multiThreaded && _downConverter.PhaseCount > 1))
            {
                _downConverter = new DownConverter(multiThreaded ? Environment.ProcessorCount : 1);
            }
            _downConverter.SampleRate = _sampleRate;
            _downConverter.Frequency  = _frequency;
            if (_needNewDecimators || _baseBandDecimator == null)
            {
                _needNewDecimators = false;
                if (_actualDetectorType == DetectorType.WFM)
                {
                    var afSamplerate = _sampleRate / (1 << _decimationStageCount);
                    _audioDecimationStageCount = 0;
                    while (afSamplerate * (1 << _audioDecimationStageCount) < DefaultWFMBandwidth && _audioDecimationStageCount < _decimationStageCount)
                    {
                        _audioDecimationStageCount++;
                    }
                    _baseBandDecimationStageCount = _decimationStageCount - _audioDecimationStageCount;
                }
                else
                {
                    _baseBandDecimationStageCount = _decimationStageCount;
                    _audioDecimationStageCount    = 0;
                }
                _baseBandDecimator = new IQDecimator(_baseBandDecimationStageCount, _sampleRate, false, Environment.ProcessorCount > 1);

                if (_hookManager != null)
                {
                    _hookManager.SetProcessorSampleRate(ProcessorType.RawIQ, _sampleRate);
                    _hookManager.SetProcessorSampleRate(ProcessorType.FrequencyTranslatedIQ, _sampleRate);
                    _hookManager.SetProcessorSampleRate(ProcessorType.DecimatedAndFilteredIQ, _sampleRate / (1 << _baseBandDecimationStageCount));
                    _hookManager.SetProcessorSampleRate(ProcessorType.DemodulatorOutput, _sampleRate / (1 << _baseBandDecimationStageCount));
                    _hookManager.SetProcessorSampleRate(ProcessorType.FilteredAudioOutput, _sampleRate / (1 << _decimationStageCount));
                }
                _needNewFilters = true;
            }
            if (_needNewFilters)
            {
                _needNewFilters = false;
                InitFilters();
            }
            var baseBandSampleRate = _sampleRate / (1 << _baseBandDecimationStageCount);

            _usbDetector.SampleRate      = baseBandSampleRate;
            _lsbDetector.SampleRate      = baseBandSampleRate;
            _cwDetector.SampleRate       = baseBandSampleRate;
            _fmDetector.SampleRate       = baseBandSampleRate;
            _fmDetector.SquelchThreshold = _squelchThreshold;
            _amDetector.SquelchThreshold = _squelchThreshold;
            _stereoDecoder.Configure(_fmDetector.SampleRate, _audioDecimationStageCount);
            _rdsDecoder.SampleRate   = _fmDetector.SampleRate;
            _stereoDecoder.ForceMono = !_fmStereo;
            switch (_actualDetectorType)
            {
            case DetectorType.USB:
                _usbDetector.BfoFrequency = -_bandwidth / 2;
                _downConverter.Frequency -= _usbDetector.BfoFrequency;
                break;

            case DetectorType.LSB:
                _lsbDetector.BfoFrequency = -_bandwidth / 2;
                _downConverter.Frequency += _lsbDetector.BfoFrequency;
                break;

            case DetectorType.CW:
                _cwDetector.BfoFrequency = _cwToneShift;
                break;

            case DetectorType.NFM:
                _fmDetector.Mode = FmMode.Narrow;
                break;

            case DetectorType.WFM:
                _fmDetector.Mode = FmMode.Wide;
                break;
            }

            _agc.SampleRate = _sampleRate / (1 << _decimationStageCount);
            _agc.Decay      = _agcDecay;
            _agc.Slope      = _agcSlope;
            _agc.Threshold  = _agcThreshold;
            _agc.UseHang    = _agcUseHang;

            _decimationModeHasChanged = false;
        }
Exemplo n.º 8
0
Arquivo: Vfo.cs Projeto: zloiia/sdrsrc
 private void Configure()
 {
     this._actualDetectorType = this._detectorType;
       bool flag = this._sampleRate >= this._minThreadedSampleRate;
       if (this._downConverter == null || flag && this._downConverter.PhaseCount > 1)
     this._downConverter = new DownConverter(flag ? Environment.ProcessorCount : 1);
       this._downConverter.SampleRate = this._sampleRate;
       this._downConverter.Frequency = (double) this._frequency;
       if (this._needNewDecimators || this._baseBandDecimator == null)
       {
     this._needNewDecimators = false;
     if (this._actualDetectorType == DetectorType.WFM)
     {
       double num = this._sampleRate / (double) (1 << this._decimationStageCount);
       this._audioDecimationStageCount = 0;
       while (num * (double) (1 << this._audioDecimationStageCount) < 200000.0 && this._audioDecimationStageCount < this._decimationStageCount)
     ++this._audioDecimationStageCount;
       this._baseBandDecimationStageCount = this._decimationStageCount - this._audioDecimationStageCount;
     }
     else
     {
       this._baseBandDecimationStageCount = this._decimationStageCount;
       this._audioDecimationStageCount = 0;
     }
     this._baseBandDecimator = new IQDecimator(this._baseBandDecimationStageCount, this._useHighDynamicRangeDecimation, this._actualDetectorType == DetectorType.WFM ? this._wideBandDecimationQuality : this._narrowBandDecimationQuality, Environment.ProcessorCount > 1);
     this.ConfigureHookSampleRates();
     this._needNewFilters = true;
       }
       if (this._needNewFilters)
       {
     this._needNewFilters = false;
     this.InitFilters();
       }
       double num1 = this._sampleRate / (double) (1 << this._baseBandDecimationStageCount);
       this._carrierLocker.SampleRate = num1;
       this._usbDetector.SampleRate = num1;
       this._lsbDetector.SampleRate = num1;
       this._cwDetector.SampleRate = num1;
       this._fmDetector.SampleRate = num1;
       this._fmDetector.SquelchThreshold = this._squelchThreshold;
       this._amDetector.SquelchThreshold = this._squelchThreshold;
       this._stereoDecoder.Configure(this._fmDetector.SampleRate, this._audioDecimationStageCount);
       this._rdsDecoder.SampleRate = this._fmDetector.SampleRate;
       this._stereoDecoder.ForceMono = !this._fmStereo;
       switch (this._actualDetectorType)
       {
     case DetectorType.NFM:
       this._fmDetector.Mode = FmMode.Narrow;
       break;
     case DetectorType.WFM:
       this._fmDetector.Mode = FmMode.Wide;
       break;
     case DetectorType.LSB:
       this._lsbDetector.BfoFrequency = -this._bandwidth / 2;
       this._downConverter.Frequency += (double) this._lsbDetector.BfoFrequency;
       break;
     case DetectorType.USB:
       this._usbDetector.BfoFrequency = -this._bandwidth / 2;
       this._downConverter.Frequency -= (double) this._usbDetector.BfoFrequency;
       break;
     case DetectorType.CW:
       this._cwDetector.BfoFrequency = this._cwToneShift;
       break;
       }
       this._agc.SampleRate = this._sampleRate / (double) (1 << this._decimationStageCount);
       this._agc.Decay = this._agcDecay;
       this._agc.Slope = this._agcSlope;
       this._agc.Threshold = this._agcThreshold;
       this._agc.UseHang = this._agcUseHang;
       this._decimationModeHasChanged = false;
 }