コード例 #1
0
ファイル: AirspyIO.cs プロジェクト: yi520520/SDRSharp-1
 public void Open()
 {
     this._airspyDevice           = new AirspyDevice(false);
     this._airspyDevice.Frequency = (uint)this._frequency;
     this._gui.Device             = this._airspyDevice;
     this._airspyDevice.ComplexSamplesAvailable += this.AirSpyDevice_SamplesAvailable;
     this._airspyDevice.SampleRateChanged       += this.AirSpyDevice_SampleRateChanged;
     this._gui.RefreshTimerEnabled = true;
 }
コード例 #2
0
ファイル: AirspyIO.cs プロジェクト: yi520520/SDRSharp-1
 public void Close()
 {
     if (this._airspyDevice != null)
     {
         this._gui.RefreshTimerEnabled = false;
         this._gui.SaveSettings();
         this._gui.Device = null;
         this._airspyDevice.ComplexSamplesAvailable -= this.AirSpyDevice_SamplesAvailable;
         this._airspyDevice.SampleRateChanged       -= this.AirSpyDevice_SampleRateChanged;
         this._airspyDevice.Dispose();
         this._airspyDevice = null;
     }
 }
コード例 #3
0
ファイル: AirspyDevice.cs プロジェクト: yi520520/SDRSharp-1
        private unsafe static int AirSpySamplesAvailable(airspy_transfer *data)
        {
            int      num             = data->sample_count;
            ulong    dropped_samples = data->dropped_samples;
            IntPtr   ctx             = data->ctx;
            GCHandle gCHandle        = GCHandle.FromIntPtr(ctx);

            if (!gCHandle.IsAllocated)
            {
                return(-1);
            }
            AirspyDevice airspyDevice = (AirspyDevice)gCHandle.Target;

            if (data->sample_type == airspy_sample_type.AIRSPY_SAMPLE_FLOAT32_REAL)
            {
                float *samples = (float *)data->samples;
                airspyDevice.OnRealSamplesAvailable(samples, num, dropped_samples);
            }
            else
            {
                Complex *samples2 = (Complex *)data->samples;
                bool     flag     = airspyDevice._analogFilterConfig != null && airspyDevice._analogFilterConfig.Shift != 0;
                if (airspyDevice._decimationStages > 0)
                {
                    airspyDevice.UpdateDDC();
                    num = airspyDevice._ddc.Process(samples2, num);
                }
                if (!flag)
                {
                    float num2  = airspyDevice._iavg;
                    float num3  = airspyDevice._qavg;
                    float alpha = airspyDevice._alpha;
                    for (int i = 0; i < num; i++)
                    {
                        num2             += alpha * (samples2[i].Real - num2);
                        num3             += alpha * (samples2[i].Imag - num3);
                        samples2[i].Real -= num2;
                        samples2[i].Imag -= num3;
                    }
                    airspyDevice._iavg = num2;
                    airspyDevice._qavg = num3;
                }
                airspyDevice.OnComplexSamplesAvailable(samples2, num, dropped_samples);
            }
            return(0);
        }