Copyright © 2011-2019 MultiMedia Soft

WASAPI.RenderDeviceVolumeSet method

Previous pageReturn to chapter overviewNext page

Remarks

 

Sets the volume of the given WASAPI device for the current process. The current volume can be obtained through the WASAPI.RenderDeviceVolumeGet method.

 

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

For further details about WASAPI see the WASAPIMan class and the How to manage audio playback through WASAPI tutorial.

 

 

Syntax

 

[Visual Basic]

Public Function RenderDeviceVolumeSet (

nDeviceIndex as Int32,

nScaleType as enumVolumeScales,

fVolumeLevel as Single

) as enumErrorCodes


 

[C#]

public enumErrorCodes RenderDeviceVolumeSet (

Int32 nDeviceIndex,

enumVolumeScales nScaleType,

float fVolumeLevel

);


 

[C++]

public: enumErrorCodes RenderDeviceVolumeSet (

Int32 nDeviceIndex,

enumVolumeScales nScaleType,

float fVolumeLevel

);


 

 

Parameter

Description

 

 

nDeviceIndex

Number representing the zero-based index of the WASAPI device of interest. The total number of available WASAPI devices can be obtained using the WASAPI.RenderDeviceGetCount method.

nScaleType

The volume scaling type.

Supported values are the following:

Mnemonic constant

Value

Meaning

SCALE_LINEAR

0

The passed volume is based upon a linear scale and can be in the range from 0.0 (silence) to 100.0 (max volume)

SCALE_LOG

1

The passed volume, expressed in dB, is based upon a logarithmic scale.

 

IMPORTANT NOTE ABOUT UNITS OF MEASURE:When dealing with values expressed in percentage the effective value can have different meaning depending upon the implementation of the sound card driver: for example, usually a percentage value of 100 is assumed as 0 dB: this is not the case when dealing with Core Audio API because, if the sound card driver allows applying a volume range from -100 dB (total silence) to +20 dB (sound amplification of +20 dB), a percentage value of 100 would mean that the applied volume is +20 dB. The range of volume values accepted by the sound card driver can be verified through the "Sound" applet of the Windows Control Panel.

 

IMPORTANT NOTE ABOUT CONVERSION BETWEEN UNITS OF MEASURE: When setting a volume expressed in percentage through one of our component's methods, the value displayed inside the "Sound" applet of the Windows Control Panel may report a value slightly different respect to the one effectively set: this issue is due to a rounding problem when converting from percentage to dB (all values are stored in dB inside the driver); if this should be a problem for you, in order to avoid this minor issue you should always use dB as unit of measure when calling our component's methods and to set the "Sound" applet of the Windows Control Panel to display values in dB instead of the percentage default.

fVolumeLevel

Number representing the volume level for the current process (the meaning of this value depends upon the nScaleType parameter).

 

 

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.