Example #1
0
        private unsafe void Configure()
        {
            this._osc->SampleRate = this._sampleRate;
            this._osc->Frequency  = 57000.0;
            int i;

            for (i = 0; this._sampleRate >= 20000.0 * Math.Pow(2.0, (double)i); i++)
            {
            }
            this._decimator              = new IQDecimator(i, this._sampleRate, true, false);
            this._decimationFactor       = (int)Math.Pow(2.0, (double)i);
            this._demodulationSampleRate = this._sampleRate / (double)this._decimationFactor;
            float[] coefficients = FilterBuilder.MakeLowPassKernel(this._demodulationSampleRate, 200, 2500.0, WindowType.BlackmanHarris4);
            this._baseBandFilter.SetCoefficients(coefficients);
            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.SetCoefficients(coefficients);
            this._syncFilter->Init(IirFilterType.BandPass, 1187.5, this._demodulationSampleRate, 500);
        }
Example #2
0
        private void Configure()
        {
            _osc->SampleRate = _sampleRate;
            _osc->Frequency  = PllDefaultFrequency;

            var decimationStageCount = 0;

            while (_sampleRate >= 20000 * Math.Pow(2.0, decimationStageCount))
            {
                decimationStageCount++;
            }

            _decimator              = new IQDecimator(decimationStageCount, _sampleRate, true, false);
            _decimationFactor       = (int)Math.Pow(2.0, decimationStageCount);
            _demodulationSampleRate = _sampleRate / _decimationFactor;

            var coefficients = FilterBuilder.MakeLowPassKernel(_demodulationSampleRate, 200, 2500, WindowType.BlackmanHarris4);

            _baseBandFilter.SetCoefficients(coefficients);

            _pll->SampleRate       = (float)_demodulationSampleRate;
            _pll->DefaultFrequency = 0;
            _pll->Range            = PllRange;
            _pll->Bandwidth        = PllBandwith;
            _pll->Zeta             = PllZeta;
            _pll->LockTime         = PllLockTime;
            _pll->LockThreshold    = PllLockThreshold;

            var matchedFilterLength = (int)(_demodulationSampleRate / RdsBitRate) | 1;

            coefficients = FilterBuilder.MakeSin(_demodulationSampleRate, RdsBitRate, matchedFilterLength);
            _matchedFilter.SetCoefficients(coefficients);

            _syncFilter->Init(IirFilterType.BandPass, RdsBitRate, _demodulationSampleRate, 500);
        }
Example #3
0
 public unsafe AirSpyDevice()
 {
     if (NativeMethods.airspy_open(out this._dev) != airspy_error.AIRSPY_SUCCESS)
     throw new ApplicationException("Cannot open AirSpy device");
       uint len;
       int num1 = (int) NativeMethods.airspy_get_samplerates(this._dev, &len, 0U);
       this._supportedSampleRates = new uint[(IntPtr) len];
       fixed (uint* buffer = this._supportedSampleRates)
       {
     int num2 = (int) NativeMethods.airspy_get_samplerates(this._dev, buffer, len);
       }
       int num3 = (int) NativeMethods.airspy_set_samplerate(this._dev, this._sampleRateIndex);
       int num4 = (int) NativeMethods.airspy_set_lna_agc(this._dev, (byte) 0);
       int num5 = (int) NativeMethods.airspy_set_mixer_agc(this._dev, (byte) 0);
       int num6 = (int) NativeMethods.airspy_set_lna_gain(this._dev, (byte) 0);
       int num7 = (int) NativeMethods.airspy_set_mixer_gain(this._dev, (byte) 0);
       int num8 = (int) NativeMethods.airspy_set_vga_gain(this._dev, (byte) 0);
       int num9 = (int) NativeMethods.airspy_set_rf_bias(this._dev, false);
       int num10 = (int) NativeMethods.airspy_set_packing(this._dev, this._usePacking ? (byte) 1 : (byte) 0);
       this._decimator = new IQDecimator(0, true, 1f, false);
       this._alpha = (float) (1.0 - Math.Exp(-1.0 / ((double) (this._supportedSampleRates[(IntPtr) this._sampleRateIndex] >> this.DecimationStages) * 0.0500000007450581)));
       this._gcHandle = GCHandle.Alloc((object) this);
 }
