Copyright © 2005-2021 MultiMedia Soft

WASAPI.InputDeviceAttachToPlayer method

Previous pageReturn to chapter overviewNext page

Remarks

 

Attaches an input device (capture or loopback) to a player for immediate playback of incoming audio data.

 

When the selected input device is a loopback device, this method gives the possibility to mirror the output of a specific render device to a different render device with a very low latency: in this specific case it's strongly recommended that you avoid playing audio data taken from a specific loopback device to the corresponding render device or you may experience a very annoying echo effect.

 

You can know if a player is already attached to an input device through the WASAPI.InputDeviceIsAttachedToPlayer method and eventually obtain the zero-based index of the input device through the WASAPI.InputDeviceAttachedToPlayerIndexGet method.

 

An attached device can be detached from the player by invoking the CloseSound method or by loading a new sound through the LoadSound method or similar.

 

This method is only intended for usage with Windows Vista and later versions.

For further details about the use of WASAPI see the WASAPIMan class and the How to manage audio flow through WASAPI tutorial

 

 

Syntax

 

[Visual Basic]

Public Function InputDeviceAttachToPlayer (

nPlayerIndex as Int16,

nDeviceIndex as Int16,

nDeviceType as enumWasapiDeviceTypes

) as enumErrorCodes


 

[C#]

public enumErrorCodes InputDeviceAttachToPlayer (

Int16 nPlayerIndex,

Int16 nDeviceIndex,

enumWasapiDeviceTypes nDeviceType

);


 

[C++]

public: enumErrorCodes InputDeviceAttachToPlayer (

Int16 nPlayerIndex,

Int16 nDeviceIndex,

enumWasapiDeviceTypes nDeviceType

);


 

Parameter

Description

 

 

nPlayerIndex

Number representing the zero-based index of the involved player

nDeviceIndex

Number representing the zero-based index of the WASAPI capture device.

This index is related to WASAPI capture devices enumerated through the WASAPI.DeviceGetCount and WASAPI.DeviceGetDesc methods having the nDeviceType parameter set to WASAPI_DEVICE_TYPE_CAPTURE..

nDeviceType

The type of input device used to obtain audio data.

Supported values are the following:

Mnemonic Value

Value

Meaning

WASAPI_DEVICE_TYPE_RENDER

0

Audio rendering device. Not being an input device, when this setting is applied audio data will be automatically taken from the corresponding loopback device.

WASAPI_DEVICE_TYPE_CAPTURE

1

Audio capture device.

WASAPI_DEVICE_TYPE_LOOPBACK

2

Audio loopback device.

 

 

 

Return value

 

Value

Meaning

 

 

Negative value

An error occurred (see the LastError property for further error details)

enumErrorCodes.NOERROR (0)

The method call was successful.