public unsafe void Configure(double sampleRate, int decimationStageCount) { int num = (int)Math.Pow(2.0, (double)decimationStageCount); if (this._sampleRate != sampleRate || this._audioDecimationFactor != num) { 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); 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 num2 = sampleRate / (double)num; float[] coefficients = FilterBuilder.MakeBandPassKernel(num2, 250, 20.0, 16000.0, WindowType.BlackmanHarris4); this._channelAFilter = new FirFilter(coefficients, 1); this._channelBFilter = new FirFilter(coefficients, 1); this._deemphasisAlpha = (float)(1.0 - Math.Exp(-1.0 / (num2 * (double)StereoDecoder._deemphasisTime))); this._deemphasisAvgL = 0f; this._deemphasisAvgR = 0f; } if (this._channelADecimator != null && this._channelBDecimator != null && this._audioDecimationFactor == num) { return; } this._channelADecimator = new FloatDecimator(decimationStageCount); this._channelBDecimator = new FloatDecimator(decimationStageCount); this._audioDecimationFactor = num; }
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); }
public void Dispose() { if (this._dec != IntPtr.Zero) { FloatDecimator.float_decimator_destroy(this._dec); this._dec = IntPtr.Zero; } }
public IQDecimator(int stageCount, double samplerate, bool useFastFilters, bool isMultithreaded) { _isMultithreaded = isMultithreaded; int childThreads; if (_isMultithreaded) { childThreads = Environment.ProcessorCount / 2; } else { childThreads = 1; } var filterType = useFastFilters ? DecimationFilterType.Fast : DecimationFilterType.Baseband; _rDecimator = new FloatDecimator(stageCount, samplerate, filterType, childThreads); _iDecimator = new FloatDecimator(stageCount, samplerate, filterType, childThreads); }
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 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 unsafe int Process(float *buffer, int length) { return(FloatDecimator.float_decimator_process(this._dec, buffer, length)); }
public FloatDecimator(int decimationRatio) { this._decimationRatio = decimationRatio; this._dec = FloatDecimator.float_decimator_create(decimationRatio); }
public IQDecimator(int stageCount, bool highDynamicRange = true, float quality = 1f, bool isMultithreaded = false) { this._isMultithreaded = isMultithreaded; this._rDecimator = new FloatDecimator(stageCount, highDynamicRange, quality); this._iDecimator = new FloatDecimator(stageCount, highDynamicRange, quality); }
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); }