Example #1
0
 public MainForm()
 {
     this._hookManager = new HookManager();
       this._hookManager.RegisterStreamHook((object) this._iqBalancerProcessor, ProcessorType.RawIQ);
       this._streamControl = new StreamControl(this._hookManager);
       this._vfo = new Vfo(this._hookManager);
       this._sharpControlProxy = new SharpControlProxy(this);
       this.InitializeComponent();
       this.InitializeGUI();
 }
Example #2
0
        public unsafe int ProcessBuffer(Complex *iqBuffer, float *audioBuffer, int iqLen, float *xBuf, float *yBuf, float *envelopBuf)
        {
            if (this._needConfigure)
            {
                this.configure();
                this._needConfigure = false;
            }
            if (this._demodX == DemodType.Envelope || this._demodY == DemodType.Envelope || envelopBuf != null)
            {
                if (this._envBuf == null || this._envBuf.Length != iqLen)
                {
                    if (this._envBuf != null)
                    {
                        this._envBuf.Dispose();
                    }
                    this._envBuf = UnsafeBuffer.Create(iqLen, sizeof(Complex));
                    this._envPtr = (Complex *)(void *)this._envBuf;
                }
                Utils.Memcpy(this._envPtr, iqBuffer, iqLen * sizeof(Complex));
                this._downConverter2.Process(this._envPtr, iqLen);
                int num = iqLen;
                if (this._envelopeDecimator.StageCount > 0)
                {
                    this._envelopeDecimator.Process(this._envPtr, iqLen);
                    num = iqLen >> this._envelopeDecimationStageCount;
                }
                this._envFilter.Process(this._envPtr, num);
                if (this._demodX == DemodType.Envelope)
                {
                    for (int i = 0; i < num; i++)
                    {
                        xBuf[i] = this._envPtr[i].Real * 0.005f;
                    }
                    this.doAgcAndGain(this._agcX, xBuf, num);
                    if (this._useAgc)
                    {
                        for (int j = 0; j < num; j++)
                        {
                            xBuf[j] *= 0.33f;
                        }
                    }
                }
                if (this._demodY == DemodType.Envelope)
                {
                    for (int k = 0; k < num; k++)
                    {
                        yBuf[k] = this._envPtr[k].Imag * 0.005f;
                    }
                    this.doAgcAndGain(this._agcY, yBuf, num);
                    if (this._useAgc)
                    {
                        for (int l = 0; l < num; l++)
                        {
                            yBuf[l] *= 0.33f;
                        }
                    }
                }
                if (envelopBuf != null)
                {
                    for (int m = 0; m < num; m++)
                    {
                        envelopBuf[m] = this._envPtr[m].Imag * 0.005f;
                    }
                    this.doAgcAndGain(this._agcEnv, envelopBuf, num);
                    if (this._useAgc)
                    {
                        for (int n = 0; n < num; n++)
                        {
                            envelopBuf[n] *= 0.33f;
                        }
                    }
                }
            }
            this._downConverter.Process(iqBuffer, iqLen);
            if (this._hookManager != null)
            {
                this._hookManager.ProcessFrequencyTranslatedIQ(iqBuffer, iqLen);
            }
            int num2 = iqLen;

            if (this._baseBandDecimator.StageCount > 0)
            {
                this._baseBandDecimator.Process(iqBuffer, iqLen);
                num2 = iqLen >> this._baseBandDecimationStageCount;
            }
            if (!Utils.FastConvolve)
            {
                this._realIqFilter.Process(iqBuffer, num2);
            }
            else
            {
                this._cpxIqFilter.Process(iqBuffer, num2);
            }
            if (this._hookManager != null)
            {
                this._hookManager.ProcessDecimatedAndFilteredIQ(iqBuffer, num2);
            }
            for (int num3 = 0; num3 <= 3; num3++)
            {
                if (this._notchFilter[num3] != null && this._notchFilter[num3].Width > 0)
                {
                    this._notchFilter[num3].Process(iqBuffer, num2);
                }
            }
            if (this._actualDetectorType == DetectorType.RAW)
            {
                Utils.Memcpy(audioBuffer, iqBuffer, num2 * sizeof(Complex));
            }
            else
            {
                if (this._rawAudioBuffer == null || this._rawAudioBuffer.Length != num2)
                {
                    if (this._rawAudioBuffer != null)
                    {
                        this._rawAudioBuffer.Dispose();
                    }
                    this._rawAudioBuffer = UnsafeBuffer.Create(num2, 4);
                    this._rawAudioPtr    = (float *)(void *)this._rawAudioBuffer;
                }
                if (this.DetectorType == DetectorType.SAM && (this._rBuf == null || this._rBuf.Length != num2))
                {
                    if (this._rBuf != null)
                    {
                        this._rBuf.Dispose();
                    }
                    if (this._lBuf != null)
                    {
                        this._lBuf.Dispose();
                    }
                    this._rBuf = UnsafeBuffer.Create(num2, 4);
                    this._lBuf = UnsafeBuffer.Create(num2, 4);
                    this._rPtr = (float *)(void *)this._rBuf;
                    this._lPtr = (float *)(void *)this._lBuf;
                }
                if (this._actualDetectorType != DetectorType.WFM)
                {
                    Vfo.scaleIQ(iqBuffer, num2);
                }
            }
            int num4 = num2 * 2;

            this.demodulate(iqBuffer, xBuf, yBuf, num2);
            if (this._demodX == DemodType.AM)
            {
                this.doAgcAndGain(this._agcX, xBuf, num2);
            }
            if (this._demodY == DemodType.AM)
            {
                this.doAgcAndGain(this._agcY, yBuf, num2);
            }
            if (this._actualDetectorType == DetectorType.RAW)
            {
                return(num2);
            }
            if (this._actualDetectorType == DetectorType.SAM && this._stereo)
            {
                if (Utils.Chk1)
                {
                    if (this._filterAudio)
                    {
                        this._rFilter.Process(this._rPtr, num2);
                    }
                    this.doAgcAndGain(this._agcX, this._rPtr, num2);
                    if (this._filterAudio)
                    {
                        this._lFilter.Process(this._lPtr, num2);
                    }
                    this.doAgcAndGain(this._agcY, this._lPtr, num2);
                }
                int num5 = 0;
                for (int num6 = 0; num6 < num2; num6++)
                {
                    audioBuffer[num5++] = this._rPtr[num6];
                    audioBuffer[num5++] = this._lPtr[num6];
                }
                if (!Utils.Chk1)
                {
                    if (this._filterAudio)
                    {
                        this._audioFilter.Process(audioBuffer, num2 * 2);
                    }
                    this.doAgcAndGain(this._agc, audioBuffer, num2 * 2);
                }
                return(num2);
            }
            if (this._hookManager != null)
            {
                this._hookManager.ProcessDemodulatorOutput(this._rawAudioPtr, num2);
            }
            if (this._actualDetectorType != DetectorType.WFM)
            {
                if (this._filterAudio)
                {
                    this._audioFilter.Process(this._rawAudioPtr, num2);
                }
                if (this._actualDetectorType != 0)
                {
                    this.doAgcOrGain(this._agc, this._rawAudioPtr, num2);
                }
            }
            if (this._actualDetectorType == DetectorType.AM)
            {
                this._dcRemover.Process(this._rawAudioPtr, num2);
            }
            if (this._actualDetectorType != DetectorType.WFM)
            {
                Vfo.monoToStereo(this._rawAudioPtr, audioBuffer, num2);
            }
            else
            {
                this._rdsDecoder.Process(this._rawAudioPtr, num2);
                this._stereoDecoder.Process(this._rawAudioPtr, audioBuffer, num2);
                num4 >>= this._audioDecimationStageCount;
            }
            if (this._hookManager != null)
            {
                this._hookManager.ProcessFilteredAudioOutput(audioBuffer, num4);
            }
            return(num2);
        }
