Skip to main content

FM Radio and TV Tuning

Products: Video Capture SDK .Net

Sample code

1. Get a list of available TV Tuners

foreach (var tunerDevice in VideoCapture1.TVTuner_Devices)
{
cbTVTuner.Items.Add(tunerDevice);
}

2. Get a list of available TV formats

foreach (var tunerTVFormat in VideoCapture1.TVTuner_TVFormats)
{
cbTVSystem.Items.Add(tunerTVFormat);
}

3. Get a list of countries

foreach (var tunerCountry in VideoCapture1.TVTuner_Countries)
{
cbTVCountry.Items.Add(tunerCountry);
}

4. Select the TV Tuner

VideoCapture1.TVTuner_Name = cbTVTuner.Text;

5. Read TV Tuner settings

await VideoCapture1.TVTuner_ReadAsync();

6. Get a list of available TV modes

foreach (var tunerMode in VideoCapture1.TVTuner_Modes)
{
cbTVMode.Items.Add(tunerMode);
}

7. Get current audio and video frequencies

edVideoFreq.Text = Convert.ToString(VideoCapture1.TVTuner_VideoFrequency);
edAudioFreq.Text = Convert.ToString(VideoCapture1.TVTuner_AudioFrequency);

8. Select the signal source

cbTVInput.SelectedIndex = cbTVInput.Items.IndexOf(VideoCapture1.TVTuner_InputType);

9. Select work mode

cbTVMode.SelectedIndex = cbTVMode.Items.IndexOf(VideoCapture1.TVTuner_Mode);

10. Select the TV system (PAL, NTSC, SECAM, etc.)

cbTVSystem.SelectedIndex = cbTVSystem.Items.IndexOf(VideoCapture1.TVTuner_TVFormat);

11. Select country

cbTVCountry.SelectedIndex = cbTVCountry.Items.IndexOf(VideoCapture1.TVTuner_Country);

12. Write event code

private void VideoCapture1_OnTVTunerTuneChannels(object sender, TVTunerTuneChannelsEventArgs e)
{
pbChannels.Value = e.Progress;

if (e.SignalPresent)
{
cbTVChannel.Items.Add(e.Channel.ToString());
}

if (e.Channel == -1)
{
pbChannels.Value = 0;
MessageBox.Show("AutoTune complete");
}

Application.DoEvents();
}

13. Start the tuning process

const int KHz = 1000;
const int MHz = 1000000;

await VideoCapture1.TVTuner_ReadAsync();
cbTVChannel.Items.Clear();

// For FM Tuning, you can specify the initial frequencies and the scanning pitch
if ((cbTVMode.SelectedIndex != -1) && (cbTVMode.Text == "FM Radio"))
{
VideoCapture1.TVTuner_FM_Tuning_StartFrequency = 100 * MHz;
VideoCapture1.TVTuner_FM_Tuning_StopFrequency = 110 * MHz;
VideoCapture1.TVTuner_FM_Tuning_Step = 100 * KHz;
};

VideoCapture1.TVTuner_TuneChannels_Start();

Once each channel is found, the event will be called and the channel will be added to the combo box.

Also, you can specify the frequency and number of each channel manually.

14. Set channel by number

VideoCapture1.TVTuner_Channel = Convert.ToInt32(edChannel.Text); 
await VideoCapture1.TVTuner_ApplyAsync();

15. Set channel by frequency

VideoCapture1.TVTuner_Channel = -1; // must be -1 to use frequency 
VideoCapture1.TVTuner_Frequency = Convert.ToInt32(edChannel.Text);
await VideoCapture1.TVTuner_ApplyAsync();

Required redists

How to install the required redists or deploy them to the user's PC?


Visit our GitHub page to get more code samples.