using System; using System.Runtime.InteropServices; using Vanara.InteropServices; namespace Vanara.PInvoke { /// Functions, structures and constants from Windows Core Audio Api. public static partial class CoreAudio { /// The ENDPOINT_HARDWARE_SUPPORT_XXX constants are hardware support flags for an audio endpoint device. /// /// /// The IAudioEndpointVolume::QueryHardwareSupport and IAudioMeterInformation::QueryHardwareSupport methods use the /// ENDPOINT_HARDWARE_SUPPORT_XXX constants. /// /// /// A hardware support mask indicates which functions an audio endpoint device implements in hardware. The mask can be either 0 or /// the bitwise-OR combination of one or more ENDPOINT_HARDWARE_SUPPORT_XXX constants. If a bit that corresponds to a particular /// ENDPOINT_HARDWARE_SUPPORT_XXX constant is set in the mask, then the meaning is that the function represented by that constant is /// implemented in hardware by the device. /// /// // https://docs.microsoft.com/en-us/windows/win32/coreaudio/endpoint-hardware-support-xxx-constants [PInvokeData("endpointvolume.h", MSDNShortId = "54032f75-2287-4589-bda5-e005ee077c41")] [Flags] public enum ENDPOINT_HARDWARE_SUPPORT { /// The audio endpoint device supports a hardware volume control. ENDPOINT_HARDWARE_SUPPORT_VOLUME = 0x00000001, /// The audio endpoint device supports a hardware mute control. ENDPOINT_HARDWARE_SUPPORT_MUTE = 0x00000002, /// The audio endpoint device supports a hardware peak meter. ENDPOINT_HARDWARE_SUPPORT_METER = 0x00000004, } /// /// /// The IAudioEndpointVolume interface represents the volume controls on the audio stream to or from an audio endpoint /// device. A client obtains a reference to the IAudioEndpointVolume interface of an endpoint device by calling the /// IMMDevice::Activate method with parameter iid set to REFIID IID_IAudioEndpointVolume. /// /// /// Audio applications that use the MMDevice API and WASAPI typically use the ISimpleAudioVolume interface to manage stream volume /// levels on a per-session basis. In rare cases, a specialized audio application might require the use of the /// IAudioEndpointVolume interface to control the master volume level of an audio endpoint device. A client of /// IAudioEndpointVolume must take care to avoid the potentially disruptive effects on other audio applications of altering /// the master volume levels of audio endpoint devices. Typically, the user has exclusive control over the master volume levels /// through the Windows volume-control program, Sndvol.exe. /// /// /// If the adapter device that streams audio data to or from the endpoint device has hardware volume and mute controls, the /// IAudioEndpointVolume interface uses those controls to manage the volume and mute settings of the audio stream. If the /// audio device lacks a hardware volume control for the stream, the audio engine automatically implements volume and mute controls /// in software. /// /// /// For applications that manage shared-mode streams to and from endpoint devices, the behavior of the IAudioEndpointVolume /// is different for rendering streams and capture streams. /// /// /// For a shared-mode rendering stream, the endpoint volume control that the client accesses through the IAudioEndpointVolume /// interface operates independently of the per-session volume controls that the ISimpleAudioVolume and IChannelAudioVolume /// interfaces implement. Thus, the volume level of the rendering stream results from the combined effects of the endpoint volume /// control and per-session controls. /// /// /// For a shared-mode capture stream, the per-session volume controls that the ISimpleAudioVolume and /// IChannelAudioVolume interfaces implement are tied directly to the endpoint volume control implemented by the /// IAudioEndpointVolume interface. Changing the per-session volume control through the methods in the /// ISimpleAudioVolume and IChannelAudioVolume interfaces changes the setting of the IAudioEndpointVolume /// interface's volume control, and the reverse is also true. The volume levels represented by each of the interfaces correspond to /// each other as follows: /// /// /// /// /// For each channel in a stream, IAudioEndpointVolume provides audio-tapered volume levels expressed in decibels (dB), that /// are mapped to normalized values in the range from 0.0 (minimum volume) to 1.0 (maximum volume). The possible range is dependent /// on the audio driver. See IAudioEndpointVolume::GetVolumeRange for details. /// /// /// /// /// The session volume represented by ISimpleAudioVolume::GetMasterVolume is the scalar value ranging from 0.0 to 1.0 that /// corresponds to the highest volume setting across the various channels. So, for example, if the left channel is set to 0.8, and /// the right channel is set to 0.4, then ISimpleAudioVolume::GetMasterVolume will return 0.8. /// /// /// /// /// When the per-channel volume level is controlled through the methods in the IChannelAudioVolume interface, the scalar indicating /// volume is always relative to the session volume. This means that the channel or channels with the highest volume has a volume of /// 1.0. Given the example of two channels, set to volumes of 0.8 and 0.4 by IAudioEndpointVolume::SetChannelVolumeLevelScalar, /// IChannelAudioVolume::GetChannelVolume will indicate volumes of 1.0 and 0.5. /// /// /// /// /// Note Clients of the EndpointVolume API should not rely on the preceding behavior because it might change in future releases. /// /// /// If a device has hardware volume and mute controls, changes made to the device's volume and mute settings through the /// IAudioEndpointVolume interface affect the volume level in both shared mode and exclusive mode. If a device lacks hardware /// volume and mute controls, changes made to the software volume and mute controls through the IAudioEndpointVolume /// interface affect the volume level in shared mode, but not in exclusive mode. In exclusive mode, the client and the device /// exchange audio data directly, bypassing the software controls. However, the software controls are persistent, and volume changes /// made while the device operates in exclusive mode take effect when the device switches to shared-mode operation. /// /// /// To determine whether a device has hardware volume and mute controls, call the IAudioEndpointVolume::QueryHardwareSupport method. /// /// /// The methods of the IAudioEndpointVolume interface enable the client to express volume levels either in decibels or as /// normalized, audio-tapered values. In the latter case, a volume level is expressed as a floating-point value in the normalized /// range from 0.0 (minimum volume) to 1.0 (maximum volume). Within this range, the relationship of the normalized volume level to /// the attenuation of signal amplitude is described by a nonlinear, audio-tapered curve. For more information about audio-tapered /// curves, see Audio-Tapered Volume Controls. /// /// /// In addition, to conveniently support volume sliders in user interfaces, the IAudioEndpointVolume interface enables /// clients to set and get volume levels that are expressed as discrete values or "steps". The steps are uniformly distributed over /// a nonlinear, audio-tapered curve. If the range contains n steps, the steps are numbered from 0 to n– 1, where step 0 represents /// the minimum volume level and step n– 1 represents the maximum. /// /// For a code example that uses the IAudioEndpointVolume interface, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nn-endpointvolume-iaudioendpointvolume [PInvokeData("endpointvolume.h", MSDNShortId = "5e3e7ffc-8822-4b1b-b9af-206ec1e767e2")] [ComImport, Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioEndpointVolume { /// The RegisterControlChangeNotify method registers a client's notification callback interface. /// /// Pointer to the IAudioEndpointVolumeCallback interface that the client is registering for notification callbacks. If the /// RegisterControlChangeNotify method succeeds, it calls the AddRef method on the client's /// IAudioEndpointVolumeCallback interface. /// /// /// /// This method registers an IAudioEndpointVolumeCallback interface to be called by the system when the volume level or muting /// state of an endpoint changes. The caller implements the IAudioEndpointVolumeCallback interface. /// /// /// When notifications are no longer needed, the client can call the IAudioEndpointVolume::UnregisterControlChangeNotify method /// to terminate the notifications. /// /// /// Before the client releases its final reference to the IAudioEndpointVolumeCallback interface, it should call /// UnregisterControlChangeNotify to unregister the interface. Otherwise, the application leaks the resources held by the /// IAudioEndpointVolumeCallback and IAudioEndpointVolume objects. Note that RegisterControlChangeNotify calls the /// client's IAudioEndpointVolumeCallback::AddRef method, and UnregisterControlChangeNotify calls the /// IAudioEndpointVolumeCallback::Release method. If the client errs by releasing its reference to the /// IAudioEndpointVolumeCallback interface before calling UnregisterControlChangeNotify, the /// IAudioEndpointVolume object never releases its reference to the IAudioEndpointVolumeCallback interface. For /// example, a poorly designed IAudioEndpointVolumeCallback implementation might call /// UnregisterControlChangeNotify from the destructor for the IAudioEndpointVolumeCallback object. In this case, /// the client will not call UnregisterControlChangeNotify until the IAudioEndpointVolume object releases its /// reference to the IAudioEndpointVolumeCallback interface, and the IAudioEndpointVolume object will not release /// its reference to the IAudioEndpointVolumeCallback interface until the client calls /// UnregisterControlChangeNotify. For more information about the AddRef and Release methods, see the /// discussion of the IUnknown interface in the Windows SDK documentation. /// /// /// In addition, the client should call UnregisterControlChangeNotify before releasing the final reference to the /// IAudioEndpointVolume object. Otherwise, the object leaks the storage that it allocated to hold the registration information. /// After registering a notification interface, the client continues to receive notifications for only as long as the /// IAudioEndpointVolume object exists. /// /// For a code example that calls RegisterControlChangeNotify, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-registercontrolchangenotify // HRESULT RegisterControlChangeNotify( IAudioEndpointVolumeCallback *pNotify ); void RegisterControlChangeNotify([In] IAudioEndpointVolumeCallback pNotify); /// /// The UnregisterControlChangeNotify method deletes the registration of a client's notification callback interface that /// the client registered in a previous call to the IAudioEndpointVolume::RegisterControlChangeNotify method. /// /// /// Pointer to the client's IAudioEndpointVolumeCallback interface. The client passed this same interface pointer to the /// endpoint volume object in a previous call to the IAudioEndpointVolume::RegisterControlChangeNotify method. If the /// UnregisterControlChangeNotify method succeeds, it calls the Release method on the client's /// IAudioEndpointVolumeCallback interface. /// /// /// /// Before the client releases its final reference to the IAudioEndpointVolumeCallback interface, it should call /// UnregisterControlChangeNotify to unregister the interface. Otherwise, the application leaks the resources held by the /// IAudioEndpointVolumeCallback and IAudioEndpointVolume objects. Note that the /// IAudioEndpointVolume::RegisterControlChangeNotify method calls the client's IAudioEndpointVolumeCallback::AddRef method, and /// UnregisterControlChangeNotify calls the IAudioEndpointVolumeCallback::Release method. If the client errs by releasing /// its reference to the IAudioEndpointVolumeCallback interface before calling UnregisterControlChangeNotify, the /// IAudioEndpointVolume object never releases its reference to the IAudioEndpointVolumeCallback interface. For /// example, a poorly designed IAudioEndpointVolumeCallback implementation might call /// UnregisterControlChangeNotify from the destructor for the IAudioEndpointVolumeCallback object. In this case, /// the client will not call UnregisterControlChangeNotify until the IAudioEndpointVolume object releases its /// reference to the IAudioEndpointVolumeCallback interface, and the IAudioEndpointVolume object will not release /// its reference to the IAudioEndpointVolumeCallback interface until the client calls /// UnregisterControlChangeNotify. For more information about the AddRef and Release methods, see the /// discussion of the IUnknown interface in the Windows SDK documentation. /// /// For a code example that calls UnregisterControlChangeNotify, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-unregistercontrolchangenotify // HRESULT UnregisterControlChangeNotify( IAudioEndpointVolumeCallback *pNotify ); void UnregisterControlChangeNotify([In] IAudioEndpointVolumeCallback pNotify); /// /// The GetChannelCount method gets a count of the channels in the audio stream that enters or leaves the audio endpoint device. /// /// A UINT variable into which the method writes the channel count. // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getchannelcount // HRESULT GetChannelCount( UINT *pnChannelCount ); uint GetChannelCount(); /// /// The SetMasterVolumeLevel method sets the master volume level, in decibels, of the audio stream that enters or leaves /// the audio endpoint device. /// /// /// The 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 IAudioEndpointVolume::GetVolumeRange method. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// SetMasterVolumeLevel call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the notification routine /// receives the context GUID value GUID_NULL. /// /// /// If volume level fLevelDB falls outside of the volume range reported by the IAudioEndpointVolume::GetVolumeRange /// method, the SetMasterVolumeLevel call fails and returns error code E_INVALIDARG. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-setmastervolumelevel // HRESULT SetMasterVolumeLevel( float fLevelDB, LPCGUID pguidEventContext ); void SetMasterVolumeLevel([In] float fLevelDB, in Guid pguidEventContext); /// /// The SetMasterVolumeLevelScalar method 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. /// /// /// The new master volume level. The level is expressed as a normalized value in the range from 0.0 to 1.0. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// SetMasterVolumeLevelScalar call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the notification routine /// receives the context GUID value GUID_NULL. /// /// /// /// The volume level is normalized to the range from 0.0 to 1.0, where 0.0 is the minimum volume level and 1.0 is the maximum /// level. Within this range, the relationship of the normalized volume level to the attenuation of signal amplitude is /// described by a nonlinear, audio-tapered curve. Note that the shape of the curve might change in future versions of Windows. /// For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// /// The normalized volume levels that are passed to this method are suitable to represent the positions of volume controls in /// application windows and on-screen displays. /// /// For a code example that calls SetMasterVolumeLevelScalar, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-setmastervolumelevelscalar // HRESULT SetMasterVolumeLevelScalar( float fLevel, LPCGUID pguidEventContext ); void SetMasterVolumeLevelScalar([In] float fLevel, in Guid pguidEventContext); /// /// The GetMasterVolumeLevel method gets the master volume level, in decibels, of the audio stream that enters or leaves /// the audio endpoint device. /// /// /// The master volume level. This parameter points to 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 IAudioEndpointVolume::GetVolumeRange method. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getmastervolumelevel // HRESULT GetMasterVolumeLevel( float *pfLevelDB ); float GetMasterVolumeLevel(); /// /// The GetMasterVolumeLevelScalar method 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. /// /// /// The master volume level. This parameter points to 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. /// /// /// /// The volume level is normalized to the range from 0.0 to 1.0, where 0.0 is the minimum volume level and 1.0 is the maximum /// level. Within this range, the relationship of the normalized volume level to the attenuation of signal amplitude is /// described by a nonlinear, audio-tapered curve. Note that the shape of the curve might change in future versions of Windows. /// For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// /// The normalized volume levels that are retrieved by this method are suitable to represent the positions of volume controls in /// application windows and on-screen displays. /// /// For a code example that calls GetMasterVolumeLevelScalar, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getmastervolumelevelscalar // HRESULT GetMasterVolumeLevelScalar( float *pfLevel ); float GetMasterVolumeLevelScalar(); /// /// The SetChannelVolumeLevel method sets the volume level, in decibels, of the specified channel of the audio stream /// that enters or leaves the audio endpoint device. /// /// /// The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n– 1. To obtain the number /// of channels, call the IAudioEndpointVolume::GetChannelCount method. /// /// /// The new volume level in decibels. To obtain the range and granularity of the volume levels that can be set by this method, /// call the IAudioEndpointVolume::GetVolumeRange method. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// SetChannelVolumeLevel call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the notification routine /// receives the context GUID value GUID_NULL. /// /// /// If volume level fLevelDB falls outside of the volume range reported by the IAudioEndpointVolume::GetVolumeRange /// method, the SetChannelVolumeLevel call fails and returns error code E_INVALIDARG. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-setchannelvolumelevel // HRESULT SetChannelVolumeLevel( UINT nChannel, float fLevelDB, LPCGUID pguidEventContext ); void SetChannelVolumeLevel([In] uint nChannel, float fLevelDB, in Guid pguidEventContext); /// /// The SetChannelVolumeLevelScalar method sets the normalized, audio-tapered volume level of the specified channel in /// the audio stream that enters or leaves the audio endpoint device. /// /// /// The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n– 1. To obtain the number /// of channels, call the IAudioEndpointVolume::GetChannelCount method. /// /// The volume level. The volume level is expressed as a normalized value in the range from 0.0 to 1.0. /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// SetChannelVolumeLevelScalar call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the notification routine /// receives the context GUID value GUID_NULL. /// /// /// /// The volume level is normalized to the range from 0.0 to 1.0, where 0.0 is the minimum volume level and 1.0 is the maximum /// level. Within this range, the relationship of the normalized volume level to the attenuation of signal amplitude is /// described by a nonlinear, audio-tapered curve. Note that the shape of the curve might change in future versions of Windows. /// For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// /// The normalized volume levels that are passed to this method are suitable to represent the positions of volume controls in /// application windows and on-screen displays. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-setchannelvolumelevelscalar // HRESULT SetChannelVolumeLevelScalar( UINT nChannel, float fLevel, LPCGUID pguidEventContext ); void SetChannelVolumeLevelScalar([In] uint nChannel, float fLevel, in Guid pguidEventContext); /// /// The GetChannelVolumeLevel method gets the volume level, in decibels, of the specified channel in the audio stream /// that enters or leaves the audio endpoint device. /// /// /// The channel number. If the audio stream has n channels, the channels are numbered from 0 to n– 1. To obtain the number of /// channels in the stream, call the IAudioEndpointVolume::GetChannelCount method. /// /// /// 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 IAudioEndpointVolume::GetVolumeRange method. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getchannelvolumelevel // HRESULT GetChannelVolumeLevel( UINT nChannel, float *pfLevelDB ); float GetChannelVolumeLevel([In] uint nChannel); /// /// The GetChannelVolumeLevelScalar method gets the normalized, audio-tapered volume level of the specified channel of /// the audio stream that enters or leaves the audio endpoint device. /// /// /// The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n– 1. To obtain the number /// of channels, call the IAudioEndpointVolume::GetChannelCount method. /// /// /// 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. /// /// /// /// The volume level is normalized to the range from 0.0 to 1.0, where 0.0 is the minimum volume level and 1.0 is the maximum /// level. Within this range, the relationship of the normalized volume level to the attenuation of signal amplitude is /// described by a nonlinear, audio-tapered curve. Note that the shape of the curve might change in future versions of Windows. /// For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// /// The normalized volume levels that are retrieved by this method are suitable to represent the positions of volume controls in /// application windows and on-screen displays. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getchannelvolumelevelscalar // HRESULT GetChannelVolumeLevelScalar( UINT nChannel, float *pfLevel ); float GetChannelVolumeLevelScalar([In] uint nChannel); /// /// The SetMute method sets the muting state of the audio stream that enters or leaves the audio endpoint device. /// /// /// The new muting state. If bMute is TRUE, the method mutes the stream. If FALSE, the method turns off muting. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// SetMute call changes the muting state of the endpoint, all clients that have registered IAudioEndpointVolumeCallback /// interfaces with that endpoint will receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the notification routine receives the context GUID value GUID_NULL. /// /// For a code example that calls SetMute, see Endpoint Volume Controls. // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-setmute HRESULT // SetMute( BOOL bMute, LPCGUID pguidEventContext ); void SetMute([In] [MarshalAs(UnmanagedType.Bool)] bool bMute, in Guid pguidEventContext); /// /// The GetMute method gets the muting state of the audio stream that enters or leaves the audio endpoint device. /// /// /// A BOOL variable into which the method writes the muting state. If *pbMute is TRUE, the stream is muted. If /// FALSE, the stream is not muted. /// /// For a code example that calls GetMute, see Endpoint Volume Controls. // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getmute HRESULT // GetMute( BOOL *pbMute ); [return: MarshalAs(UnmanagedType.Bool)] bool GetMute(); /// The GetVolumeStepInfo method gets information about the current step in the volume range. /// /// Pointer to a UINT variable into which the method writes the current step index. This index is a value in the range /// from 0 to *pStepCount– 1, where 0 represents the minimum volume level and *pStepCount– 1 represents the maximum level. /// /// /// Pointer to a UINT variable into which the method writes the number of steps in the volume range. This number remains /// constant for the lifetime of the IAudioEndpointVolume interface instance. /// /// /// /// This method represents the volume level of the audio stream that enters or leaves the audio endpoint device as an index or /// "step" in a range of discrete volume levels. Output value *pnStepCount is the number of steps in the range. Output value /// *pnStep is the step index of the current volume level. If the number of steps is n = *pnStepCount, then step index *pnStep /// can assume values from 0 (minimum volume) to n – 1 (maximum volume). /// /// /// Over the range from 0 to n – 1, successive intervals between adjacent steps do not necessarily represent uniform volume /// increments in either linear signal amplitude or decibels. In Windows Vista, GetVolumeStepInfo defines the /// relationship of index to volume level (signal amplitude) to be an audio-tapered curve. Note that the shape of the curve /// might change in future versions of Windows. For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// /// Audio applications can call the IAudioEndpointVolume::VolumeStepUp and IAudioEndpointVolume::VolumeStepDown methods to /// increase or decrease the volume level by one interval. Either method first calculates the idealized volume level that /// corresponds to the next point on the audio-tapered curve. Next, the method selects the endpoint volume setting that is the /// best approximation to the idealized level. To obtain the range and granularity of the endpoint volume settings, call the /// IEndpointVolume::GetVolumeRange method. If the audio endpoint device implements a hardware volume control, /// GetVolumeRange describes the hardware volume settings. Otherwise, the EndpointVolume API implements the endpoint /// volume control in software, and GetVolumeRange describes the volume settings of the software-implemented control. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getvolumestepinfo // HRESULT GetVolumeStepInfo( UINT *pnStep, UINT *pnStepCount ); void GetVolumeStepInfo(out uint pnStep, out uint pnStepCount); /// /// The VolumeStepUp method increments, by one step, the volume level of the audio stream that enters or leaves the audio /// endpoint device. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// VolumeStepUp call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the client's notification /// method receives a NULL context pointer. /// /// /// /// To obtain the current volume step and the total number of steps in the volume range, call the /// IAudioEndpointVolume::GetVolumeStepInfo method. /// /// /// If the volume level is already at the highest step in the volume range, the call to VolumeStepUp has no effect and /// returns status code S_OK. /// /// /// Successive intervals between adjacent steps do not necessarily represent uniform volume increments in either linear signal /// amplitude or decibels. In Windows Vista, VolumeStepUp defines the relationship of step index to volume level (signal /// amplitude) to be an audio-tapered curve. Note that the shape of the curve might change in future versions of Windows. For /// more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-volumestepup HRESULT // VolumeStepUp( LPCGUID pguidEventContext ); void VolumeStepUp(in Guid pguidEventContext); /// /// The VolumeStepDown method decrements, by one step, the volume level of the audio stream that enters or leaves the /// audio endpoint device. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// VolumeStepDown call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the client's notification /// method receives a NULL context pointer. /// /// /// /// To obtain the current volume step and the total number of steps in the volume range, call the /// IAudioEndpointVolume::GetVolumeStepInfo method. /// /// /// If the volume level is already at the lowest step in the volume range, the call to VolumeStepDown has no effect and /// returns status code S_OK. /// /// /// Successive intervals between adjacent steps do not necessarily represent uniform volume increments in either linear signal /// amplitude or decibels. In Windows Vista, VolumeStepDown defines the relationship of step index to volume level /// (signal amplitude) to be an audio-tapered curve. Note that the shape of the curve might change in future versions of /// Windows. For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-volumestepdown // HRESULT VolumeStepDown( LPCGUID pguidEventContext ); void VolumeStepDown(in Guid pguidEventContext); /// The QueryHardwareSupport method queries the audio endpoint device for its hardware-supported functions. /// /// A DWORD variable into which the method writes a hardware support mask that indicates the hardware capabilities of the /// audio endpoint device. The method can set the mask to 0 or to the bitwise-OR combination of one or more /// ENDPOINT_HARDWARE_SUPPORT_XXX constants. /// /// /// This method indicates whether the audio endpoint device implements the following functions in hardware: /// /// /// Volume control /// /// /// Mute control /// /// /// Peak meter /// /// /// /// The system automatically substitutes a software implementation for any function in the preceding list that the endpoint /// device does not implement in hardware. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-queryhardwaresupport // HRESULT QueryHardwareSupport( DWORD *pdwHardwareSupportMask ); ENDPOINT_HARDWARE_SUPPORT QueryHardwareSupport(); /// /// The GetVolumeRange method gets the volume range, in decibels, of the audio stream that enters or leaves the audio /// endpoint device. /// /// /// Pointer to the minimum volume level. This parameter points to a float variable into which the method writes the /// minimum volume level in decibels. This value remains constant for the lifetime of the IAudioEndpointVolume interface instance. /// /// /// Pointer to the maximum volume level. This parameter points to a float variable into which the method writes the /// maximum volume level in decibels. This value remains constant for the lifetime of the IAudioEndpointVolume interface instance. /// /// /// Pointer to the volume increment. This parameter points to a float variable into which the method writes the volume /// increment in decibels. This increment remains constant for the lifetime of the IAudioEndpointVolume interface instance. /// /// /// /// The volume range from vmin = *pfLevelMinDB to vmax = *pfLevelMaxDB is divided into n uniform intervals of size vinc = /// *pfVolumeIncrementDB, where /// /// n = (vmax – vmin) / vinc. /// /// The values vmin, vmax, and vinc are measured in decibels. The client can set the volume level to one of n + 1 discrete /// values in the range from vmin to vmax. /// /// /// The IAudioEndpointVolume::SetChannelVolumeLevel and IAudioEndpointVolume::SetMasterVolumeLevel methods accept only volume /// levels in the range from vmin to vmax. If the caller specifies a volume level outside of this range, the method fails and /// returns E_INVALIDARG. If the caller specifies a volume level that falls between two steps in the volume range, the method /// sets the endpoint volume level to the step that lies closest to the requested volume level and returns S_OK. However, a /// subsequent call to IAudioEndpointVolume::GetChannelVolumeLevel or IAudioEndpointVolume::GetMasterVolumeLevel retrieves the /// volume level requested by the previous call to SetChannelVolumeLevel or SetMasterVolumeLevel, not the step value. /// /// /// If the volume control is implemented in hardware, GetVolumeRange describes the range and granularity of the hardware /// volume settings. In contrast, the steps that are reported by the IEndpointVolume::GetVolumeStepInfo method correspond to /// points on an audio-tapered curve that are calculated in software by the IEndpointVolume::VolumeStepDown and /// IEndpointVolume::VolumeStepUp methods. Either method first calculates the idealized volume level that corresponds to the /// next point on the curve. Next, the method selects the hardware volume setting that is the best approximation to the /// idealized level. For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getvolumerange // HRESULT GetVolumeRange( float *pflVolumeMindB, float *pflVolumeMaxdB, float *pflVolumeIncrementdB ); void GetVolumeRange(out float pflVolumeMindB, out float pflVolumeMaxdB, out float pflVolumeIncrementdB); } /// /// /// The IAudioEndpointVolumeCallback interface provides notifications of changes in the volume level and muting state of an /// audio endpoint device. Unlike the other interfaces in this section, which are implemented by the WASAPI system component, an /// EndpointVolume API client implements the IAudioEndpointVolumeCallback interface. To receive event notifications, the /// client passes a pointer to its IAudioEndpointVolumeCallback interface to the /// IAudioEndpointVolume::RegisterControlChangeNotify method. /// /// /// After registering its IAudioEndpointVolumeCallback interface, the client receives event notifications in the form of /// callbacks through the OnNotify method in the interface. These event notifications occur when one of the following methods /// causes a change in the volume level or muting state of an endpoint device: /// /// /// /// IAudioEndpointVolume::SetChannelVolumeLevel /// /// /// IAudioEndpointVolume::SetChannelVolumeLevelScalar /// /// /// IAudioEndpointVolume::SetMasterVolumeLevel /// /// /// IAudioEndpointVolume::SetMasterVolumeLevelScalar /// /// /// IAudioEndpointVolume::SetMute /// /// /// IAudioEndpointVolume::VolumeStepDown /// /// /// IAudioEndpointVolume::VolumeStepUp /// /// /// /// If an audio endpoint device implements hardware volume and mute controls, the IAudioEndpointVolume interface uses the /// hardware controls to manage the device's volume. Otherwise, the IAudioEndpointVolume interface implements volume and mute /// controls in software, transparently to the client. /// /// /// If a device has hardware volume and mute controls, changes made to the volume and mute settings through the methods in the /// preceding list affect the device's volume in both shared mode and exclusive mode. If a device lacks hardware volume and mute /// controls, changes made to the software volume and mute controls through these methods affect the device's volume in shared mode, /// but not in exclusive mode. In exclusive mode, the client and the device exchange audio data directly, bypassing the software /// controls. However, changes made to the software controls through these methods generate event notifications regardless of /// whether the device is operating in shared mode or in exclusive mode. Changes made to the software volume and mute controls while /// the device operates in exclusive mode take effect when the device switches to shared mode. /// /// /// To determine whether a device has hardware volume and mute controls, call the IAudioEndpointVolume::QueryHardwareSupport method. /// /// In implementing the IAudioEndpointVolumeCallback interface, the client should observe these rules to avoid deadlocks: /// /// /// /// The methods in the interface must be nonblocking. The client should never wait on a synchronization object during an event callback. /// /// /// /// The client should never call the IAudioEndpointVolume::UnregisterControlChangeNotify method during an event callback. /// /// /// The client should never release the final reference on an EndpointVolume API object during an event callback. /// /// /// For a code example that implements the IAudioEndpointVolumeCallback interface, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nn-endpointvolume-iaudioendpointvolumecallback [PInvokeData("endpointvolume.h", MSDNShortId = "0b631d1b-f89c-4789-a09c-875b24a48a89")] [ComImport, Guid("657804FA-D6AD-4496-8A60-352752AF4F89"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioEndpointVolumeCallback { /// /// The OnNotify method notifies the client that the volume level or muting state of the audio endpoint device has changed. /// /// Pointer to the volume-notification data. This parameter points to a structure of type AUDIO_VOLUME_NOTIFICATION_DATA. /// If the method succeeds, it returns S_OK. If it fails, it returns an error code. /// /// /// The pNotify parameter points to a structure that describes the volume change event that initiated the call to /// OnNotify. This structure contains an event-context GUID. This GUID enables a client to distinguish between a volume /// (or muting) change that it initiated and one that some other client initiated. When calling an IAudioEndpointVolume method /// that changes the volume level of the stream, a client passes in a pointer to an event-context GUID that its implementation /// of the OnNotify method can recognize. The structure pointed to by pNotify contains this context GUID. If the client /// that changes the volume level supplies a NULL pointer value for the pointer to the event-context GUID, the value of /// the event-context GUID in the structure pointed to by pNotify is GUID_NULL. /// /// /// The Windows 7, the system's volume user interface does not specify GUID_NULL when it changes the volume in the system. A /// third-party OSD application can differentiate between master volume control changes that result from the system's volume /// user interface, and other volume changes such as changes from the built-in volume control handler. /// /// For a code example that implements the OnNotify method, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolumecallback-onnotify // HRESULT OnNotify( PAUDIO_VOLUME_NOTIFICATION_DATA pNotify ); [PreserveSig] HRESULT OnNotify([In] IntPtr pNotify); } /// /// The IAudioEndpointVolumeEx interface provides volume controls on the audio stream to or from a device endpoint. /// /// A client obtains a reference to the IAudioEndpointVolumeEx interface of an endpoint device by calling the /// IMMDevice::Activate method with parameter iid set to REFIID IID_IAudioEndpointVolumeEx. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nn-endpointvolume-iaudioendpointvolumeex [ComImport, Guid("66E11784-F695-4F28-A505-A7080081A78F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioEndpointVolumeEx : IAudioEndpointVolume { /// The RegisterControlChangeNotify method registers a client's notification callback interface. /// /// Pointer to the IAudioEndpointVolumeCallback interface that the client is registering for notification callbacks. If the /// RegisterControlChangeNotify method succeeds, it calls the AddRef method on the client's /// IAudioEndpointVolumeCallback interface. /// /// /// /// This method registers an IAudioEndpointVolumeCallback interface to be called by the system when the volume level or muting /// state of an endpoint changes. The caller implements the IAudioEndpointVolumeCallback interface. /// /// /// When notifications are no longer needed, the client can call the IAudioEndpointVolume::UnregisterControlChangeNotify method /// to terminate the notifications. /// /// /// Before the client releases its final reference to the IAudioEndpointVolumeCallback interface, it should call /// UnregisterControlChangeNotify to unregister the interface. Otherwise, the application leaks the resources held by the /// IAudioEndpointVolumeCallback and IAudioEndpointVolume objects. Note that RegisterControlChangeNotify calls the /// client's IAudioEndpointVolumeCallback::AddRef method, and UnregisterControlChangeNotify calls the /// IAudioEndpointVolumeCallback::Release method. If the client errs by releasing its reference to the /// IAudioEndpointVolumeCallback interface before calling UnregisterControlChangeNotify, the /// IAudioEndpointVolume object never releases its reference to the IAudioEndpointVolumeCallback interface. For /// example, a poorly designed IAudioEndpointVolumeCallback implementation might call /// UnregisterControlChangeNotify from the destructor for the IAudioEndpointVolumeCallback object. In this case, /// the client will not call UnregisterControlChangeNotify until the IAudioEndpointVolume object releases its /// reference to the IAudioEndpointVolumeCallback interface, and the IAudioEndpointVolume object will not release /// its reference to the IAudioEndpointVolumeCallback interface until the client calls /// UnregisterControlChangeNotify. For more information about the AddRef and Release methods, see the /// discussion of the IUnknown interface in the Windows SDK documentation. /// /// /// In addition, the client should call UnregisterControlChangeNotify before releasing the final reference to the /// IAudioEndpointVolume object. Otherwise, the object leaks the storage that it allocated to hold the registration information. /// After registering a notification interface, the client continues to receive notifications for only as long as the /// IAudioEndpointVolume object exists. /// /// For a code example that calls RegisterControlChangeNotify, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-registercontrolchangenotify // HRESULT RegisterControlChangeNotify( IAudioEndpointVolumeCallback *pNotify ); new void RegisterControlChangeNotify([In] IAudioEndpointVolumeCallback pNotify); /// /// The UnregisterControlChangeNotify method deletes the registration of a client's notification callback interface that /// the client registered in a previous call to the IAudioEndpointVolume::RegisterControlChangeNotify method. /// /// /// Pointer to the client's IAudioEndpointVolumeCallback interface. The client passed this same interface pointer to the /// endpoint volume object in a previous call to the IAudioEndpointVolume::RegisterControlChangeNotify method. If the /// UnregisterControlChangeNotify method succeeds, it calls the Release method on the client's /// IAudioEndpointVolumeCallback interface. /// /// /// /// Before the client releases its final reference to the IAudioEndpointVolumeCallback interface, it should call /// UnregisterControlChangeNotify to unregister the interface. Otherwise, the application leaks the resources held by the /// IAudioEndpointVolumeCallback and IAudioEndpointVolume objects. Note that the /// IAudioEndpointVolume::RegisterControlChangeNotify method calls the client's IAudioEndpointVolumeCallback::AddRef method, and /// UnregisterControlChangeNotify calls the IAudioEndpointVolumeCallback::Release method. If the client errs by releasing /// its reference to the IAudioEndpointVolumeCallback interface before calling UnregisterControlChangeNotify, the /// IAudioEndpointVolume object never releases its reference to the IAudioEndpointVolumeCallback interface. For /// example, a poorly designed IAudioEndpointVolumeCallback implementation might call /// UnregisterControlChangeNotify from the destructor for the IAudioEndpointVolumeCallback object. In this case, /// the client will not call UnregisterControlChangeNotify until the IAudioEndpointVolume object releases its /// reference to the IAudioEndpointVolumeCallback interface, and the IAudioEndpointVolume object will not release /// its reference to the IAudioEndpointVolumeCallback interface until the client calls /// UnregisterControlChangeNotify. For more information about the AddRef and Release methods, see the /// discussion of the IUnknown interface in the Windows SDK documentation. /// /// For a code example that calls UnregisterControlChangeNotify, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-unregistercontrolchangenotify // HRESULT UnregisterControlChangeNotify( IAudioEndpointVolumeCallback *pNotify ); new void UnregisterControlChangeNotify([In] IAudioEndpointVolumeCallback pNotify); /// /// The GetChannelCount method gets a count of the channels in the audio stream that enters or leaves the audio endpoint device. /// /// A UINT variable into which the method writes the channel count. // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getchannelcount // HRESULT GetChannelCount( UINT *pnChannelCount ); new uint GetChannelCount(); /// /// The SetMasterVolumeLevel method sets the master volume level, in decibels, of the audio stream that enters or leaves /// the audio endpoint device. /// /// /// The 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 IAudioEndpointVolume::GetVolumeRange method. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// SetMasterVolumeLevel call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the notification routine /// receives the context GUID value GUID_NULL. /// /// /// If volume level fLevelDB falls outside of the volume range reported by the IAudioEndpointVolume::GetVolumeRange /// method, the SetMasterVolumeLevel call fails and returns error code E_INVALIDARG. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-setmastervolumelevel // HRESULT SetMasterVolumeLevel( float fLevelDB, LPCGUID pguidEventContext ); new void SetMasterVolumeLevel([In] float fLevelDB, in Guid pguidEventContext); /// /// The SetMasterVolumeLevelScalar method 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. /// /// /// The new master volume level. The level is expressed as a normalized value in the range from 0.0 to 1.0. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// SetMasterVolumeLevelScalar call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the notification routine /// receives the context GUID value GUID_NULL. /// /// /// /// The volume level is normalized to the range from 0.0 to 1.0, where 0.0 is the minimum volume level and 1.0 is the maximum /// level. Within this range, the relationship of the normalized volume level to the attenuation of signal amplitude is /// described by a nonlinear, audio-tapered curve. Note that the shape of the curve might change in future versions of Windows. /// For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// /// The normalized volume levels that are passed to this method are suitable to represent the positions of volume controls in /// application windows and on-screen displays. /// /// For a code example that calls SetMasterVolumeLevelScalar, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-setmastervolumelevelscalar // HRESULT SetMasterVolumeLevelScalar( float fLevel, LPCGUID pguidEventContext ); new void SetMasterVolumeLevelScalar([In] float fLevel, in Guid pguidEventContext); /// /// The GetMasterVolumeLevel method gets the master volume level, in decibels, of the audio stream that enters or leaves /// the audio endpoint device. /// /// /// The master volume level. This parameter points to 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 IAudioEndpointVolume::GetVolumeRange method. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getmastervolumelevel // HRESULT GetMasterVolumeLevel( float *pfLevelDB ); new float GetMasterVolumeLevel(); /// /// The GetMasterVolumeLevelScalar method 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. /// /// /// The master volume level. This parameter points to 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. /// /// /// /// The volume level is normalized to the range from 0.0 to 1.0, where 0.0 is the minimum volume level and 1.0 is the maximum /// level. Within this range, the relationship of the normalized volume level to the attenuation of signal amplitude is /// described by a nonlinear, audio-tapered curve. Note that the shape of the curve might change in future versions of Windows. /// For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// /// The normalized volume levels that are retrieved by this method are suitable to represent the positions of volume controls in /// application windows and on-screen displays. /// /// For a code example that calls GetMasterVolumeLevelScalar, see Endpoint Volume Controls. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getmastervolumelevelscalar // HRESULT GetMasterVolumeLevelScalar( float *pfLevel ); new float GetMasterVolumeLevelScalar(); /// /// The SetChannelVolumeLevel method sets the volume level, in decibels, of the specified channel of the audio stream /// that enters or leaves the audio endpoint device. /// /// /// The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n– 1. To obtain the number /// of channels, call the IAudioEndpointVolume::GetChannelCount method. /// /// /// The new volume level in decibels. To obtain the range and granularity of the volume levels that can be set by this method, /// call the IAudioEndpointVolume::GetVolumeRange method. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// SetChannelVolumeLevel call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the notification routine /// receives the context GUID value GUID_NULL. /// /// /// If volume level fLevelDB falls outside of the volume range reported by the IAudioEndpointVolume::GetVolumeRange /// method, the SetChannelVolumeLevel call fails and returns error code E_INVALIDARG. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-setchannelvolumelevel // HRESULT SetChannelVolumeLevel( UINT nChannel, float fLevelDB, LPCGUID pguidEventContext ); new void SetChannelVolumeLevel([In] uint nChannel, float fLevelDB, in Guid pguidEventContext); /// /// The SetChannelVolumeLevelScalar method sets the normalized, audio-tapered volume level of the specified channel in /// the audio stream that enters or leaves the audio endpoint device. /// /// /// The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n– 1. To obtain the number /// of channels, call the IAudioEndpointVolume::GetChannelCount method. /// /// The volume level. The volume level is expressed as a normalized value in the range from 0.0 to 1.0. /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// SetChannelVolumeLevelScalar call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the notification routine /// receives the context GUID value GUID_NULL. /// /// /// /// The volume level is normalized to the range from 0.0 to 1.0, where 0.0 is the minimum volume level and 1.0 is the maximum /// level. Within this range, the relationship of the normalized volume level to the attenuation of signal amplitude is /// described by a nonlinear, audio-tapered curve. Note that the shape of the curve might change in future versions of Windows. /// For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// /// The normalized volume levels that are passed to this method are suitable to represent the positions of volume controls in /// application windows and on-screen displays. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-setchannelvolumelevelscalar // HRESULT SetChannelVolumeLevelScalar( UINT nChannel, float fLevel, LPCGUID pguidEventContext ); new void SetChannelVolumeLevelScalar([In] uint nChannel, float fLevel, in Guid pguidEventContext); /// /// The GetChannelVolumeLevel method gets the volume level, in decibels, of the specified channel in the audio stream /// that enters or leaves the audio endpoint device. /// /// /// The channel number. If the audio stream has n channels, the channels are numbered from 0 to n– 1. To obtain the number of /// channels in the stream, call the IAudioEndpointVolume::GetChannelCount method. /// /// /// 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 IAudioEndpointVolume::GetVolumeRange method. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getchannelvolumelevel // HRESULT GetChannelVolumeLevel( UINT nChannel, float *pfLevelDB ); new float GetChannelVolumeLevel([In] uint nChannel); /// /// The GetChannelVolumeLevelScalar method gets the normalized, audio-tapered volume level of the specified channel of /// the audio stream that enters or leaves the audio endpoint device. /// /// /// The channel number. If the audio stream contains n channels, the channels are numbered from 0 to n– 1. To obtain the number /// of channels, call the IAudioEndpointVolume::GetChannelCount method. /// /// /// 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. /// /// /// /// The volume level is normalized to the range from 0.0 to 1.0, where 0.0 is the minimum volume level and 1.0 is the maximum /// level. Within this range, the relationship of the normalized volume level to the attenuation of signal amplitude is /// described by a nonlinear, audio-tapered curve. Note that the shape of the curve might change in future versions of Windows. /// For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// /// The normalized volume levels that are retrieved by this method are suitable to represent the positions of volume controls in /// application windows and on-screen displays. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getchannelvolumelevelscalar // HRESULT GetChannelVolumeLevelScalar( UINT nChannel, float *pfLevel ); new float GetChannelVolumeLevelScalar([In] uint nChannel); /// /// The SetMute method sets the muting state of the audio stream that enters or leaves the audio endpoint device. /// /// /// The new muting state. If bMute is TRUE, the method mutes the stream. If FALSE, the method turns off muting. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// SetMute call changes the muting state of the endpoint, all clients that have registered IAudioEndpointVolumeCallback /// interfaces with that endpoint will receive notifications. In its implementation of the OnNotify method, a client can /// inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the /// caller supplies a NULL pointer for this parameter, the notification routine receives the context GUID value GUID_NULL. /// /// For a code example that calls SetMute, see Endpoint Volume Controls. // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-setmute HRESULT // SetMute( BOOL bMute, LPCGUID pguidEventContext ); new void SetMute([In] [MarshalAs(UnmanagedType.Bool)] bool bMute, in Guid pguidEventContext); /// /// The GetMute method gets the muting state of the audio stream that enters or leaves the audio endpoint device. /// /// /// A BOOL variable into which the method writes the muting state. If *pbMute is TRUE, the stream is muted. If /// FALSE, the stream is not muted. /// /// For a code example that calls GetMute, see Endpoint Volume Controls. // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getmute HRESULT // GetMute( BOOL *pbMute ); [return: MarshalAs(UnmanagedType.Bool)] new bool GetMute(); /// The GetVolumeStepInfo method gets information about the current step in the volume range. /// /// Pointer to a UINT variable into which the method writes the current step index. This index is a value in the range /// from 0 to *pStepCount– 1, where 0 represents the minimum volume level and *pStepCount– 1 represents the maximum level. /// /// /// Pointer to a UINT variable into which the method writes the number of steps in the volume range. This number remains /// constant for the lifetime of the IAudioEndpointVolume interface instance. /// /// /// /// This method represents the volume level of the audio stream that enters or leaves the audio endpoint device as an index or /// "step" in a range of discrete volume levels. Output value *pnStepCount is the number of steps in the range. Output value /// *pnStep is the step index of the current volume level. If the number of steps is n = *pnStepCount, then step index *pnStep /// can assume values from 0 (minimum volume) to n – 1 (maximum volume). /// /// /// Over the range from 0 to n – 1, successive intervals between adjacent steps do not necessarily represent uniform volume /// increments in either linear signal amplitude or decibels. In Windows Vista, GetVolumeStepInfo defines the /// relationship of index to volume level (signal amplitude) to be an audio-tapered curve. Note that the shape of the curve /// might change in future versions of Windows. For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// /// Audio applications can call the IAudioEndpointVolume::VolumeStepUp and IAudioEndpointVolume::VolumeStepDown methods to /// increase or decrease the volume level by one interval. Either method first calculates the idealized volume level that /// corresponds to the next point on the audio-tapered curve. Next, the method selects the endpoint volume setting that is the /// best approximation to the idealized level. To obtain the range and granularity of the endpoint volume settings, call the /// IEndpointVolume::GetVolumeRange method. If the audio endpoint device implements a hardware volume control, /// GetVolumeRange describes the hardware volume settings. Otherwise, the EndpointVolume API implements the endpoint /// volume control in software, and GetVolumeRange describes the volume settings of the software-implemented control. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getvolumestepinfo // HRESULT GetVolumeStepInfo( UINT *pnStep, UINT *pnStepCount ); new void GetVolumeStepInfo(out uint pnStep, out uint pnStepCount); /// /// The VolumeStepUp method increments, by one step, the volume level of the audio stream that enters or leaves the audio /// endpoint device. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// VolumeStepUp call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the client's notification /// method receives a NULL context pointer. /// /// /// /// To obtain the current volume step and the total number of steps in the volume range, call the /// IAudioEndpointVolume::GetVolumeStepInfo method. /// /// /// If the volume level is already at the highest step in the volume range, the call to VolumeStepUp has no effect and /// returns status code S_OK. /// /// /// Successive intervals between adjacent steps do not necessarily represent uniform volume increments in either linear signal /// amplitude or decibels. In Windows Vista, VolumeStepUp defines the relationship of step index to volume level (signal /// amplitude) to be an audio-tapered curve. Note that the shape of the curve might change in future versions of Windows. For /// more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-volumestepup HRESULT // VolumeStepUp( LPCGUID pguidEventContext ); new void VolumeStepUp(in Guid pguidEventContext); /// /// The VolumeStepDown method decrements, by one step, the volume level of the audio stream that enters or leaves the /// audio endpoint device. /// /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This parameter points to an event-context GUID. If the /// VolumeStepDown call changes the volume level of the endpoint, all clients that have registered /// IAudioEndpointVolumeCallback interfaces with that endpoint will receive notifications. In its implementation of the /// OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source /// of the volume-change event. If the caller supplies a NULL pointer for this parameter, the client's notification /// method receives a NULL context pointer. /// /// /// /// To obtain the current volume step and the total number of steps in the volume range, call the /// IAudioEndpointVolume::GetVolumeStepInfo method. /// /// /// If the volume level is already at the lowest step in the volume range, the call to VolumeStepDown has no effect and /// returns status code S_OK. /// /// /// Successive intervals between adjacent steps do not necessarily represent uniform volume increments in either linear signal /// amplitude or decibels. In Windows Vista, VolumeStepDown defines the relationship of step index to volume level /// (signal amplitude) to be an audio-tapered curve. Note that the shape of the curve might change in future versions of /// Windows. For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-volumestepdown // HRESULT VolumeStepDown( LPCGUID pguidEventContext ); new void VolumeStepDown(in Guid pguidEventContext); /// The QueryHardwareSupport method queries the audio endpoint device for its hardware-supported functions. /// /// A DWORD variable into which the method writes a hardware support mask that indicates the hardware capabilities of the /// audio endpoint device. The method can set the mask to 0 or to the bitwise-OR combination of one or more /// ENDPOINT_HARDWARE_SUPPORT_XXX constants. /// /// /// This method indicates whether the audio endpoint device implements the following functions in hardware: /// /// /// Volume control /// /// /// Mute control /// /// /// Peak meter /// /// /// /// The system automatically substitutes a software implementation for any function in the preceding list that the endpoint /// device does not implement in hardware. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-queryhardwaresupport // HRESULT QueryHardwareSupport( DWORD *pdwHardwareSupportMask ); new ENDPOINT_HARDWARE_SUPPORT QueryHardwareSupport(); /// /// The GetVolumeRange method gets the volume range, in decibels, of the audio stream that enters or leaves the audio /// endpoint device. /// /// /// Pointer to the minimum volume level. This parameter points to a float variable into which the method writes the /// minimum volume level in decibels. This value remains constant for the lifetime of the IAudioEndpointVolume interface instance. /// /// /// Pointer to the maximum volume level. This parameter points to a float variable into which the method writes the /// maximum volume level in decibels. This value remains constant for the lifetime of the IAudioEndpointVolume interface instance. /// /// /// Pointer to the volume increment. This parameter points to a float variable into which the method writes the volume /// increment in decibels. This increment remains constant for the lifetime of the IAudioEndpointVolume interface instance. /// /// /// /// The volume range from vmin = *pfLevelMinDB to vmax = *pfLevelMaxDB is divided into n uniform intervals of size vinc = /// *pfVolumeIncrementDB, where /// /// n = (vmax – vmin) / vinc. /// /// The values vmin, vmax, and vinc are measured in decibels. The client can set the volume level to one of n + 1 discrete /// values in the range from vmin to vmax. /// /// /// The IAudioEndpointVolume::SetChannelVolumeLevel and IAudioEndpointVolume::SetMasterVolumeLevel methods accept only volume /// levels in the range from vmin to vmax. If the caller specifies a volume level outside of this range, the method fails and /// returns E_INVALIDARG. If the caller specifies a volume level that falls between two steps in the volume range, the method /// sets the endpoint volume level to the step that lies closest to the requested volume level and returns S_OK. However, a /// subsequent call to IAudioEndpointVolume::GetChannelVolumeLevel or IAudioEndpointVolume::GetMasterVolumeLevel retrieves the /// volume level requested by the previous call to SetChannelVolumeLevel or SetMasterVolumeLevel, not the step value. /// /// /// If the volume control is implemented in hardware, GetVolumeRange describes the range and granularity of the hardware /// volume settings. In contrast, the steps that are reported by the IEndpointVolume::GetVolumeStepInfo method correspond to /// points on an audio-tapered curve that are calculated in software by the IEndpointVolume::VolumeStepDown and /// IEndpointVolume::VolumeStepUp methods. Either method first calculates the idealized volume level that corresponds to the /// next point on the curve. Next, the method selects the hardware volume setting that is the best approximation to the /// idealized level. For more information about audio-tapered curves, see Audio-Tapered Volume Controls. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getvolumerange // HRESULT GetVolumeRange( float *pflVolumeMindB, float *pflVolumeMaxdB, float *pflVolumeIncrementdB ); new void GetVolumeRange(out float pflVolumeMindB, out float pflVolumeMaxdB, out float pflVolumeIncrementdB); /// The GetVolumeRangeChannel method gets the volume range for a specified channel. /// /// The channel number for which to get the volume range. If the audio stream has n channels, the channels are numbered from 0 /// to n– 1. To obtain the number of channels in the stream, call the IAudioEndpointVolume::GetChannelCount method. /// /// Receives the minimum volume level for the channel, in decibels. /// Receives the maximum volume level for the channel, in decibels. /// Receives the volume increment for the channel, in decibels. // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolumeex-getvolumerangechannel // HRESULT GetVolumeRangeChannel( UINT iChannel, float *pflVolumeMindB, float *pflVolumeMaxdB, float *pflVolumeIncrementdB ); void GetVolumeRangeChannel(uint iChannel, out float pflVolumeMindB, out float pflVolumeMaxdB, out float pflVolumeIncrementdB); } /// /// /// The IAudioMeterInformation interface represents a peak meter on an audio stream to or from an audio endpoint device. The /// client obtains a reference to the IAudioMeterInformation interface on an endpoint object by calling the /// IMMDevice::Activate method with parameter iid set to REFIID IID_IAudioMeterInformation. /// /// /// If the adapter device that streams audio data to or from the endpoint device implements a hardware peak meter, the /// IAudioMeterInformation interface uses that meter to monitor the peak levels in the audio stream. If the audio device /// lacks a hardware peak meter, the audio engine automatically implements the peak meter in software, transparently to the client. /// /// /// If a device has a hardware peak meter, a client can use the methods in the IAudioMeterInformation interface to monitor /// the device's peak levels in both shared mode and exclusive mode. If a device lacks a hardware peak meter, a client can use those /// methods to monitor the device's peak levels in shared mode, but not in exclusive mode. In exclusive mode, the client and the /// device exchange audio data directly, bypassing the software peak meter. In exclusive mode, a software peak meter always reports /// a peak value of 0.0. /// /// To determine whether a device has a hardware peak meter, call the IAudioMeterInformation::QueryHardwareSupport method. /// /// For a rendering endpoint device, the IAudioMeterInformation interface monitors the peak levels in the output stream /// before the stream is attenuated by the endpoint volume controls. Similarly, for a capture endpoint device, the interface /// monitors the peak levels in the input stream before the stream is attenuated by the endpoint volume controls. /// /// /// The peak values reported by the methods in the IAudioMeterInformation interface are normalized to the range from 0.0 to /// 1.0. For example, if a PCM stream contains 16-bit samples, and the peak sample value during a particular metering period is /// –8914, then the absolute value recorded by the peak meter is 8914, and the normalized peak value reported by the /// IAudioMeterInformation interface is 8914/32768 = 0.272. /// /// For a code example that uses the IAudioMeterInformation interface, see Peak Meters. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nn-endpointvolume-iaudiometerinformation [PInvokeData("endpointvolume.h", MSDNShortId = "eff1c1cd-792b-489a-8381-4b783c57f005")] [ComImport, Guid("C02216F6-8C67-4B5B-9D00-D008E73E0064"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioMeterInformation { /// The GetPeakValue method gets the peak sample value for the channels in the audio stream. /// /// Pointer to a float variable into which the method writes the peak sample value for the audio stream. The peak value /// is a number in the normalized range from 0.0 to 1.0. /// /// /// /// This method retrieves the peak sample value recorded across all of the channels in the stream. The peak value for each /// channel is recorded over one device period and made available during the subsequent device period. Thus, this method always /// retrieves the peak value recorded during the previous device period. To obtain the device period, call the /// IAudioClient::GetDevicePeriod method. /// /// For a code example that uses the GetPeakValue method, see Peak Meters. /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudiometerinformation-getpeakvalue // HRESULT GetPeakValue( float *pfPeak ); float GetPeakValue(); /// /// The GetMeteringChannelCount method gets the number of channels in the audio stream that are monitored by peak meters. /// /// Pointer to a UINT variable into which the method writes the number of channels. // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudiometerinformation-getmeteringchannelcount // HRESULT GetMeteringChannelCount( UINT *pnChannelCount ); uint GetMeteringChannelCount(); /// The GetChannelsPeakValues method gets the peak sample values for all the channels in the audio stream. /// /// The channel count. This parameter also specifies the number of elements in the afPeakValues array. If the specified count /// does not match the number of channels in the stream, the method returns error code E_INVALIDARG. /// /// /// Pointer to an array of peak sample values. The method writes the peak values for the channels into the array. The array /// contains one element for each channel in the stream. The peak values are numbers in the normalized range from 0.0 to 1.0. /// /// /// /// This method retrieves the peak sample values for the channels in the stream. The peak value for each channel is recorded /// over one device period and made available during the subsequent device period. Thus, this method always retrieves the peak /// values recorded during the previous device period. To obtain the device period, call the IAudioClient::GetDevicePeriod method. /// /// /// Parameter afPeakValues points to a caller-allocated float array. If the stream contains n channels, the channels are /// numbered 0 to n– 1. The method stores the peak value for each channel in the array element whose array index matches the /// channel number. To get the number of channels in the audio stream that are monitored by peak meters, call the /// IAudioMeterInformation::GetMeteringChannelCount method. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudiometerinformation-getchannelspeakvalues // HRESULT GetChannelsPeakValues( UINT32 u32ChannelCount, float *afPeakValues ); void GetChannelsPeakValues(uint u32ChannelCount, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] float[] afPeakValues); /// The QueryHardwareSupport method queries the audio endpoint device for its hardware-supported functions. /// /// A DWORD variable into which the method writes a hardware support mask that indicates the hardware capabilities of the /// audio endpoint device. The method can set the mask to 0 or to the bitwise-OR combination of one or more /// ENDPOINT_HARDWARE_SUPPORT_XXX constants. /// /// /// This method indicates whether the audio endpoint device implements the following functions in hardware: /// /// /// Volume control /// /// /// Mute control /// /// /// Peak meter /// /// /// /// The system automatically substitutes a software implementation for any function in the preceding list that the endpoint /// devices does not implement in hardware. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudiometerinformation-queryhardwaresupport // HRESULT QueryHardwareSupport( DWORD *pdwHardwareSupportMask ); uint QueryHardwareSupport(); } /// /// The AUDIO_VOLUME_NOTIFICATION_DATA structure describes a change in the volume level or muting state of an audio endpoint device. /// /// /// This structure is used by the IAudioEndpointVolumeCallback::OnNotify method. /// /// A client can register to be notified when the volume level or muting state of an endpoint device changes. The following methods /// can cause such a change: /// /// /// /// IAudioEndpointVolume::SetChannelVolumeLevel /// /// /// IAudioEndpointVolume::SetChannelVolumeLevelScalar /// /// /// IAudioEndpointVolume::SetMasterVolumeLevel /// /// /// IAudioEndpointVolume::SetMasterVolumeLevelScalar /// /// /// IAudioEndpointVolume::SetMute /// /// /// IAudioEndpointVolume::VolumeStepDown /// /// /// IAudioEndpointVolume::VolumeStepUp /// /// /// /// When a call to one of these methods causes a volume-change event (that is, a change in the volume level or muting state), the /// method sends notifications to all clients that have registered to receive them. The method notifies a client by calling the /// client's IAudioEndpointVolumeCallback::OnNotify method. Through the OnNotify call, the client receives a pointer /// to an AUDIO_VOLUME_NOTIFICATION_DATA structure that describes the change. /// /// /// Each of the methods in the preceding list accepts an input parameter named pguidEventContext, which is a pointer to an /// event-context GUID. Before sending notifications to clients, the method copies the event-context GUID pointed to by /// pguidEventContext into the guidEventContext member of the AUDIO_VOLUME_NOTIFICATION_DATA structure that it /// supplies to clients through their OnNotify methods. If pguidEventContext is NULL, the value of the /// guidEventContext member is set to GUID_NULL. /// /// /// In its implementation of the OnNotify method, a client can inspect the event-context GUID from that call to discover /// whether it or another client is the source of the volume-change event. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/ns-endpointvolume-audio_volume_notification_data typedef struct // AUDIO_VOLUME_NOTIFICATION_DATA { GUID guidEventContext; BOOL bMuted; float fMasterVolume; UINT nChannels; float // afChannelVolumes[1]; } AUDIO_VOLUME_NOTIFICATION_DATA, *PAUDIO_VOLUME_NOTIFICATION_DATA; [PInvokeData("endpointvolume.h", MSDNShortId = "8778eb32-bc37-4d21-a096-f932db3d7b3f")] [VanaraMarshaler(typeof(SafeAnysizeStructMarshaler), nameof(nChannels))] [StructLayout(LayoutKind.Sequential)] public struct AUDIO_VOLUME_NOTIFICATION_DATA { /// /// Context value for the IAudioEndpointVolumeCallback::OnNotify method. This member is the value of the event-context GUID that /// was provided as an input parameter to the IAudioEndpointVolume method call that changed the endpoint volume level or muting /// state. For more information, see Remarks. /// public Guid guidEventContext; /// /// Specifies whether the audio stream is currently muted. If bMuted is TRUE, the stream is muted. If /// FALSE, the stream is not muted. /// [MarshalAs(UnmanagedType.Bool)] public bool bMuted; /// /// Specifies the current master volume level of the audio stream. The volume level is normalized to the range from 0.0 to 1.0, /// where 0.0 is the minimum volume level and 1.0 is the maximum level. Within this range, the relationship of the normalized /// volume level to the attenuation of signal amplitude is described by a nonlinear, audio-tapered curve. For more information /// about audio tapers, see Audio-Tapered Volume Controls. /// public float fMasterVolume; /// /// Specifies the number of channels in the audio stream, which is also the number of elements in the afChannelVolumes /// array. If the audio stream contains n channels, the channels are numbered from 0 to n-1. The volume level for a particular /// channel is contained in the array element whose index matches the channel number. /// public uint nChannels; /// /// The first element in an array of channel volumes. This element contains the current volume level of channel 0 in the audio /// stream. If the audio stream contains more than one channel, the volume levels for the additional channels immediately follow /// the AUDIO_VOLUME_NOTIFICATION_DATA structure. The volume level for each channel is normalized to the range from 0.0 /// to 1.0, where 0.0 is the minimum volume level and 1.0 is the maximum level. Within this range, the relationship of the /// normalized volume level to the attenuation of signal amplitude is described by a nonlinear, audio-tapered curve. /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public float[] afChannelVolumes; } } }