Example #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;
        }
Example #5
0
 private unsafe void Configure()
 {
     this._osc->SampleRate = this._sampleRate;
       this._osc->Frequency = 57000.0;
       int stageCount = 0;
       while (this._sampleRate >= 20000.0 * Math.Pow(2.0, (double) stageCount))
     ++stageCount;
       this._decimator = new IQDecimator(stageCount, false, 0.5f, false);
       this._decimationFactor = (int) Math.Pow(2.0, (double) stageCount);
       this._demodulationSampleRate = this._sampleRate / (double) this._decimationFactor;
       this._baseBandFilter.SetCoefficients(FilterBuilder.MakeLowPassKernel(this._demodulationSampleRate, 200, 2500.0, WindowType.BlackmanHarris4));
       this._pll->SampleRate = (float) this._demodulationSampleRate;
       this._pll->DefaultFrequency = 0.0f;
       this._pll->Range = 12f;
       this._pll->Bandwidth = 1f;
       this._pll->Zeta = 0.707f;
       this._pll->LockTime = 0.5f;
       this._pll->LockThreshold = 3.2f;
       this._matchedFilter.SetCoefficients(FilterBuilder.MakeSin(this._demodulationSampleRate, 1187.5, (int) (this._demodulationSampleRate / 1187.5) | 1));
       this._syncFilter->Init(IirFilterType.BandPass, 1187.5, this._demodulationSampleRate, 500.0);
 }
Example #6
0
        private void Configure()
        {
            _osc->SampleRate = _sampleRate;
            _osc->Frequency = PllDefaultFrequency;

            var decimationStageCount = 0;
            while (_sampleRate >= 20000 * Math.Pow(2.0, decimationStageCount))
            {
                decimationStageCount++;
            }

            _decimator = new IQDecimator(decimationStageCount, _sampleRate, true, false);
            _decimationFactor = (int) Math.Pow(2.0, decimationStageCount);
            _demodulationSampleRate = _sampleRate / _decimationFactor;

            var coefficients = FilterBuilder.MakeLowPassKernel(_demodulationSampleRate, 200, 2500, WindowType.BlackmanHarris4);
            _baseBandFilter.SetCoefficients(coefficients);
            
            _pll->SampleRate = (float) _demodulationSampleRate;
            _pll->DefaultFrequency = 0;
            _pll->Range = PllRange;
            _pll->Bandwidth = PllBandwith;
            _pll->Zeta = PllZeta;
            _pll->LockTime = PllLockTime;
            _pll->LockThreshold = PllLockThreshold;

            var matchedFilterLength = (int) (_demodulationSampleRate / RdsBitRate) | 1;
            coefficients = FilterBuilder.MakeSin(_demodulationSampleRate, RdsBitRate, matchedFilterLength);
            _matchedFilter.SetCoefficients(coefficients);

            _syncFilter->Init(IirFilterType.BandPass, RdsBitRate, _demodulationSampleRate, 500);
        }