Example #3
0
        public unsafe void ProcessBuffer(Complex *iqBuffer, float *audioBuffer, int length)
        {
            if (this._needConfigure)
            {
                this.Configure(true);
            }
            length = this._mainDownConverter.Process(iqBuffer, length);
            this._ifOffsetTranslator.Process(iqBuffer, length);
            if (this._lockCarrier && (this._actualDetectorType == DetectorType.LSB || this._actualDetectorType == DetectorType.USB))
            {
                this._carrierLocker.Process(iqBuffer, length);
            }
            this._iqFilter.Process(iqBuffer, length);
            if (this._hookManager != null && this._hooksEnabled)
            {
                this._hookManager.ProcessDecimatedAndFilteredIQ(iqBuffer, length);
            }
            if (this._lockCarrier && (this._actualDetectorType == DetectorType.DSB || this._actualDetectorType == DetectorType.AM))
            {
                this._carrierLocker.Process(iqBuffer, length);
            }
            if (this._lockCarrier && this._useAntiFading && this._carrierLocker.IsLocked && (this._actualDetectorType == DetectorType.DSB || this._actualDetectorType == DetectorType.AM))
            {
                this._amAntiFading.Process(iqBuffer, length);
            }
            if (this._actualDetectorType == DetectorType.RAW)
            {
                Utils.Memcpy(audioBuffer, iqBuffer, length * sizeof(Complex));
                if (this._hookManager != null && this._hooksEnabled)
                {
                    this._hookManager.ProcessFilteredAudioOutput(audioBuffer, length * 2);
                }
                if (this._muted)
                {
                    Vfo.MuteAudio(audioBuffer, length * 2);
                }
            }
            else
            {
                if (this._rawAudioBuffer == null || this._rawAudioBuffer.Length != length)
                {
                    this._rawAudioBuffer = UnsafeBuffer.Create(length, 4);
                    this._rawAudioPtr    = (float *)(void *)this._rawAudioBuffer;
                }
                if (this._actualDetectorType != DetectorType.WFM)
                {
                    Vfo.ScaleIQ(iqBuffer, length);
                }
                if (this._bypassDemodulation)
                {
                    if (this._actualDetectorType == DetectorType.WFM)
                    {
                        length >>= this._audioDecimationStageCount;
                    }
                    length <<= 1;
                    Vfo.MuteAudio(audioBuffer, length);
                }
                else
                {
                    this.Demodulate(iqBuffer, this._rawAudioPtr, length);
                    if (this._hookManager != null && this._hooksEnabled)
                    {
                        this._hookManager.ProcessDemodulatorOutput(this._rawAudioPtr, length);
                    }
                    switch (this._actualDetectorType)
                    {
                    case DetectorType.WFM:
                        if (this._filterAudio)
                        {
                            this._audioIIR.Process(this._rawAudioPtr, length);
                        }
                        if (this._hookManager != null && this._hooksEnabled)
                        {
                            this._hookManager.ProcessFMMPX(this._rawAudioPtr, length);
                        }
                        this._rdsDecoder.Process(this._rawAudioPtr, length);
                        this._stereoDecoder.Process(this._rawAudioPtr, audioBuffer, length);
                        length >>= this._audioDecimationStageCount;
                        break;

                    case DetectorType.NFM:
                        if (this._filterAudio)
                        {
                            this._audioIIR.Process(this._rawAudioPtr, length);
                            this._audioFIR.Process(this._rawAudioPtr, length, 1);
                            this.Deemphasis(this._rawAudioPtr, length);
                        }
                        if (this._useAgc)
                        {
                            this._agc.Process(this._rawAudioPtr, length);
                        }
                        Vfo.MonoToStereo(this._rawAudioPtr, audioBuffer, length);
                        break;

                    default:
                        if (this._useAgc)
                        {
                            this._agc.Process(this._rawAudioPtr, length);
                        }
                        if (this._filterAudio)
                        {
                            this._audioIIR.Process(this._rawAudioPtr, length);
                            this._audioFIR.Process(this._rawAudioPtr, length, 1);
                        }
                        Vfo.MonoToStereo(this._rawAudioPtr, audioBuffer, length);
                        break;
                    }
                    length <<= 1;
                    if (this._hookManager != null && this._hooksEnabled)
                    {
                        this._hookManager.ProcessFilteredAudioOutput(audioBuffer, length);
                    }
                    if (this._muted)
                    {
                        Vfo.MuteAudio(audioBuffer, length);
                    }
                }
            }
        }
        public MainForm()
        {
            _streamControl = new StreamControl();
            _vfoHookManager = new VfoHookManager();
            _vfo = new Vfo(_vfoHookManager);
            _vfoHookManager.Vfo = _vfo;

            InitializeComponent();
            InitializeGUI();
            InitialiseSharpPlugins();

            _vfoHookManager.RegisterStreamHook(this, ProcessorType.RawIQ);
        }