Beispiel #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);
 }
Beispiel #2
0
        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;
        }
Beispiel #3
0
 public unsafe RdsDecoder()
 {
     this._pllBuffer        = UnsafeBuffer.Create(sizeof(Pll));
     this._pll              = (Pll *)(void *)this._pllBuffer;
     this._oscBuffer        = UnsafeBuffer.Create(sizeof(Oscillator));
     this._osc              = (Oscillator *)(void *)this._oscBuffer;
     this._syncFilterBuffer = UnsafeBuffer.Create(sizeof(IirFilter));
     this._syncFilter       = (IirFilter *)(void *)this._syncFilterBuffer;
 }
Beispiel #4
0
 public unsafe RdsDecoder()
 {
     this._pllBuffer                  = UnsafeBuffer.Create(sizeof(Pll));
     this._pll                        = (Pll *)(void *)this._pllBuffer;
     this._syncFilterBuffer           = UnsafeBuffer.Create(sizeof(IirFilter));
     this._syncFilter                 = (IirFilter *)(void *)this._syncFilterBuffer;
     this._bitDecoder                 = new RdsDetectorBank();
     this._bitDecoder.FrameAvailable += this.FrameAvailableHandler;
 }
Beispiel #5
0
 public unsafe RdsDecoder()
 {
     this._pllBuffer = UnsafeBuffer.Create(sizeof (Pll));
       this._pll = (Pll*) (void*) this._pllBuffer;
       this._oscBuffer = UnsafeBuffer.Create(sizeof (Oscillator));
       this._osc = (Oscillator*) (void*) this._oscBuffer;
       this._syncFilterBuffer = UnsafeBuffer.Create(sizeof (IirFilter));
       this._syncFilter = (IirFilter*) (void*) this._syncFilterBuffer;
       this._bitDecoder = new RdsDetectorBank();
       this._bitDecoder.FrameAvailable += new RdsFrameAvailableDelegate(this.FrameAvailableHandler);
 }
Beispiel #6
0
        public RdsDecoder()
        {
            _pllBuffer = UnsafeBuffer.Create(sizeof(Pll));
            _pll = (Pll*) _pllBuffer;

            _oscBuffer = UnsafeBuffer.Create(sizeof(Oscillator));
            _osc = (Oscillator*) _oscBuffer;

            _syncFilterBuffer = UnsafeBuffer.Create(sizeof(IirFilter));
            _syncFilter = (IirFilter*) _syncFilterBuffer;
        }
Beispiel #7
0
        public RdsDecoder()
        {
            _pllBuffer = UnsafeBuffer.Create(sizeof(Pll));
            _pll       = (Pll *)_pllBuffer;

            _oscBuffer = UnsafeBuffer.Create(sizeof(Oscillator));
            _osc       = (Oscillator *)_oscBuffer;

            _syncFilterBuffer = UnsafeBuffer.Create(sizeof(IirFilter));
            _syncFilter       = (IirFilter *)_syncFilterBuffer;
        }
        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);
            }
        }
Beispiel #9
0
        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);
            }
        }
Beispiel #10
0
 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);
 }