예제 #1
0
파일: Form1.cs 프로젝트: Roman-Port/LibSDR
 private void ProgramService_OnPartialTextReceived(RdsClient ctx, char[] buffer, int offset)
 {
     Invoke((MethodInvoker) delegate
     {
         rdsPs.Text = new string(buffer);
     });
 }
예제 #2
0
파일: Form1.cs 프로젝트: Roman-Port/LibSDR
 private void PiCode_OnPiCodeChanged(RdsClient ctx, ushort pi)
 {
     Invoke((MethodInvoker) delegate
     {
         rdsPi.Text = pi.ToString("X");
     });
 }
예제 #3
0
파일: Form1.cs 프로젝트: Roman-Port/LibSDR
 private void ProgramType_OnCategoryChanged(RdsClient ctx, byte category)
 {
     Invoke((MethodInvoker) delegate
     {
         rdsCategory.Text = category + " : " + ctx.ProgramType.CategoryAmerica.ToString();
     });
 }
예제 #4
0
파일: Form1.cs 프로젝트: Roman-Port/LibSDR
 private void RadioText_OnPartialTextReceived(RdsClient ctx, char[] buffer, int offset)
 {
     Invoke((MethodInvoker) delegate
     {
         rdsRt.Text = new string(buffer);
     });
 }
예제 #5
0
파일: Form1.cs 프로젝트: Roman-Port/LibSDR
        private void Form1_Load(object sender, EventArgs e)
        {
            //Add all entries to the pie graph to start off with
            for (int i = 0; i < 32; i++)
            {
                rdsGroupChart.Series["Groups"].Points.AddXY("", 0);
                rdsGroupChart.Series["Groups"].Points[i].IsVisibleInLegend = false;
            }

            //Configure table
            rdsHistory.Columns.Add(GenerateColumn("PI", 40));
            rdsHistory.Columns.Add(GenerateColumn("Group", 50));
            rdsHistory.Columns.Add(GenerateColumn("Description", -1));

            //Create buffers
            iqBuffer    = UnsafeBuffer.Create(BUFFER_SIZE, out iqBufferPtr);
            audioBuffer = UnsafeBuffer.Create(BUFFER_SIZE, out audioBufferPtr);

            //Open USB device
            usb    = new LibUSBProvider();
            device = AirSpyDevice.OpenDevice(usb);

            //Configure radio
            device.SetLinearGain(gain.Value / 100f);
            device.CenterFrequency = (long)(freq.Value * 1000000);
            device.SampleRate      = 3000000;
            device.StartRx();

            //Create filter
            var filterBuilder = new LowPassFilterBuilder(device.SampleRate, BANDWIDTH / 2)
                                .SetAutomaticTapCount(BANDWIDTH * 0.1f, 50)
                                .SetWindow();

            filter = ComplexFirFilter.CreateFirFilter(filterBuilder, filterBuilder.GetDecimation(out float decimatedSampleRate));

            //Create FM and RDS
            fm = new WbFmDemodulator();
            fm.Configure(BUFFER_SIZE, decimatedSampleRate, 48000);
            fm.OnStereoDetected += Fm_OnStereoDetected;
            fm.OnRdsDetected    += Fm_OnRdsDetected;
            rds = new RdsClient();
            fm.OnRdsFrameEmitted += (ulong frame) => rds.ProcessFrame(frame);

            //Bind RDS client commands
            rds.ProgramService.OnPartialTextReceived += ProgramService_OnPartialTextReceived;
            rds.PiCode.OnPiCodeChanged          += PiCode_OnPiCodeChanged;
            rds.ProgramType.OnCategoryChanged   += ProgramType_OnCategoryChanged;
            rds.RadioText.OnPartialTextReceived += RadioText_OnPartialTextReceived;
            rds.OnCommand += Rds_OnCommand;

            //Create worker thread
            worker = new Thread(WorkerThread);
            worker.IsBackground = true;
            worker.Start();
        }
예제 #6
0
파일: Form1.cs 프로젝트: Roman-Port/LibSDR
        private int[] groupChartValues = new int[32]; //32 = 2^5

        private void Rds_OnCommand(RdsClient client, RdsCommand command)
        {
            //Configure pie graph
            int groupId = (command.GroupType << 1) | (command.GroupVersionB ? 1 : 0);

            //Update internal count
            groupChartValues[groupId]++;

            //Update UI
            Invoke((MethodInvoker) delegate
            {
                //Update graph
                rdsGroupChart.Series["Groups"].Points[groupId].SetValueXY(command.GroupName + " (" + groupChartValues[groupId] + ")", groupChartValues[groupId]);
                rdsGroupChart.Series["Groups"].Points[groupId].IsVisibleInLegend = true;
                rdsGroupChart.Invalidate();

                //Update table
                if (!historyPause.Checked)
                {
                    rdsHistory.Rows.Insert(0, command.PiCode.ToString("X"), command.GroupName, command.DescribeCommand());
                }
            });
        }