예제 #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);
        }
예제 #2
0
 public void Dispose()
 {
     if (this._fir != IntPtr.Zero)
     {
         IQFirFilter.complex_fir_destroy(this._fir);
         this._fir = IntPtr.Zero;
     }
     GC.SuppressFinalize(this);
 }
예제 #3
0
 public unsafe IQFirFilter(float[] coefficients, int decimationRatio = 1)
 {
     if (decimationRatio <= 0)
     {
         throw new ArgumentException("The decimation factor must be greater than zero", "decimationRatio");
     }
     this._decimationRatio = decimationRatio;
     this._length          = coefficients.Length;
     fixed(float *kernel = coefficients)
     {
         this._fir = IQFirFilter.complex_fir_create(kernel, this._length, decimationRatio);
     }
 }
예제 #4
0
        private void InitFilters()
        {
            int cutoff1 = 0;
            int cutoff2 = 10000;
            var iqBW    = _bandwidth / 2;
            int iqOrder = _actualDetectorType == DetectorType.WFM ? 60 : _filterOrder;

            var coeffs = FilterBuilder.MakeLowPassKernel(_sampleRate / (1 << _baseBandDecimationStageCount), iqOrder, iqBW, _windowType);

            if (_iqFilter == null || _decimationModeHasChanged)
            {
                _iqFilter = new IQFirFilter(coeffs, _actualDetectorType == DetectorType.WFM, 1);
            }
            else
            {
                _iqFilter.SetCoefficients(coeffs);
            }

            switch (_actualDetectorType)
            {
            case DetectorType.AM:
                cutoff1 = MinBCAudioFrequency;
                cutoff2 = Math.Min(_bandwidth / 2, MaxBCAudioFrequency);
                break;

            case DetectorType.CW:
                cutoff1 = Math.Abs(_cwToneShift) - _bandwidth / 2;
                cutoff2 = Math.Abs(_cwToneShift) + _bandwidth / 2;
                break;

            case DetectorType.USB:
            case DetectorType.LSB:
                cutoff1 = MinSSBAudioFrequency;
                cutoff2 = _bandwidth;
                break;

            case DetectorType.DSB:
                cutoff1 = MinSSBAudioFrequency;
                cutoff2 = _bandwidth / 2;
                break;

            case DetectorType.NFM:
                cutoff1 = MinNFMAudioFrequency;
                cutoff2 = _bandwidth / 2;
                break;
            }

            coeffs = FilterBuilder.MakeBandPassKernel(_sampleRate / (1 << (_baseBandDecimationStageCount + _audioDecimationStageCount)), _filterOrder, cutoff1, cutoff2, _windowType);
            _audioFilter.SetCoefficients(coeffs);
        }
예제 #5
0
파일: Vfo.cs 프로젝트: taozhengbo/sdrsharp
        private void InitFilters()
        {
            int cutoff1 = 0;
            int cutoff2 = 10000;
            var iqBW = _bandwidth / 2;
            int iqOrder = _actualDetectorType == DetectorType.WFM ? 60 : _filterOrder;
            
            var coeffs = FilterBuilder.MakeLowPassKernel(_sampleRate / Math.Pow(2.0, _baseBandDecimationStageCount), iqOrder, iqBW, _windowType);

            if (_iqFilter == null || _decimationModeHasChanged)
            {
                _iqFilter = new IQFirFilter(coeffs, _actualDetectorType == DetectorType.WFM, 1);
            }
            else
            {
                _iqFilter.SetCoefficients(coeffs);
            }

            switch (_actualDetectorType)
            {
                case DetectorType.AM:
                    cutoff1 = MinBCAudioFrequency;
                    cutoff2 = Math.Min(_bandwidth / 2, MaxBCAudioFrequency);
                    break;

                case DetectorType.CW:
                    cutoff1 = Math.Abs(_cwToneShift) - _bandwidth / 2;
                    cutoff2 = Math.Abs(_cwToneShift) + _bandwidth / 2;
                    break;

                case DetectorType.USB:
                case DetectorType.LSB:
                    cutoff1 = MinSSBAudioFrequency;
                    cutoff2 = _bandwidth;
                    break;

                case DetectorType.DSB:
                    cutoff1 = MinSSBAudioFrequency;
                    cutoff2 = _bandwidth / 2;
                    break;

                case DetectorType.NFM:
                    cutoff1 = MinNFMAudioFrequency;
                    cutoff2 = _bandwidth / 2;
                    break;
            }

            coeffs = FilterBuilder.MakeBandPassKernel(_sampleRate / Math.Pow(2.0, _baseBandDecimationStageCount + _audioDecimationStageCount), _filterOrder, cutoff1, cutoff2, _windowType);
            _audioFilter.SetCoefficients(coeffs);
        }