Example #7
0
        private void configure()
        {
            this._actualDetectorType        = this._detectorType;
            this._downConverter.SampleRate  = this._sampleRate;
            this._downConverter.Frequency   = (double)this._frequency;
            this._downConverter2.SampleRate = this._sampleRate;
            this._downConverter2.Frequency  = (double)(this._frequency - 6000);
            if (this._needNewDecimators)
            {
                this.setDecimationCount();
                this._baseBandDecimator = new IQDecimator(this._baseBandDecimationStageCount, this._sampleRate, false, Utils.ProcessorCount > 1);
                this._envelopeDecimator = new IQDecimator(this._envelopeDecimationStageCount, this._sampleRate, false, Utils.ProcessorCount > 1);
                if (this._hookManager != null)
                {
                    this._hookManager.SetProcessorSampleRate(ProcessorType.RawIQ, this._sampleRate);
                    this._hookManager.SetProcessorSampleRate(ProcessorType.FrequencyTranslatedIQ, this._sampleRate);
                    this._hookManager.SetProcessorSampleRate(ProcessorType.DecimatedAndFilteredIQ, this._sampleRate / (double)(1 << this._baseBandDecimationStageCount));
                    this._hookManager.SetProcessorSampleRate(ProcessorType.DemodulatorOutput, this._sampleRate / (double)(1 << this._baseBandDecimationStageCount));
                    this._hookManager.SetProcessorSampleRate(ProcessorType.FilteredAudioOutput, this._sampleRate / (double)(1 << this._decimationStageCount));
                }
                this._needNewFilters = true;
            }
            if (this._needNewFilters)
            {
                this.initFilters();
                this._samDetector.Range = (float)(this._bandwidth / 2);
            }
            if (this._needNewDecimators)
            {
                double num = this._sampleRate / Math.Pow(2.0, (double)this._baseBandDecimationStageCount);
                this._usbDetector.SampleRate   = num;
                this._lsbDetector.SampleRate   = num;
                this._cwDetector.SampleRate    = num;
                this._fmDetector.SampleRate    = num;
                this._pmDetector.SampleRate    = num;
                this._samDetector.SampleRate   = (float)num;
                this._samDetector.BandWidth    = 500f;
                this._samDetector.LockTime     = 2f;
                this._samDetector.LockTreshold = 3f;
                this._stereoDecoder.Configure(this._fmDetector.SampleRate, this._audioDecimationStageCount);
                this._rdsDecoder.SampleRate = this._fmDetector.SampleRate;
            }
            this._fmDetector.SquelchThreshold = this._squelchThreshold;
            this._amDetector.SquelchThreshold = this._squelchThreshold;
            this._stereoDecoder.ForceMono     = !this._stereo;
            switch (this._actualDetectorType)
            {
            case DetectorType.AM:
            case DetectorType.DSB:
            case DetectorType.SAM:
                this._downConverter.Frequency += (double)this._frequencyOffset;
                break;

            case DetectorType.USB:
                this._usbDetector.BfoFrequency = -this._bandwidth / 2;
                this._downConverter.Frequency -= (double)this._usbDetector.BfoFrequency;
                break;

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

            case DetectorType.CW:
                this._cwDetector.BfoFrequency  = this._cwToneShift;
                this._downConverter.Frequency += (double)this._frequencyOffset;
                break;

            case DetectorType.NFM:
                this._fmDetector.Mode          = FmMode.Narrow;
                this._downConverter.Frequency += (double)this._frequencyOffset;
                break;

            case DetectorType.WFM:
                this._fmDetector.Mode          = FmMode.Wide;
                this._downConverter.Frequency += (double)this._frequencyOffset;
                break;
            }
            this._agc.SampleRate           = this._sampleRate / Math.Pow(2.0, (double)this._decimationStageCount);
            this._agc.Decay                = this._agcDecay;
            this._agc.Slope                = this._agcSlope;
            this._agc.Threshold            = this._agcThreshold;
            this._agc.UseHang              = this._agcUseHang;
            this._agcX.SampleRate          = this._sampleRate / Math.Pow(2.0, (double)this._decimationStageCount);
            this._agcX.Decay               = this._agcDecay;
            this._agcX.Slope               = this._agcSlope;
            this._agcX.Threshold           = this._agcThreshold;
            this._agcX.UseHang             = this._agcUseHang;
            this._agcY.SampleRate          = this._sampleRate / Math.Pow(2.0, (double)this._decimationStageCount);
            this._agcY.Decay               = this._agcDecay;
            this._agcY.Slope               = this._agcSlope;
            this._agcY.Threshold           = this._agcThreshold;
            this._agcY.UseHang             = this._agcUseHang;
            this._agcEnv.SampleRate        = this._sampleRate / Math.Pow(2.0, (double)this._decimationStageCount);
            this._agcEnv.Decay             = this._agcDecay;
            this._agcEnv.Slope             = this._agcSlope;
            this._agcEnv.Threshold         = this._agcThreshold;
            this._agcEnv.UseHang           = this._agcUseHang;
            this._decimationModeHasChanged = false;
            this._needNewDecimators        = false;
            this._needNewFilters           = false;
        }
        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;
        }
Example #9
0
File: Vfo.cs Project: 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;
 }