示例#1
0
 public unsafe void Configure(double sampleRate, int decimationStageCount)
 {
     this._audioDecimationRatio = 1 << decimationStageCount;
     if (this._sampleRate != sampleRate)
     {
         this._sampleRate        = sampleRate;
         this._pilotFilterBuffer = UnsafeBuffer.Create(sizeof(IirFilter));
         this._pilotFilter       = (IirFilter *)(void *)this._pilotFilterBuffer;
         this._pilotFilter->Init(IirFilterType.BandPass, 19000.0, this._sampleRate, 500.0);
         this._pll->SampleRate       = (float)this._sampleRate;
         this._pll->DefaultFrequency = 19000f;
         this._pll->Range            = 20f;
         this._pll->Bandwidth        = 10f;
         this._pll->Zeta             = 0.707f;
         this._pll->PhaseAdjM        = StereoDecoder._pllPhaseAdjM;
         this._pll->PhaseAdjB        = StereoDecoder._pllPhaseAdjB;
         this._pll->LockTime         = 0.5f;
         this._pll->LockThreshold    = 1f;
         double    num    = sampleRate / (double)this._audioDecimationRatio;
         Complex[] kernel = FilterBuilder.MakeComplexKernel(num, 250, Math.Min(0.9 * num, 30000.0), 0.0, WindowType.BlackmanHarris4);
         this._channelAFilter  = new ComplexFilter(kernel);
         this._channelBFilter  = new ComplexFilter(kernel);
         this._deemphasisAlpha = (float)(1.0 - Math.Exp(-1.0 / (num * (double)StereoDecoder._deemphasisTime)));
         this._deemphasisAvgL  = 0f;
         this._deemphasisAvgR  = 0f;
     }
     if (this._channelADecimator != null && this._channelBDecimator != null && this._audioDecimationRatio == this._channelADecimator.DecimationRatio)
     {
         return;
     }
     this._channelADecimator = new FloatDecimator(this._audioDecimationRatio);
     this._channelBDecimator = new FloatDecimator(this._audioDecimationRatio);
 }
示例#2
0
 public unsafe void Process(Complex* buffer, int length)
 {
     if (!this._spectrumAnalyzer.Visible)
     return;
       if (IFProcessor._displayBeforeFilter && this._iqStream.Length < length * 4)
     this._iqStream.Write(buffer, length);
       if (this._enableFilter)
       {
     if (this._complexFilter == null)
       this._complexFilter = new ComplexFilter(FilterBuilder.MakeComplexKernel(this._sampleRate, 510, (double) this._filterbandwidth, (double) this._filterOffset, WindowType.BlackmanHarris7));
     else if (this._updateFilter)
     {
       this._complexFilter.SetKernel(FilterBuilder.MakeComplexKernel(this._sampleRate, 510, (double) this._filterbandwidth, (double) this._filterOffset, WindowType.BlackmanHarris7));
       this._updateFilter = false;
     }
     this._complexFilter.Process(buffer, length);
       }
       if (IFProcessor._displayBeforeFilter || this._iqStream.Length >= length * 4)
     return;
       this._iqStream.Write(buffer, length);
 }
        public void Process(Complex* buffer, int length)
        {
            if (!_spectrumAnalyzer.Visible)
            {
                return;
            }

            if (_displayBeforeFilter)
            {
                if (_iqStream.Length < length * 4)
                {
                    _iqStream.Write(buffer, length);
                }
            }

            if (_enableFilter)
            {
                if (_complexFilter == null)
                {
                    var kernel = FilterBuilder.MakeComplexKernel(_sampleRate, DefaultFilterOrder, _filterbandwidth, _filterOffset, WindowType.BlackmanHarris7);
                    _complexFilter = new ComplexFilter(kernel);
                }
                else if (_updateFilter)
                {
                    var kernel = FilterBuilder.MakeComplexKernel(_sampleRate, DefaultFilterOrder, _filterbandwidth, _filterOffset, WindowType.BlackmanHarris7);
                    _complexFilter.SetKernel(kernel);
                    _updateFilter = false;
                }

                _complexFilter.Process(buffer, length);
            }

            if (!_displayBeforeFilter)
            {
                if (_iqStream.Length < length * 4)
                {
                    _iqStream.Write(buffer, length);
                }
            }
        }
示例#4
0
        private void UpdateFilters(bool refresh)
        {
            int num  = 0;
            int num2 = 15000;
            int num3 = 0;

            switch (this._actualDetectorType)
            {
            case DetectorType.WFM:
            case DetectorType.AM:
                num  = 20;
                num2 = Math.Min(this._bandwidth / 2, 15000);
                break;

            case DetectorType.CW:
                num  = Math.Abs(this._cwToneShift) - this._bandwidth / 2;
                num2 = Math.Abs(this._cwToneShift) + this._bandwidth / 2;
                break;

            case DetectorType.USB:
                num  = (this._lockCarrier ? 20 : 100);
                num2 = this._bandwidth;
                num3 = this._bandwidth / 2;
                break;

            case DetectorType.LSB:
                num  = (this._lockCarrier ? 20 : 100);
                num2 = this._bandwidth;
                num3 = -this._bandwidth / 2;
                break;

            case DetectorType.DSB:
                num  = 20;
                num2 = this._bandwidth / 2;
                break;

            case DetectorType.NFM:
                num  = 300;
                num2 = Math.Min(this._bandwidth / 2, 3800);
                break;
            }
            Complex[] array = FilterBuilder.MakeComplexKernel(this._sampleRate / (double)(1 << this._baseBandDecimationStageCount), this._filterOrder, (double)this._bandwidth, (double)num3, this._windowType);
            if ((this._iqFilter == null | refresh) || this._iqFilter.KernelSize != array.Length)
            {
                this._iqFilter = new ComplexFilter(array);
            }
            else
            {
                this._iqFilter.SetKernel(array);
            }
            double num4 = this._sampleRate / (double)(1 << this._decimationStageCount);

            if (refresh)
            {
                if (this._actualDetectorType == DetectorType.CW)
                {
                    this._audioIIR.Init(IirFilterType.BandPass, (double)Math.Abs(this._cwToneShift), num4, 3.0);
                }
                else if (this._actualDetectorType == DetectorType.WFM)
                {
                    double sampleRate = this._sampleRate / (double)(1 << this._baseBandDecimationStageCount);
                    this._audioIIR.Init(IirFilterType.HighPass, (double)num, sampleRate, 1.0);
                }
                else
                {
                    this._audioIIR.Init(IirFilterType.HighPass, (double)num, num4, 1.0);
                }
            }
            Complex[] array2 = FilterBuilder.MakeComplexKernel(num4, this._filterOrder, (double)(num2 - num), (double)(num2 + num) * 0.5, this._windowType);
            if ((this._audioFIR == null | refresh) || this._audioFIR.KernelSize != array2.Length)
            {
                this._audioFIR = new ComplexFilter(array2);
            }
            else
            {
                this._audioFIR.SetKernel(array2);
            }
            this._deemphasisAlpha = (float)(1.0 - Math.Exp(-1.0 / (num4 * 0.00014999999257270247)));
            this._deemphasisState = 0f;
        }