예제 #6
0
        private void initFilters()
        {
            int num         = this._bandwidth / 2;
            int filterOrder = (this._actualDetectorType == DetectorType.WFM) ? 60 : this._filterOrder;

            float[] coefficients = FilterBuilder.MakeLowPassKernel(this._sampleRate / Math.Pow(2.0, (double)this._baseBandDecimationStageCount), filterOrder, (double)num, this._windowType);
            if (this._realIqFilter == null)
            {
                this._realIqFilter = new IQFirFilter(coefficients, this._actualDetectorType == DetectorType.WFM, 1);
            }
            else
            {
                this._realIqFilter.SetCoefficients(coefficients);
            }
            if (this._cpxIqFilter == null)
            {
                this._cpxIqFilter = new CpxFirFilter(coefficients);
            }
            else
            {
                this._cpxIqFilter.SetCoefficients(coefficients);
            }
            this._envFilter.MakeCoefficients(this._sampleRate / Math.Pow(2.0, (double)this._envelopeDecimationStageCount), 6000, num, this._windowType, false);
            if (this._notch >= 0)
            {
                this._notchFilter[this._notch].MakeCoefficients(this._sampleRate / Math.Pow(2.0, (double)this._baseBandDecimationStageCount), this._notchFrequency, this._notchWidth, this._windowType, true);
                this._notch = -1;
            }
            int num2 = 0;
            int num3 = 10000;

            switch (this._actualDetectorType)
            {
            case DetectorType.AM:
            case DetectorType.SAM:
                num2 = 20;
                num3 = Math.Min(this._bandwidth / 2, 16000);
                break;

            case DetectorType.CW:
                num2 = this._cwToneShift - this._bandwidth / 2;
                num3 = this._cwToneShift + this._bandwidth / 2;
                break;

            case DetectorType.LSB:
            case DetectorType.USB:
                num2 = 400;
                num3 = this._bandwidth;
                break;

            case DetectorType.DSB:
                num2 = 400;
                num3 = this._bandwidth / 2;
                break;

            case DetectorType.NFM:
                num2 = 300;
                num3 = this._bandwidth / 2;
                break;
            }
            coefficients = FilterBuilder.MakeBandPassKernel(this._sampleRate / Math.Pow(2.0, (double)(this._baseBandDecimationStageCount + this._audioDecimationStageCount)), this._filterOrder, (double)num2, (double)num3, this._windowType);
            this._audioFilter.SetCoefficients(coefficients);
            this._rFilter.SetCoefficients(coefficients);
            this._lFilter.SetCoefficients(coefficients);
        }
예제 #7
0
 public unsafe int Process(Complex *buffer, int length)
 {
     return(IQFirFilter.complex_fir_process(this._fir, buffer, length));
 }
예제 #8
0
파일: Vfo.cs 프로젝트: zloiia/sdrsrc
 private void InitFilters()
 {
     int num1 = 0;
       int num2 = 10000;
       float[] coefficients = FilterBuilder.MakeLowPassKernel(this._sampleRate / (double) (1 << this._baseBandDecimationStageCount), this._actualDetectorType == DetectorType.WFM ? 60 : this._filterOrder, (double) (this._bandwidth / 2), this._windowType);
       if (this._iqFilter == null || this._decimationModeHasChanged)
     this._iqFilter = new IQFirFilter(coefficients, this._actualDetectorType == DetectorType.WFM, 1);
       else
     this._iqFilter.SetCoefficients(coefficients);
       switch (this._actualDetectorType)
       {
     case DetectorType.NFM:
       num1 = 300;
       num2 = Math.Min(this._bandwidth / 2, 3500);
       break;
     case DetectorType.WFM:
     case DetectorType.AM:
       num1 = 20;
       num2 = Math.Min(this._bandwidth / 2, 15500);
       break;
     case DetectorType.DSB:
       num1 = 20;
       num2 = this._bandwidth / 2;
       break;
     case DetectorType.LSB:
     case DetectorType.USB:
       num1 = 100;
       num2 = this._bandwidth;
       break;
     case DetectorType.CW:
       num1 = Math.Abs(this._cwToneShift) - this._bandwidth / 2;
       num2 = Math.Abs(this._cwToneShift) + this._bandwidth / 2;
       break;
       }
       double sampleRate1 = this._sampleRate / (double) (1 << this._baseBandDecimationStageCount + this._audioDecimationStageCount);
       if (this._actualDetectorType == DetectorType.CW)
     this._audioHP.Init(IirFilterType.BandPass, (double) Math.Abs(this._cwToneShift), sampleRate1, 3.0);
       else if (this._actualDetectorType == DetectorType.WFM)
       {
     double sampleRate2 = this._sampleRate / (double) (1 << this._baseBandDecimationStageCount);
     this._audioHP.Init(IirFilterType.HighPass, (double) num1, sampleRate2, 1.5);
       }
       else
     this._audioHP.Init(IirFilterType.HighPass, (double) num1 * 1.5, sampleRate1, 1.5);
       this._audioLP.SetCoefficients(FilterBuilder.MakeBandPassKernel(sampleRate1, this._filterOrder, (double) num1, (double) num2, this._windowType));
       this._deemphasisAlpha = (float) (1.0 - Math.Exp(-1.0 / (sampleRate1 * 0.000149999999621286)));
       this._deemphasisState = 0.0f;
 }