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); }
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); }