public IQFirFilter(float[] coefficients, bool isMultiThteaded, int decimationFactor) { this._rFilter = new FirFilter(coefficients, decimationFactor); this._iFilter = new FirFilter(coefficients, decimationFactor); this._isMultiThteaded = isMultiThteaded; if (!this._isMultiThteaded) return; this._event = new SharpEvent(false); }
public IQFirFilter(float[] coefficients, bool isMultiThteaded, int decimationFactor) { _rFilter = new FirFilter(coefficients, decimationFactor); _iFilter = new FirFilter(coefficients, decimationFactor); _isMultiThteaded = isMultiThteaded; if (_isMultiThteaded) { _event = new SharpEvent(false); } }
public void Configure(double sampleRate, int decimationStageCount) { _audioDecimationFactor = (int) Math.Pow(2.0, decimationStageCount); if (_sampleRate != sampleRate) { _sampleRate = sampleRate; _pilotFilterBuffer = UnsafeBuffer.Create(sizeof(IirFilter)); _pilotFilter = (IirFilter*) _pilotFilterBuffer; _pilotFilter->Init(IirFilterType.BandPass, DefaultPilotFrequency, _sampleRate, 500); _pll->SampleRate = (float) _sampleRate; _pll->DefaultFrequency = DefaultPilotFrequency; _pll->Range = PllRange; _pll->Bandwidth = PllBandwith; _pll->Zeta = PllZeta; _pll->PhaseAdjM = _pllPhaseAdjM; _pll->PhaseAdjB = _pllPhaseAdjB; _pll->LockTime = PllLockTime; _pll->LockThreshold = PllThreshold; var outputSampleRate = sampleRate / _audioDecimationFactor; var coefficients = FilterBuilder.MakeBandPassKernel(outputSampleRate, 250, Vfo.MinBCAudioFrequency, Vfo.MaxBCAudioFrequency, WindowType.BlackmanHarris4); _channelAFilter = new FirFilter(coefficients, 1); _channelBFilter = new FirFilter(coefficients, 1); _deemphasisAlpha = (float) (1.0 - Math.Exp(-1.0 / (outputSampleRate * _deemphasisTime))); _deemphasisAvgL = 0; _deemphasisAvgR = 0; } if (_channelADecimator == null || _channelBDecimator == null || decimationStageCount != _channelADecimator.StageCount) { _channelADecimator = new FloatDecimator(decimationStageCount); _channelBDecimator = new FloatDecimator(decimationStageCount); } }
public FloatDecimator(int stageCount, double samplerate, DecimationFilterType filterType, int threadCount) { _stageCount = stageCount; _threadCount = threadCount; _cicCount = 0; var firCount = 0; switch (filterType) { case DecimationFilterType.Fast: _cicCount = stageCount; break; case DecimationFilterType.Audio: firCount = stageCount; break; case DecimationFilterType.Baseband: while (_cicCount < stageCount && samplerate >= _minimumCICSampleRate) { _cicCount++; samplerate /= 2; } firCount = stageCount - _cicCount; break; } _cicDecimatorsBuffer = UnsafeBuffer.Create(_threadCount * _cicCount, sizeof(CicDecimator)); _cicDecimators = (CicDecimator*)_cicDecimatorsBuffer; for (var i = 0; i < _threadCount; i++) { for (var j = 0; j < _cicCount; j++) { _cicDecimators[i * _cicCount + j] = new CicDecimator(); } } _firFilters = new FirFilter[firCount]; for (var i = 0; i < firCount; i++) { _firFilters[i] = new FirFilter(DecimationKernels.Kernel51, 2); } }
public unsafe int Process(float *buffer, int length) { return(FirFilter.float_fir_process(this._fir, buffer, length)); }
public unsafe void Configure(double sampleRate, int decimationStageCount) { this._audioDecimationFactor = (int) Math.Pow(2.0, (double) 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 sampleRate1 = sampleRate / (double) this._audioDecimationFactor; float[] coefficients = FilterBuilder.MakeBandPassKernel(sampleRate1, 250, 20.0, 15500.0, WindowType.BlackmanHarris4); this._channelAFilter = new FirFilter(coefficients, 1); this._channelBFilter = new FirFilter(coefficients, 1); this._deemphasisAlpha = (float) (1.0 - Math.Exp(-1.0 / (sampleRate1 * (double) StereoDecoder._deemphasisTime))); this._deemphasisAvgL = 0.0f; this._deemphasisAvgR = 0.0f; } if (this._channelADecimator != null && this._channelBDecimator != null && decimationStageCount == this._channelADecimator.StageCount) return; this._channelADecimator = new FloatDecimator(decimationStageCount, false, 1f); this._channelBDecimator = new FloatDecimator(decimationStageCount, false, 1f); }