Example #1
0
        private unsafe static void extIOCallback(int count, int status, float iqOffs, IntPtr dataPtr)
        {
            if (count >= 0 && ExtIO._isHWStarted)
            {
                if (ExtIO._iqPtr != null)
                {
                    int length = ExtIO._iqBuffer.Length;
                    if (ExtIO._hwType == HWTypes.Aud16BInt || ExtIO._hwType == HWTypes.Sdr14)
                    {
                        short *ptr = (short *)(void *)dataPtr;
                        for (int i = 0; i < length; i++)
                        {
                            Complex *intPtr  = ExtIO._iqPtr + i;
                            short *  intPtr2 = ptr;
                            ptr          = intPtr2 + 1;
                            intPtr->Imag = (float)(*intPtr2) * 3.051851E-05f;
                            Complex *intPtr3 = ExtIO._iqPtr + i;
                            short *  intPtr4 = ptr;
                            ptr           = intPtr4 + 1;
                            intPtr3->Real = (float)(*intPtr4) * 3.051851E-05f;
                        }
                    }
                    else if (ExtIO._hwType == HWTypes.Aud24BInt)
                    {
                        Int24 *ptr2 = (Int24 *)(void *)dataPtr;
                        for (int j = 0; j < length; j++)
                        {
                            Complex *intPtr5 = ExtIO._iqPtr + j;
                            Int24 *  intPtr6 = ptr2;
                            ptr2          = intPtr6 + 1;
                            intPtr5->Imag = (float)(*intPtr6) * 1.1920929E-07f;
                            Complex *intPtr7 = ExtIO._iqPtr + j;
                            Int24 *  intPtr8 = ptr2;
                            ptr2          = intPtr8 + 1;
                            intPtr7->Real = (float)(*intPtr8) * 1.1920929E-07f;
                        }
                    }
                    else if (ExtIO._hwType == HWTypes.Aud32BInt)
                    {
                        int *ptr3 = (int *)(void *)dataPtr;
                        for (int k = 0; k < length; k++)
                        {
                            Complex *intPtr9  = ExtIO._iqPtr + k;
                            int *    intPtr10 = ptr3;
                            ptr3          = intPtr10 + 1;
                            intPtr9->Imag = (float)(*intPtr10) * 4.656613E-10f;
                            Complex *intPtr11 = ExtIO._iqPtr + k;
                            int *    intPtr12 = ptr3;
                            ptr3           = intPtr12 + 1;
                            intPtr11->Real = (float)(*intPtr12) * 4.656613E-10f;
                        }
                    }
                    else if (ExtIO._hwType == HWTypes.Aud32BFloat)
                    {
                        float *ptr4 = (float *)(void *)dataPtr;
                        for (int l = 0; l < length; l++)
                        {
                            Complex *intPtr13 = ExtIO._iqPtr + l;
                            float *  intPtr14 = ptr4;
                            ptr4           = intPtr14 + 1;
                            intPtr13->Imag = *intPtr14;
                            Complex *intPtr15 = ExtIO._iqPtr + l;
                            float *  intPtr16 = ptr4;
                            ptr4           = intPtr16 + 1;
                            intPtr15->Real = *intPtr16;
                        }
                    }
                    if (ExtIO.SamplesAvailable != null)
                    {
                        ExtIO.SamplesAvailable(null, ExtIO._iqPtr, length);
                    }
                }
            }
            else if (status > 0)
            {
                int num = 0;
                switch (status)
                {
                case 100:
                    ExtIO.logInfo("Status 100, SRChanged");
                    num = ExtIO.GetHWSR();
                    if (ExtIO.SampleRateChanged != null)
                    {
                        ExtIO.SampleRateChanged(num);
                    }
                    break;

                case 101:
                    ExtIO.logInfo("Status 101, LOFreqChanged");
                    num = ExtIO.GetHWLO();
                    if (ExtIO.LOFreqChanged != null && num > 0)
                    {
                        ExtIO.LOFreqChanged(num);
                    }
                    break;

                case 102:
                    ExtIO.logInfo("Status 102, ProhibitLO");
                    if (ExtIO.ProhibitLOChanged != null)
                    {
                        ExtIO.ProhibitLOChanged();
                    }
                    break;

                case 103:
                    ExtIO.logInfo("Status 103, LOChangeOK");
                    if (ExtIO.LOFreqChangedAccepted != null)
                    {
                        ExtIO.LOFreqChangedAccepted();
                    }
                    break;

                case 104:
                    ExtIO.logInfo("Status 104, LOChangedNoTune");
                    num = ExtIO.GetHWLO();
                    if (ExtIO.LOFreqChanged != null && num > 0)
                    {
                        ExtIO.LOFreqChanged(num);
                    }
                    break;

                case 105:
                    ExtIO.logInfo("Status 105, TuneChanged");
                    num = ExtIO.GetTune();
                    if (ExtIO.TuneFreqChanged != null && num > 0)
                    {
                        ExtIO.TuneFreqChanged(num);
                    }
                    break;

                case 106:
                    ExtIO.logInfo("Status 106, DemodChange");
                    break;

                case 107:
                    ExtIO.logInfo("Status 107, RsqStart");
                    break;

                case 108:
                    ExtIO.logInfo("Status 108, RsqStop");
                    break;

                case 109:
                    ExtIO.logInfo("FiltChange (109)");
                    break;

                default:
                    ExtIO.logInfo("Unknown status " + status.ToString() + " received from DLL.");
                    break;
                }
            }
        }