public class AudioEndpointVolume : ComObject
The AudioEndpointVolume interface represents the volume controls on the audio stream to or from an audio endpoint device. For more information, see .
AudioEndpointVolume(IntPtr ptr)
Initializes a new instance of the AudioEndpointVolume class.
public void AudioEndpointVolume(IntPtr ptr)
Parameters
ptr
IntPtrNative pointer of the AudioEndpointVolume object.
FromDevice(MMDevice device)
Returns a new AudioEndpointVolume instance based on a MMDevice instance.
public static AudioEndpointVolume FromDevice(MMDevice device)
Parameters
device
MMDeviceMMDevice instance to create the AudioEndpointVolume for.
Returns
A new AudioEndpointVolume instance based on the specified device.
GetChannelCount()
Gets the number of channels in the audio stream that enters or leaves the audio endpoint device.
GetChannelCountNative(Int32& channelCount)
Gets the number of channels in the audio stream that enters or leaves the audio endpoint device.
public Int32 GetChannelCountNative(Int32& channelCount)
Parameters
channelCount
Int32&Retrieves the number of channels in the audio stream.
Returns
HRESULT
GetChannelVolumeLevel(Int32 channel)
Gets the volume level, in decibels, of the specified channel in the audio stream that enters or leaves the audio endpoint device.
public Single GetChannelVolumeLevel(Int32 channel)
Parameters
channel
Int32The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n–1.
Returns
Volume level in decibels. To get the range of volume levels obtained from this method, call the GetVolumeRange method.
GetChannelVolumeLevelNative(Int32 channel, Single& levelDB)
Gets the volume level, in decibels, of the specified channel in the audio stream that enters or leaves the audio endpoint device.
public Int32 GetChannelVolumeLevelNative(Int32 channel, Single& levelDB)
Parameters
levelDB
Single&A float variable into which the method writes the volume level in decibels. To get the range of volume levels obtained from this method, call the GetVolumeRange method.
channel
Int32The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n–1.
Returns
HRESULT
GetChannelVolumeLevelScalar(Int32 channel)
Gets the normalized, audio-tapered volume level of the specified channel of the audio stream that enters or leaves the audio endpoint device.
public Single GetChannelVolumeLevelScalar(Int32 channel)
Parameters
channel
Int32The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n–1.
Returns
Volume level of a specific channel. The level is expressed as a normalized value in the range from 0.0 to 1.0.
GetChannelVolumeLevelScalarNative(Int32 channel, Single& level)
Gets the normalized, audio-tapered volume level of the specified channel of the audio stream that enters or leaves the audio endpoint device.
public Int32 GetChannelVolumeLevelScalarNative(Int32 channel, Single& level)
Parameters
level
Single&A float variable into which the method writes the volume level. The level is expressed as a normalized value in the range from 0.0 to 1.0.
channel
Int32The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n–1.
Returns
HRESULT
GetMasterVolumeLevel()
Gets the master volume level, in decibels, of the audio stream that enters or leaves the audio endpoint device.
GetMasterVolumeLevelNative(Single& levelDB)
Gets the master volume level, in decibels, of the audio stream that enters or leaves the audio endpoint device.
public Int32 GetMasterVolumeLevelNative(Single& levelDB)
Parameters
levelDB
Single&A float variable into which the method writes the volume level in decibels. To get the range of volume levels obtained from this method, call the GetVolumeRange method.
Returns
HRESULT
GetMasterVolumeLevelScalar()
Gets the master volume level of the audio stream that enters or leaves the audio endpoint device. The volume level is expressed as a normalized, audio-tapered value in the range from 0.0 to 1.0.
GetMasterVolumeLevelScalarNative(Single& level)
Gets the master volume level of the audio stream that enters or leaves the audio endpoint device. The volume level is expressed as a normalized, audio-tapered value in the range from 0.0 to 1.0.
public Int32 GetMasterVolumeLevelScalarNative(Single& level)
Parameters
level
Single&A float variable into which the method writes the volume level. The level is expressed as a normalized value in the range from 0.0 to 1.0.
Returns
HRESULT
GetMute()
Gets the muting state of the audio stream that enters or leaves the audio endpoint device.
GetMuteNative(NativeBool& mute)
Gets the muting state of the audio stream that enters or leaves the audio endpoint device.
public Int32 GetMuteNative(NativeBool& mute)
Parameters
mute
NativeBool&A Variable into which the method writes the muting state. If mute is true, the stream is muted. If false, the stream is not muted.
Returns
HRESULT
GetVolumeRange(Single& volumeMinDB, Single& volumeMaxDB, Single& volumeIncrementDB)
Gets the volume range, in decibels, of the audio stream that enters or leaves the audio endpoint device.
public void GetVolumeRange(Single& volumeMinDB, Single& volumeMaxDB, Single& volumeIncrementDB)
Parameters
volumeMinDB
Single&Minimum volume level in decibels. This value remains constant for the lifetime of the AudioEndpointVolume object instance.
volumeMaxDB
Single&Maximum volume level in decibels. This value remains constant for the lifetime of the AudioEndpointVolume object instance.
volumeIncrementDB
Single&Volume increment in decibels. This increment remains constant for the lifetime of the AudioEndpointVolume object instance.
GetVolumeRangeNative(Single& volumeMinDB, Single& volumeMaxDB, Single& volumeIncrementDB)
Gets the volume range, in decibels, of the audio stream that enters or leaves the audio endpoint device.
public Int32 GetVolumeRangeNative(Single& volumeMinDB, Single& volumeMaxDB, Single& volumeIncrementDB)
Parameters
volumeMinDB
Single&Minimum volume level in decibels. This value remains constant for the lifetime of the AudioEndpointVolume object instance.
volumeMaxDB
Single&Maximum volume level in decibels. This value remains constant for the lifetime of the AudioEndpointVolume object instance.
volumeIncrementDB
Single&Volume increment in decibels. This increment remains constant for the lifetime of the AudioEndpointVolume object instance.
Returns
HREUSLT
GetVolumeStepInfo(Int32& currentStep, Int32& stepCount)
Gets information about the current step in the volume range.
public void GetVolumeStepInfo(Int32& currentStep, Int32& stepCount)
Parameters
currentStep
Int32&A variable into which the method writes the current step index. This index is a value in the range from 0 to stepCount– 1, where 0 represents the minimum volume level and stepCount– 1 represents the maximum level.
stepCount
Int32&A variable into which the method writes the number of steps in the volume range. This number remains constant for the lifetime of the AudioEndpointVolume object instance.
GetVolumeStepInfoNative(Int32& currentStep, Int32& stepCount)
Gets information about the current step in the volume range.
public Int32 GetVolumeStepInfoNative(Int32& currentStep, Int32& stepCount)
Parameters
currentStep
Int32&A variable into which the method writes the current step index. This index is a value in the range from 0 to stepCount– 1, where 0 represents the minimum volume level and stepCount– 1 represents the maximum level.
stepCount
Int32&A variable into which the method writes the number of steps in the volume range. This number remains constant for the lifetime of the AudioEndpointVolume object instance.
Returns
HRESULT
QueryHardwareSupport()
Queries the audio endpoint device for its hardware-supported functions.
QueryHardwareSupportNative(EndpointHardwareSupportFlags& hardwareSupportMask)
Queries the audio endpoint device for its hardware-supported functions.
public Int32 QueryHardwareSupportNative(EndpointHardwareSupportFlags& hardwareSupportMask)
Parameters
hardwareSupportMask
EndpointHardwareSupportFlags&A variable into which the method writes a hardware support mask that indicates the hardware capabilities of the audio endpoint device.
Returns
HRESULT
RegisterControlChangeNotify(IAudioEndpointVolumeCallback notify)
Registers a client's notification callback interface.
public void RegisterControlChangeNotify(IAudioEndpointVolumeCallback notify)
Parameters
notify
IAudioEndpointVolumeCallbackThe callback instance that the client is registering for notification callbacks.
Remarks
When notifications are no longer needed, the client can call the UnregisterControlChangeNotify method to terminate the notifications.
RegisterControlChangeNotifyNative(IAudioEndpointVolumeCallback notify)
Registers a client's notification callback interface.
public Int32 RegisterControlChangeNotifyNative(IAudioEndpointVolumeCallback notify)
Parameters
notify
IAudioEndpointVolumeCallbackThe callback instance that the client is registering for notification callbacks.
Returns
HRESULT
Remarks
When notifications are no longer needed, the client can call the UnregisterControlChangeNotify method to terminate the notifications.
SetChannelVolumeLevel(Int32 channel, Single levelDB, Guid eventContext)
Sets the volume level, in decibels, of the specified channel of the audio stream that enters or leaves the audio endpoint device.
public void SetChannelVolumeLevel(Int32 channel, Single levelDB, Guid eventContext)
Parameters
levelDB
SingleThe new volume level in decibels. To obtain the range and granularity of the volume levels that can be set by this method, call the GetVolumeRange method.
eventContext
GuidEventContext which can be accessed in the event handler.
channel
Int32The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n–1.
SetChannelVolumeLevelNative(Int32 channel, Single levelDB, Guid eventContext)
Sets the volume level, in decibels, of the specified channel of the audio stream that enters or leaves the audio endpoint device.
public Int32 SetChannelVolumeLevelNative(Int32 channel, Single levelDB, Guid eventContext)
Parameters
levelDB
SingleThe new volume level in decibels. To obtain the range and granularity of the volume levels that can be set by this method, call the GetVolumeRange method.
eventContext
GuidEventContext which can be accessed in the event handler.
channel
Int32The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n–1.
Returns
HRESULT
SetChannelVolumeLevelScalar(Int32 channel, Single level, Guid eventContext)
Sets the normalized, audio-tapered volume level of the specified channel in the audio stream that enters or leaves the audio endpoint device.
public void SetChannelVolumeLevelScalar(Int32 channel, Single level, Guid eventContext)
Parameters
level
SingleThe volume level. The volume level is expressed as a normalized value in the range from 0.0 to 1.0.
eventContext
GuidEventContext which can be accessed in the event handler.
channel
Int32The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n–1.
SetChannelVolumeLevelScalarNative(Int32 channel, Single level, Guid eventContext)
Sets the normalized, audio-tapered volume level of the specified channel in the audio stream that enters or leaves the audio endpoint device.
public Int32 SetChannelVolumeLevelScalarNative(Int32 channel, Single level, Guid eventContext)
Parameters
level
SingleThe volume level. The volume level is expressed as a normalized value in the range from 0.0 to 1.0.
eventContext
GuidEventContext which can be accessed in the event handler.
channel
Int32The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n–1.
Returns
HRESULT
SetMasterVolumeLevel(Single levelDB, Guid eventContext)
Sets the master volume level, in decibels, of the audio stream that enters or leaves the audio endpoint device.
public void SetMasterVolumeLevel(Single levelDB, Guid eventContext)
Parameters
levelDB
SingleThe new master volume level in decibels. To obtain the range and granularity of the volume levels that can be set by this method, call the GetVolumeRange method.
eventContext
GuidEventContext which can be accessed in the event handler.
SetMasterVolumeLevelNative(Single levelDB, Guid eventContext)
Sets the master volume level, in decibels, of the audio stream that enters or leaves the audio endpoint device.
public Int32 SetMasterVolumeLevelNative(Single levelDB, Guid eventContext)
Parameters
levelDB
SingleThe new master volume level in decibels. To obtain the range and granularity of the volume levels that can be set by this method, call the GetVolumeRange method.
eventContext
GuidEventContext which can be accessed in the event handler.
Returns
HRESULT
SetMasterVolumeLevelScalar(Single level, Guid eventContext)
Sets the master volume level of the audio stream that enters or leaves the audio endpoint device. The volume level is expressed as a normalized, audio-tapered value in the range from 0.0 to 1.0.
public void SetMasterVolumeLevelScalar(Single level, Guid eventContext)
Parameters
level
SingleThe new master volume level. The level is expressed as a normalized value in the range from 0.0 to 1.0.
eventContext
GuidEventContext which can be accessed in the event handler.
SetMasterVolumeLevelScalarNative(Single level, Guid eventContext)
Sets the master volume level of the audio stream that enters or leaves the audio endpoint device. The volume level is expressed as a normalized, audio-tapered value in the range from 0.0 to 1.0.
public Int32 SetMasterVolumeLevelScalarNative(Single level, Guid eventContext)
Parameters
level
SingleThe new master volume level. The level is expressed as a normalized value in the range from 0.0 to 1.0.
eventContext
GuidEventContext which can be accessed in the event handler.
Returns
HRESULT
SetMute(Boolean mute, Guid eventContext)
Sets the muting state of the audio stream that enters or leaves the audio endpoint device.
SetMuteNative(NativeBool mute, Guid eventContext)
Sets the muting state of the audio stream that enters or leaves the audio endpoint device.
public Int32 SetMuteNative(NativeBool mute, Guid eventContext)
Parameters
mute
NativeBoolTrue mutes the stream. False turns off muting.
eventContext
GuidEventContext which can be accessed in the event handler.
Returns
HRESULT
UnregisterControlChangeNotify(IAudioEndpointVolumeCallback notify)
Deletes the registration of a client's notification callback interface that the client registered in a previous call to the RegisterControlChangeNotify method.
public void UnregisterControlChangeNotify(IAudioEndpointVolumeCallback notify)
Parameters
notify
IAudioEndpointVolumeCallbackThe callback instance to unregister. The client passed this same object to the endpoint volume object in the previous call to the RegisterControlChangeNotify method.
UnregisterControlChangeNotifyNative(IAudioEndpointVolumeCallback notify)
Deletes the registration of a client's notification callback interface that the client registered in a previous call to the RegisterControlChangeNotify method.
public Int32 UnregisterControlChangeNotifyNative(IAudioEndpointVolumeCallback notify)
Parameters
notify
IAudioEndpointVolumeCallbackThe callback instance to unregister. The client passed this same object to the endpoint volume object in the previous call to the RegisterControlChangeNotify method.
Returns
HRESULT
VolumeStepDown(Guid eventContext)
Decrements, by one step, the volume level of the audio stream that enters or leaves the audio endpoint device.
VolumeStepDownNative(Guid eventContext)
Decrements, by one step, the volume level of the audio stream that enters or leaves the audio endpoint device.
public Int32 VolumeStepDownNative(Guid eventContext)
Parameters
eventContext
GuidEventContext which can be accessed in the event handler.
Returns
HRESULT
VolumeStepUp(Guid eventContext)
Increments, by one step, the volume level of the audio stream that enters or leaves the audio endpoint device.
VolumeStepUpNative(Guid eventContext)
Increments, by one step, the volume level of the audio stream that enters or leaves the audio endpoint device.
public Int32 VolumeStepUpNative(Guid eventContext)
Parameters
eventContext
GuidEventContext which can be accessed in the event handler.
Returns
HRESULT
ChannelCount
Gets the number of available channels.
public Int32 ChannelCount { get; }
Channels
Gets all available channels.
public ReadOnlyCollection<AudioEndpointVolumeChannel> Channels { get; }
MasterVolumeLevel
Gets or sets the MasterVolumeLevel in decibel.
public Single MasterVolumeLevel { get; set; }
MasterVolumeLevelScalar
Gets or sets the MasterVolumeLevel as a normalized value in the range from 0.0 to 1.0.
public Single MasterVolumeLevelScalar { get; set; }
RegisteredCallbacks
Gets all registered IAudioEndpointVolumeCallback.
public ReadOnlyCollection<IAudioEndpointVolumeCallback> RegisteredCallbacks { get; }