Skip to main content

FM Radio and TV Tuning

Products: Video Capture SDK .Net

This article describes how to use the FM radio and TV tuning features of the SDK.

Sample code

Get a list of available TV Tuners.

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

Get a list of available TV formats.

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

Get a list of countries.

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

Select the TV Tuner.

VideoCapture1.TVTuner_Name = cbTVTuner.Text;

Read TV Tuner settings.

await VideoCapture1.TVTuner_ReadAsync();

Get a list of available TV modes.

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

Get current audio and video frequencies.

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

Select the signal source.

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

Select work mode.

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

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

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

Select country.

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

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();
}

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.

Set channel by number

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

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 can the required redists be installed or deployed to the user's PC?


Visit our GitHub page to get more code samples.