Copyright © 2006-2018 MultiMedia Soft

MixerInputDevicePeakLevelsGet method

Previous pageReturn to chapter overviewNext page

Remarks

 

Retrieves peak levels on one of the input devices attached to the stream mixer using the specified scale.

 

The CallbackVuMeterValueChange delegate is used for the purpose of retrieving peak levels of the audio stream during recording/playback: this method can be used as an integration of the existing CallbackVuMeterValueChange delegate in order to obtain peak or RMS (Root-Mean-Square) levels for a specific input devices attached to the stream mixer: a good place to invoke this method is indeed inside the handler function of the CallbackVuMeterValueChange

 

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 MixerInputDevicePeakLevelsGet (

tPeakLevels() as Single,

nLengthInMs as Int32,

bRms as Boolean,

bStereo as Boolean,

nScaleType as enumVolumeScales

) as enumErrorCodes


 

[C#]

public enumErrorCodes MixerInputDevicePeakLevelsGet (

float[] tPeakLevels,

Int32 nLengthInMs,

bool bRms,

bool bStereo,

enumVolumeScales nScaleType

);


 

[C++]

public: enumErrorCodes MixerInputDevicePeakLevelsGet (

float[] tPeakLevels,

Int32 nLengthInMs,

bool bRms,

bool bStereo,

enumVolumeScales nScaleType

);


 

 

Parameter

Description

 

 

nListIndex

Zero-based index of the input device within the list of input devices attached to the WASAPI mixer; the number of of input devices attached to the WASAPI mixer can be obtained through the WASAPI.MixerInputDeviceAttachedCountGet method.

nDeviceIndex

Reference that, on return from the method call, will contain the number representing the zero-based index of the WASAPI input device of interest. The total number of available WASAPI devices can be obtained using the WASAPI.DeviceGetCount method.

nDeviceType

Reference that, on return from the method call, will contain type of input device.

Supported values are the following:

Mnemonic Value

Value

Meaning

WASAPI_DEVICE_TYPE_CAPTURE

1

Audio capture device.

WASAPI_DEVICE_TYPE_LOOPBACK

2

Audio loopback device.

tPeakLevels

Table that, on return from the method call, will contain floating point values representing detected peak levels for each of the audio stream's channels.

In order to avoid issues, the size of this table should be adapted to the possibility to store up to 8 channels.

nLengthInMs

The amount of data to inspect to calculate the peak level, expressed in milliseconds. The maximum value is 1000.

bRms

Boolean value indicating if values to retrieve are RMS (Root-Mean-Square) levels or peak levels.

Supported values are the following:

Mnemonic constant

Meaning

false

Use peak levels.

true

Use RMS levels.

bStereo

Boolean value indicating if values to retrieve should be considered as mono or stereo levels.

Supported values are the following:

Mnemonic constant

Meaning

false

Get mono levels, allowing to retrieve a separate level for each channel.

true

Get stereo levels meaning that the left level will be from the even channels, and the right level will be from the odd channels. If there are an odd number of channels then the left and right levels will both include all channels.

nScaleType

The scaling type of values reported into the tPeakLevels table.

Supported values are the following:

Mnemonic constant

Value

Meaning

SCALE_LINEAR

0

Returned values are based upon a linear scale and can be in the range from 0.0 (silence) to 100.0 (max volume)

SCALE_LOG

1

Returned values, expressed in dB, are based upon a logarithmic scale and can be in the range from -100  (silence) to 0 (max volume)

The actual applied formula for converting a linear value into a logarithmic value is the following:

ValueInDB = 20 * log10 (ValueLinear/100)

The C syntax for converting a logarithmic value into a linear value is the following:

ValueLinear = 100 * pow (10, ValueInDB/20);

 

 

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.