Beispiel #1
0
 public void Dispose()
 {
     if (this._nco != IntPtr.Zero)
     {
         FrequencyTranslator.nco_destroy(this._nco);
         this._nco = IntPtr.Zero;
     }
 }
Beispiel #2
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;
            }
        }
Beispiel #3
0
 public unsafe void Process(Complex *buffer, int length)
 {
     FrequencyTranslator.nco_process(this._nco, buffer, length);
 }
Beispiel #4
0
 public FrequencyTranslator(double sampleRate)
 {
     this._sampleRate = sampleRate;
     this._nco        = FrequencyTranslator.nco_create(sampleRate);
 }