Table of Contents

Class AudioCaptureSource

Namespace
VisioForge.Core.Types.VideoCapture
Assembly
VisioForge.Core.dll

Represents an audio capture source configuration for audio recording and preview operations.

public class AudioCaptureSource

Inheritance

Inherited Members

Remarks

This class encapsulates all settings required to configure an audio capture device, including device selection, format configuration, input line selection, and custom source filters. It supports both physical audio devices and custom audio source implementations through the VisioForge.Core.Types.VideoCapture.ICustomAudioSourceFilter interface.

Constructors

AudioCaptureSource()

Initializes a new instance of the VisioForge.Core.Types.VideoCapture.AudioCaptureSource class with default settings.

public AudioCaptureSource()

Remarks

The instance is initialized with the following defaults:

  • VisioForge.Core.Types.VideoCapture.AudioCaptureSource.Format_UseBest is set to true
  • VisioForge.Core.Types.VideoCapture.AudioCaptureSource.Name, VisioForge.Core.Types.VideoCapture.AudioCaptureSource.Format, and VisioForge.Core.Types.VideoCapture.AudioCaptureSource.Line are set to empty strings
  • All other properties are set to their default values

AudioCaptureSource(string)

Initializes a new instance of the VisioForge.Core.Types.VideoCapture.AudioCaptureSource class with the specified device name.

public AudioCaptureSource(string name)

Parameters

name string

The name of the audio capture device to use.

Remarks

This constructor automatically attempts to detect the preferred audio format for the specified device. If a format with 44100 Hz, 16-bit, 2 channels is available, it will be selected. Otherwise, VisioForge.Core.Types.VideoCapture.AudioCaptureSource.Format_UseBest is set to true.

The constructor temporarily creates a VisioForge.Core.DirectShow.MediaDevices instance to query device capabilities, which is disposed after use.

AudioCaptureSource(AudioCaptureDeviceInfo)

Initializes a new instance of the VisioForge.Core.Types.VideoCapture.AudioCaptureSource class using device information.

public AudioCaptureSource(AudioCaptureDeviceInfo info)

Parameters

info AudioCaptureDeviceInfo

An VisioForge.Core.Types.VideoCapture.AudioCaptureDeviceInfo instance containing device information.

Remarks

This constructor uses the device information to set the device name and automatically detect the preferred format. The format detection logic is the same as in the VisioForge.Core.Types.VideoCapture.AudioCaptureSource.#ctor(System.String) constructor.

Exceptions

ArgumentNullException

Thrown when info is null.

Properties

CustomLatency

Gets or sets the custom audio latency in milliseconds.

public int CustomLatency { get; set; }

Property Value

int

Remarks

This property allows fine-tuning of audio latency for specific scenarios. Lower values reduce delay but may increase CPU usage and the risk of audio dropouts. Higher values provide more stable capture but increase the delay.

Note: Not all audio capture devices support custom latency settings. If unsupported, this value is ignored.

Format

Gets or sets the audio format to use for recording and preview.

public string Format { get; set; }

Property Value

string

Remarks

The format string must match one of the formats supported by the selected audio capture device. You can get the list of supported formats from VisioForge.Core.Types.VideoCapture.AudioCaptureDeviceInfo.Formats.

If VisioForge.Core.Types.VideoCapture.AudioCaptureSource.Format_UseBest is true, this property is ignored and the best available format is automatically selected.

Format_UseBest

Gets or sets a value indicating whether the best available audio format should be automatically selected.

public bool Format_UseBest { get; set; }

Property Value

bool

Remarks

When set to true, the system will automatically choose the highest quality format supported by the device, typically preferring formats like 44100 Hz, 16-bit, Stereo when available. This is the recommended setting for most applications.

Line

Gets or sets the audio input line to use for recording and preview.

public string Line { get; set; }

Property Value

string

Remarks

The available input lines depend on the selected audio capture device. You can get the list of available lines from VisioForge.Core.Types.VideoCapture.AudioCaptureDeviceInfo.Lines.

Not all audio devices support multiple input lines. If the device doesn't support line selection, this property is ignored.

MasterDevice

Gets or sets the master device name for audio synchronization.

public string MasterDevice { get; set; }

Property Value

string

Remarks

This is an advanced property used for synchronizing audio capture with another device, typically a video capture device. The audio capture will be synchronized to the timing of the master device.

Warning: This property should only be used if you fully understand audio/video synchronization. Incorrect use can result in audio/video sync issues.

MasterDevice_Format

Gets or sets the format of the master device used for synchronization.

public string MasterDevice_Format { get; set; }

Property Value

string

Remarks

This property should be set when VisioForge.Core.Types.VideoCapture.AudioCaptureSource.MasterDevice is specified. It defines the format that the master device is using, which affects how synchronization is performed.

Name

Gets or sets the name of the audio capture device to use.

public string Name { get; set; }

Property Value

string

Remarks

This should match one of the device names returned by the device enumeration API. If multiple devices have the same name, use the VisioForge.Core.Types.VideoCapture.AudioCaptureSource.Path property to distinguish between them.

Path

Gets or sets the unique device path for the audio capture device.

public string Path { get; set; }

Property Value

string

Remarks

This property is optional and primarily used when multiple devices have the same display name. The device path uniquely identifies a specific device instance.

On Windows, this is typically a DirectShow moniker string. You can obtain the device path using the device enumeration API or from VisioForge.Core.Types.VideoCapture.AudioCaptureDeviceInfo.DevicePath.

SourceFilter

Gets or sets a custom audio source filter implementation.

public ICustomAudioSourceFilter SourceFilter { get; set; }

Property Value

ICustomAudioSourceFilter

Remarks

This property allows you to provide custom audio data programmatically instead of capturing from a physical device. Implement the VisioForge.Core.Types.VideoCapture.ICustomAudioSourceFilter interface in your class to create a custom audio source. When this property is set, the VisioForge.Core.Types.VideoCapture.AudioCaptureSource.Name property is ignored.

Methods

~AudioCaptureSource()

Finalizes an instance of the VisioForge.Core.Types.VideoCapture.AudioCaptureSource class.

protected ~AudioCaptureSource()

Remarks

The finalizer ensures that the VisioForge.Core.Types.VideoCapture.AudioCaptureSource.SourceFilter is properly disposed if it hasn't been disposed already. This prevents resource leaks when custom audio source filters are used.

ToString()

Returns a string representation of the audio capture source.

public override string ToString()

Returns

string

The name of the audio capture device, or an empty string if no device is selected.

Remarks

This method is useful for displaying the audio source in user interfaces or for debugging purposes.