AudioCaptureFormats Property

Summary
Gets the AudioFormats object that contains all the audio formats available for the current capture device.
Syntax
C#
C++/CLI
public virtual AudioFormats AudioCaptureFormats { get; } 
public: 
virtual property AudioFormats^ AudioCaptureFormats { 
   AudioFormats^ get(); 
} 

Property Value

An AudioFormats object.

Remarks

The AudioFormats collection contains an AudioFormat object for each of the supported audio formats. The properties of each AudioFormat object include the BitsPerSample, Channels, and the SampleFrequency.

Example
C#
using Leadtools; 
using Leadtools.Multimedia; 
using LeadtoolsMultimediaExamples.Fixtures; 
 
 
public CaptureCtrlForm _form = new CaptureCtrlForm(); 
 
public bool _result = false; 
 
public void AudioFormatExample() 
{ 
   try 
   { 
      int count, freq = 0, bits = 0, channels = 0; 
      int found, selected = -1; 
 
      // reference the capture control 
      CaptureCtrl capturectrl = _form.CaptureCtrl; 
 
      // set an audio device, use the name of your device here 
      if (capturectrl.AudioDevices["USB"] == null) 
         throw new Exception("No USB audio device available"); 
 
      capturectrl.AudioDevices["USB"].Selected = true; 
 
      // get a count of the available audio formats 
      count = capturectrl.AudioCaptureFormats.Count; 
 
      // reset the current selection to -1 
      capturectrl.AudioCaptureFormats.Selection = -1; 
 
      // reference the audioformats property 
      AudioFormats audioformats = capturectrl.AudioCaptureFormats; 
 
      // enumerate formats and select one 
      foreach (AudioFormat af in audioformats) 
      { 
         freq = af.SampleFrequency; 
         bits = af.BitsPerSample; 
         channels = af.Channels; 
 
         // select the format if it matches some criteria 
         if (freq == 8000 && bits == 16 && channels == 2) 
         { 
            af.Selected = true; 
            break; 
         } 
      } 
 
      // get the currently selected format 
      selected = audioformats.Selection; 
 
      // find a format based on frequency, bits/channel and number of channels 
      found = audioformats.IndexOf(8000, 8, 2); 
 
      // the format found format is not selected, so select it 
      if (found != selected) 
         audioformats.Selection = found; 
 
      // get the new selected format 
      selected = audioformats.Selection; 
 
      // set our result based on what we expect 
      _result = (count > 0 && selected == found); 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
Requirements

Target Platforms

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Multimedia Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.