#nullable enable using System; using System.Runtime.InteropServices; using Vanara.InteropServices; using static Vanara.PInvoke.Ole32; using static Vanara.PInvoke.PropSys; namespace Vanara.PInvoke; public static partial class CoreAudio { /// Specifies the level of an APO event logged with IAudioProcessingObjectLoggingService::ApoLog. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ne-audioengineextensionapo-apo_log_level typedef enum // APO_LOG_LEVEL { APO_LOG_LEVEL_ALWAYS, APO_LOG_LEVEL_CRITICAL, APO_LOG_LEVEL_ERROR, APO_LOG_LEVEL_WARNING, APO_LOG_LEVEL_INFO, // APO_LOG_LEVEL_VERBOSE } ; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NE:audioengineextensionapo.APO_LOG_LEVEL")] public enum APO_LOG_LEVEL { /// All events. APO_LOG_LEVEL_ALWAYS = 0, /// Abnormal exit or termination events. APO_LOG_LEVEL_CRITICAL, /// Severe error events. APO_LOG_LEVEL_ERROR, /// Warning events such as allocation failures. APO_LOG_LEVEL_WARNING, /// Non-error events such as entry or exit events. APO_LOG_LEVEL_INFO, /// Detailed trace events. APO_LOG_LEVEL_VERBOSE, } /// Specifies the type of an APO_NOTIFICATION. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ne-audioengineextensionapo-apo_notification_type typedef // enum APO_NOTIFICATION_TYPE { APO_NOTIFICATION_TYPE_NONE, APO_NOTIFICATION_TYPE_ENDPOINT_VOLUME, // APO_NOTIFICATION_TYPE_ENDPOINT_PROPERTY_CHANGE, APO_NOTIFICATION_TYPE_SYSTEM_EFFECTS_PROPERTY_CHANGE, // APO_NOTIFICATION_TYPE_ENDPOINT_VOLUME2, APO_NOTIFICATION_TYPE_DEVICE_ORIENTATION, APO_NOTIFICATION_TYPE_MICROPHONE_BOOST } ; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NE:audioengineextensionapo.APO_NOTIFICATION_TYPE")] public enum APO_NOTIFICATION_TYPE { /// None. APO_NOTIFICATION_TYPE_NONE = 0, /// Endpoint volume notification. APO_NOTIFICATION_TYPE_ENDPOINT_VOLUME = 1, /// Endpoint property change notification. APO_NOTIFICATION_TYPE_ENDPOINT_PROPERTY_CHANGE = 2, /// System effects property change notification. APO_NOTIFICATION_TYPE_SYSTEM_EFFECTS_PROPERTY_CHANGE = 3, /// Endpoint volume notifications for an endpoint that includes master and channel volume in dB. APO_NOTIFICATION_TYPE_ENDPOINT_VOLUME2 = 4, /// Orientation notifications for the device. APO_NOTIFICATION_TYPE_DEVICE_ORIENTATION = 5, /// Microphone boost notifications APO_NOTIFICATION_TYPE_MICROPHONE_BOOST = 6 } /// Specifies the state of a System Effects Audio Processing Object (sAPO) audio effect. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ne-audioengineextensionapo-audio_systemeffect_state // typedef enum AUDIO_SYSTEMEFFECT_STATE { AUDIO_SYSTEMEFFECT_STATE_OFF, AUDIO_SYSTEMEFFECT_STATE_ON } ; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NE:audioengineextensionapo.AUDIO_SYSTEMEFFECT_STATE")] public enum AUDIO_SYSTEMEFFECT_STATE { /// The audio effect is off. AUDIO_SYSTEMEFFECT_STATE_OFF, /// The audio effect is on. AUDIO_SYSTEMEFFECT_STATE_ON, } /// Undocumented [PInvokeData("audioengineextensionapo.h")] public enum DEVICE_ORIENTATION_TYPE { /// Undocumented DEVICE_NOT_ROTATED, /// Undocumented DEVICE_ROTATED_90_DEGREES_CLOCKWISE, /// Undocumented DEVICE_ROTATED_180_DEGREES_CLOCKWISE, /// Undocumented DEVICE_ROTATED_270_DEGREES_CLOCKWISE } /// Represents a logging service for APOs. /// /// /// Get an instance of this interface by QueryService on the object in the pServiceProvider field of the APOInitSystemEffects3 structure /// passed in the pbyData parameter to IAudioProcessingObject::Initialize. Specify SID_AudioProcessingObjectLoggingService as the /// identifier in the guidService parameter. /// /// /// Note /// /// IAudioProcessingObjectLoggingService::ApoLog should never be called from a real-time priority thread. For more information on thread /// priorities, see Scheduling Priorities. /// /// /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nn-audioengineextensionapo-iaudioprocessingobjectloggingservice [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NN:audioengineextensionapo.IAudioProcessingObjectLoggingService")] [ComImport, Guid("698f0107-1745-4708-95a5-d84478a62a65"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioProcessingObjectLoggingService { /// Logs an APO event. /// A value from the APO_LOG_LEVEL enumeration specifying the level of the event being logged. /// The format-control string for the log message. /// Format argument list. /// None /// /// Note /// /// This method should never be called from a real-time priority thread. For more information on thread priorities, see Scheduling Priorities. /// /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nf-audioengineextensionapo-iaudioprocessingobjectloggingservice-apolog // void ApoLog( APO_LOG_LEVEL level, LPCWSTR format, ... ); [PreserveSig] void ApoLog(APO_LOG_LEVEL level, string format, IntPtr args); } /// /// Implemented by clients to register for and receive common audio-related notifications for APO endpoint and system effect notifications. /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nn-audioengineextensionapo-iaudioprocessingobjectnotifications [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NN:audioengineextensionapo.IAudioProcessingObjectNotifications")] [ComImport, Guid("56B0C76F-02FD-4B21-A52E-9F8219FC86E4"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioProcessingObjectNotifications { /// /// Called by the system to allow clients to register to receive notification callbacks for APO endpoint and system effect notifications. /// /// /// Output parameter that returns a pointer to an array of APO_NOTIFICATION_DESCRIPTOR specifying the set of APO changes for which /// notifications are requested. /// /// Output parameter specifying the number of items returned in apoNotifications. /// An HRESULT. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nf-audioengineextensionapo-iaudioprocessingobjectnotifications-getaponotificationregistrationinfo // HRESULT GetApoNotificationRegistrationInfo( APO_NOTIFICATION_DESCRIPTOR **apoNotifications, DWORD *count ); [PreserveSig] HRESULT GetApoNotificationRegistrationInfo( [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] out APO_NOTIFICATION_DESCRIPTOR[] apoNotifications, out uint count); /// Called by the system to notify clients of changes to APO endpoints or system effects. /// An APO_NOTIFICATION representing the APO change associated with the notification. /// None /// /// Specify the set of APO changes for which this method is called by implementing IAudioProcessingObjectNotifications::GetApoNotificationRegistrationInfo. /// /// This method will be called after LockForProcess is called and will stop being called before UnlockForProcess. If there are any /// notifications in flight, they might get executed during or after UnlockForProcess. The APO must handle synchronization in /// this case. /// /// /// Note /// /// APOs must query each property once to get its initial value because HandleNotification method is only invoked when any of /// the properties have changed. The exceptions to this are the initial audio endpoint volume when the APO registers for /// APO_NOTIFICATION_TYPE_ENDPOINT_VOLUME and the value of PKEY_AudioEndpoint_Disable_SysFx if the APO registers for APO_NOTIFICATION_TYPE_ENDPOINT_PROPERTY_CHANGE /// /// /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nf-audioengineextensionapo-iaudioprocessingobjectnotifications-handlenotification // void HandleNotification( APO_NOTIFICATION *apoNotification ); [PreserveSig] void HandleNotification(in APO_NOTIFICATION apoNotification); } /// Undocumented /// [ComImport, Guid("ca2cfbde-a9d6-4eb0-bc95-c4d026b380f0"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioProcessingObjectNotifications2 : IAudioProcessingObjectNotifications { /// /// Called by the system to allow clients to register to receive notification callbacks for APO endpoint and system effect notifications. /// /// /// Output parameter that returns a pointer to an array of APO_NOTIFICATION_DESCRIPTOR specifying the set of APO changes for which /// notifications are requested. /// /// Output parameter specifying the number of items returned in apoNotifications. /// An HRESULT. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nf-audioengineextensionapo-iaudioprocessingobjectnotifications-getaponotificationregistrationinfo // HRESULT GetApoNotificationRegistrationInfo( APO_NOTIFICATION_DESCRIPTOR **apoNotifications, DWORD *count ); [PreserveSig] new HRESULT GetApoNotificationRegistrationInfo( [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] out APO_NOTIFICATION_DESCRIPTOR[] apoNotifications, out uint count); /// Called by the system to notify clients of changes to APO endpoints or system effects. /// An APO_NOTIFICATION representing the APO change associated with the notification. /// None /// /// Specify the set of APO changes for which this method is called by implementing IAudioProcessingObjectNotifications::GetApoNotificationRegistrationInfo. /// /// This method will be called after LockForProcess is called and will stop being called before UnlockForProcess. If there are any /// notifications in flight, they might get executed during or after UnlockForProcess. The APO must handle synchronization in /// this case. /// /// /// Note /// /// APOs must query each property once to get its initial value because HandleNotification method is only invoked when any of /// the properties have changed. The exceptions to this are the initial audio endpoint volume when the APO registers for /// APO_NOTIFICATION_TYPE_ENDPOINT_VOLUME and the value of PKEY_AudioEndpoint_Disable_SysFx if the APO registers for APO_NOTIFICATION_TYPE_ENDPOINT_PROPERTY_CHANGE /// /// /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nf-audioengineextensionapo-iaudioprocessingobjectnotifications-handlenotification // void HandleNotification( APO_NOTIFICATION *apoNotification ); [PreserveSig] new void HandleNotification(in APO_NOTIFICATION apoNotification); /// Undocumented [PreserveSig] HRESULT GetApoNotificationRegistrationInfo2(APO_NOTIFICATION_TYPE maxApoNotificationTypeSupported, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] out APO_NOTIFICATION_DESCRIPTOR[] apoNotifications, out uint count); } /// Provides access to the real time work queue for APOs. /// /// /// Get an instance of this interface by calling QueryService on the object in the pServiceProvider field of the APOInitSystemEffects3 /// structure passed in the pbyData parameter to IAudioProcessingObject::Initialize. Specify SID_AudioProcessingObjectRTQueue as /// the identifier in the guidService parameter. /// /// For information on using the real-time work queue APIs, see rtworkq.h header. /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nn-audioengineextensionapo-iaudioprocessingobjectrtqueueservice [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NN:audioengineextensionapo.IAudioProcessingObjectRTQueueService")] [ComImport, Guid("ACD65E2F-955B-4B57-B9BF-AC297BB752C9"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioProcessingObjectRTQueueService { /// Gets the ID of a work queue that the APO can use to schedule tasks that need to run at a real-time priority. /// A DWORD containing the work queue ID. /// The returned work queue ID is used with the real-time work queue APIs. For more information see rtworkq.h header. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nf-audioengineextensionapo-iaudioprocessingobjectrtqueueservice-getrealtimeworkqueue // HRESULT GetRealTimeWorkQueue( DWORD *workQueueId ); uint GetRealTimeWorkQueue(); } /// /// /// Implementing this interface also implies that the APO supports the APO Settings framework and allows the APO to subscribe for common /// audio related notifications from the Audio Engine /// /// /// This interface is also implemented by clients that require an APOInitSystemEffects3 structure to be passed into the /// IAudioProcessingObject::Initialize method. APOInitSystemEffects3 adds the ability to obtain a service provider such as /// IAudioProcessingObjectLoggingService or IAudioProcessingObjectRTQueueService. /// /// /// Note /// /// On OS versions earlier than Windows Build 22000, the system will not pass an APOInitSystemEffects3 into /// IAudioProcessingObject::Initialize even if the client implements IAudioSystemEffects3, but will instead pass an older /// version of the structure, APOInitSystemEffects2 or APOInitSystemEffects, into Initialize. /// /// /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nn-audioengineextensionapo-iaudiosystemeffects3 [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NN:audioengineextensionapo.IAudioSystemEffects3")] [ComImport, Guid("C58B31CD-FC6A-4255-BC1F-AD29BB0A4A17"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioSystemEffects3 : IAudioSystemEffects2 { /// /// The GetEffectsList method is used for retrieving the list of audio processing effects that are currently active, and stores an /// event to be signaled if the list changes. /// /// /// Pointer to the list of GUIDs that represent audio processing effects. The caller is responsible for freeing this memory by /// calling CoTaskMemFree. /// /// A count of the audio processing effects in the list. /// The HANDLE of the event that will be signaled if the list changes. /// /// The GetEffectsList method returns S_OK, If the method call is successful. If there are no effects in the list, the /// function still succeeds, ppEffectsIds returns a NULL pointer, and pcEffects returns a count of 0. /// /// /// /// The APO signals the specified event when the list of audio processing effects changes from the list that was returned by /// GetEffectsList. The APO uses this event until either GetEffectsList is called again, or the APO is destroyed. The /// passed handle can be NULL, in which case the APO stops using any previous handle and does not signal an event. /// /// /// An APO implements this method to allow Windows to discover the current effects applied by the APO. The list of effects may depend /// on the processing mode that the APO initialized, and on any end user configuration. The processing mode is indicated by the /// AudioProcessingMode member of APOInitSystemEffects2. /// /// /// APOs should identify effects using GUIDs defined by Windows, such as AUDIO_EFFECT_TYPE_ACOUSTIC_ECHO_CANCELLATION. An APO should /// only define and return a custom GUID in rare cases where the type of effect is clearly different from the ones defined by Windows. /// /// // https://learn.microsoft.com/en-us/windows/win32/api/audioenginebaseapo/nf-audioenginebaseapo-iaudiosystemeffects2-geteffectslist // HRESULT GetEffectsList( [out] LPGUID *ppEffectsIds, [out] UINT *pcEffects, [in] HANDLE Event ); [PreserveSig] new HRESULT GetEffectsList(out SafeCoTaskMemHandle ppEffectsIds, out uint pcEffects, [In] IntPtr Event); /// /// Implemented by System Effects Audio Processing Object (sAPO) audio effects to allow the caller to get the current list of effects. /// /// /// Receives a pointer to an array of AUDIO_SYSTEMEFFECT_STATE structures representing the current list of audio effects. /// /// Receives the number of AUDIO_EFFECT structures returned in effects. /// The HANDLE of the event that will be signaled if the list changes. /// An HRESULT. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nf-audioengineextensionapo-iaudiosystemeffects3-getcontrollablesystemeffectslist // HRESULT GetControllableSystemEffectsList( AUDIO_SYSTEMEFFECT **effects, UINT *numEffects, HANDLE event ); [PreserveSig] HRESULT GetControllableSystemEffectsList([Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] out AUDIO_SYSTEMEFFECT[]? effects, out uint numEffects, [In, Optional] HEVENT @event); /// /// Implemented by System Effects Audio Processing Object (sAPO) audio effects to allow the caller to set the state of effects. /// /// The GUID identifier for an audio effect. Audio effect GUIDs are defined in ksmedia.h. /// A value from the AUDIO_SYSTEMEFFECT_STATE enumerating specifying the state to set. /// An HRESULT. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/nf-audioengineextensionapo-iaudiosystemeffects3-setaudiosystemeffectstate // HRESULT SetAudioSystemEffectState( GUID effectId, AUDIO_SYSTEMEFFECT_STATE state ); [PreserveSig] HRESULT SetAudioSystemEffectState(Guid effectId, AUDIO_SYSTEMEFFECT_STATE state); } /// Represents a notification for a change to an APO endpoint or system effects. /// /// Register for the types of notifications you want to receive by implementing /// IAudioProcessingObjectNotifications::GetApoNotificationRegistrationInfo. Receive the registered notifications by implementing IAudioProcessingObjectNotifications::HandleNotification. /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ns-audioengineextensionapo-apo_notification typedef struct // APO_NOTIFICATION { APO_NOTIFICATION_TYPE type; union { AUDIO_ENDPOINT_VOLUME_CHANGE_NOTIFICATION audioEndpointVolumeChange; // AUDIO_ENDPOINT_PROPERTY_CHANGE_NOTIFICATION audioEndpointPropertyChange; AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_NOTIFICATION // audioSystemEffectsPropertyChange; AUDIO_ENDPOINT_VOLUME_CHANGE_NOTIFICATION2 audioEndpointVolumeChange2; DEVICE_ORIENTATION_TYPE // deviceOrientation; AUDIO_MICROPHONE_BOOST_NOTIFICATION audioMicrophoneBoostChange; } DUMMYUNIONNAME; } APO_NOTIFICATION; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NS:audioengineextensionapo.APO_NOTIFICATION")] [StructLayout(LayoutKind.Explicit)] public struct APO_NOTIFICATION { /// A value from the APO_NOTIFICATION_TYPE enumeration specifying the type of change the notification represents. [FieldOffset(0)] public APO_NOTIFICATION_TYPE type; /// An AUDIO_ENDPOINT_VOLUME_CHANGE_NOTIFICATION representing a notification of a change to APO endpoint volume. [FieldOffset(8)] public AUDIO_ENDPOINT_VOLUME_CHANGE_NOTIFICATION audioEndpointVolumeChange; /// An AUDIO_ENDPOINT_PROPERTY_CHANGE_NOTIFICATION representing a notification of a change to an APO endpoint property. [FieldOffset(8)] public AUDIO_ENDPOINT_PROPERTY_CHANGE_NOTIFICATION audioEndpointPropertyChange; /// /// An AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_NOTIFICATION representing a notification of a change to an APO system effect property. /// [FieldOffset(8)] public AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_NOTIFICATION audioSystemEffectsPropertyChange; /// Used when type is APO_NOTIFICATION_TYPE_ENDPOINT_VOLUME2. [FieldOffset(8)] public AUDIO_ENDPOINT_VOLUME_CHANGE_NOTIFICATION2 audioEndpointVolumeChange2; /// Used when type is APO_NOTIFICATION_TYPE_DEVICE_ORIENTATION. [FieldOffset(8)] public DEVICE_ORIENTATION_TYPE deviceOrientation; /// Used when type is APO_NOTIFICATION_TYPE_MICROPHONE_BOOST. [FieldOffset(8)] public AUDIO_MICROPHONE_BOOST_NOTIFICATION audioMicrophoneBoostChange; } /// Specifies a requested APO notification. /// /// Return this structure from an implementation ofIAudioProcessingObjectNotifications::GetApoNotificationRegistrationInfo to specify a /// requested APO notifications. /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ns-audioengineextensionapo-apo_notification_descriptor // typedef struct APO_NOTIFICATION_DESCRIPTOR { APO_NOTIFICATION_TYPE type; union { AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR // audioEndpointVolume; AUDIO_ENDPOINT_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR audioEndpointPropertyChange; // AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR audioSystemEffectsPropertyChange; // AUDIO_MICROPHONE_BOOST_APO_NOTIFICATION_DESCRIPTOR audioMicrophoneBoost; } DUMMYUNIONNAME; } APO_NOTIFICATION_DESCRIPTOR; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NS:audioengineextensionapo.APO_NOTIFICATION_DESCRIPTOR")] [StructLayout(LayoutKind.Explicit)] public struct APO_NOTIFICATION_DESCRIPTOR { /// A value from the APO_NOTIFICATION_TYPE enumeration [FieldOffset(0)] public APO_NOTIFICATION_TYPE type; /// An AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR specifying an endpoint volume change APO notification. [FieldOffset(8)] public AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR audioEndpointVolume; /// An AUDIO_ENDPOINT_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR specifying an endpoint property change APO notification. [FieldOffset(8)] public AUDIO_ENDPOINT_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR audioEndpointPropertyChange; /// /// An AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR specifying a system effects property change APO notification. /// [FieldOffset(8)] public AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR audioSystemEffectsPropertyChange; /// Used for microphone boost notifications. [FieldOffset(8)] public AUDIO_MICROPHONE_BOOST_APO_NOTIFICATION_DESCRIPTOR audioMicrophoneBoost; } /// /// Provides audio processing object (APO) initialization parameters, extending APOInitSystemEffects2 to add the ability to specify a /// service provider for logging. /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ns-audioengineextensionapo-apoinitsystemeffects3 typedef // struct APOInitSystemEffects3 { APOInitBaseStruct APOInit; IPropertyStore *pAPOEndpointProperties; IServiceProvider *pServiceProvider; // IMMDeviceCollection *pDeviceCollection; UINT nSoftwareIoDeviceInCollection; UINT nSoftwareIoConnectorIndex; GUID AudioProcessingMode; // BOOL InitializeForDiscoveryOnly; } APOInitSystemEffects3; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NS:audioengineextensionapo.APOInitSystemEffects3")] [StructLayout(LayoutKind.Sequential)] public struct APOInitSystemEffects3 { /// An APOInitBaseStruct structure. public APOInitBaseStruct APOInit; /// A pointer to an ../propsys/nn-propsys-ipropertystore object. [MarshalAs(UnmanagedType.Interface)] public IPropertyStore pAPOEndpointProperties; /// An IServiceProvider interface. public IServiceProvider pServiceProvider; /// /// A pointer to an IMMDeviceCollection object. The last item in the pDeviceCollection is always the IMMDevice representing the audio endpoint. /// [MarshalAs(UnmanagedType.Interface)] public IMMDeviceCollection pDeviceCollection; /// /// Specifies the MMDevice that implements the DeviceTopology that includes the software connector for which the APO is /// initializing. The MMDevice is contained in pDeviceCollection. /// public uint nSoftwareIoDeviceInCollection; /// Specifies the index of a Software_IO connector in the DeviceTopology. public uint nSoftwareIoConnectorIndex; /// Specifies the processing mode for the audio graph. public Guid AudioProcessingMode; /// Indicates whether the audio system is initializing the APO for effects discovery only. [MarshalAs(UnmanagedType.Bool)] public bool InitializeForDiscoveryOnly; } /// Specifies an endpoint property change APO notification. /// /// Return an APO_NOTIFICATION_DESCRIPTOR containing this structure from an implementation /// ofIAudioProcessingObjectNotifications::GetApoNotificationRegistrationInfo to request endpoint property change APO notifications. /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ns-audioengineextensionapo-audio_endpoint_property_change_apo_notification_descriptor // typedef struct AUDIO_ENDPOINT_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR { IMMDevice *device; } AUDIO_ENDPOINT_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NS:audioengineextensionapo.AUDIO_ENDPOINT_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR")] [StructLayout(LayoutKind.Sequential)] public struct AUDIO_ENDPOINT_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR { /// An IMMDevice representing the audio endpoint associated with the notification. [MarshalAs(UnmanagedType.Interface)] public IMMDevice device; } /// Represents a property change APO notification. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ns-audioengineextensionapo-audio_endpoint_property_change_notification // typedef struct AUDIO_ENDPOINT_PROPERTY_CHANGE_NOTIFICATION { IMMDevice *endpoint; IPropertyStore *propertyStore; PROPERTYKEY // propertyKey; } AUDIO_ENDPOINT_PROPERTY_CHANGE_NOTIFICATION; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NS:audioengineextensionapo.AUDIO_ENDPOINT_PROPERTY_CHANGE_NOTIFICATION")] [StructLayout(LayoutKind.Sequential)] public struct AUDIO_ENDPOINT_PROPERTY_CHANGE_NOTIFICATION { /// An IMMDevice representing the audio endpoint associated with the notification. [MarshalAs(UnmanagedType.Interface)] public IMMDevice endpoint; /// An IPropertyStore representing the property store associated with the notification. [MarshalAs(UnmanagedType.Interface)] public IPropertyStore propertyStore; /// A PROPERTYKEY structure identifying the property associated with the notification. public PROPERTYKEY propertyKey; } /// Specifies an endpoint volume APO notification. /// /// Return an APO_NOTIFICATION_DESCRIPTOR containing this structure from an implementation /// ofIAudioProcessingObjectNotifications::GetApoNotificationRegistrationInfo to request endpoint volume change APO notifications. /// // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ns-audioengineextensionapo-audio_endpoint_volume_apo_notification_descriptor // typedef struct AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR { IMMDevice *device; } AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NS:audioengineextensionapo.AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR")] [StructLayout(LayoutKind.Sequential)] public struct AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR { /// The IMMDevice representing the audio endpoint associated with the notification request. [MarshalAs(UnmanagedType.Interface)] public IMMDevice device; } /// Represents an audio endpoint volume change APO notification. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ns-audioengineextensionapo-audio_endpoint_volume_change_notification // typedef struct AUDIO_ENDPOINT_VOLUME_CHANGE_NOTIFICATION { IMMDevice *endpoint; PAUDIO_VOLUME_NOTIFICATION_DATA volume; } AUDIO_ENDPOINT_VOLUME_CHANGE_NOTIFICATION; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NS:audioengineextensionapo.AUDIO_ENDPOINT_VOLUME_CHANGE_NOTIFICATION")] [StructLayout(LayoutKind.Sequential)] public struct AUDIO_ENDPOINT_VOLUME_CHANGE_NOTIFICATION { /// An IMMDevice representing the audio endpoint associated with the notification. [MarshalAs(UnmanagedType.Interface)] public IMMDevice endpoint; /// A pointer to a AUDIO_VOLUME_NOTIFICATION_DATA representing the new endpoint volume. public IntPtr /*AUDIO_VOLUME_NOTIFICATION_DATA*/ volume; } /// Undocumented [PInvokeData("audioengineextensionapo.h")] [StructLayout(LayoutKind.Sequential)] public struct AUDIO_ENDPOINT_VOLUME_CHANGE_NOTIFICATION2 { /// Undocumented [MarshalAs(UnmanagedType.Interface)] public IMMDevice endpoint; /// Undocumented public IntPtr /*PAUDIO_VOLUME_NOTIFICATION_DATA2*/ volume; } /// Used to request microphone boost notifications. [StructLayout(LayoutKind.Sequential)] public struct AUDIO_MICROPHONE_BOOST_APO_NOTIFICATION_DESCRIPTOR { /// Undocumented [MarshalAs(UnmanagedType.Interface)] public IMMDevice device; } /// Undocumented [PInvokeData("audioengineextensionapo.h")] [StructLayout(LayoutKind.Sequential)] public struct AUDIO_MICROPHONE_BOOST_NOTIFICATION { /// Device associated with mic boost notification. [MarshalAs(UnmanagedType.Interface)] public IMMDevice endpoint; /// /// Context associated with the originator of the event. A client can use this method to keep track of control changes made by other /// processes and by the hardware. The functions IAudioVolumeLevel::SetLevel and IAudioMute::SetMute use the context. When this /// notification is recieved, a client can inspect the context Guid to discover whether it or another client is the source of the notification. /// public Guid eventContext; /// Indicates the presence of a "Microphone Boost" part (connector or subunit) of an audio capture device topology. [MarshalAs(UnmanagedType.Bool)] public bool microphoneBoostEnabled; /// The volume level in decibels. public float levelInDb; /// The minimum volume level in decibels. public float levelMinInDb; /// The maximum volume level in decibels. public float levelMaxInDb; /// The stepping value between consecutive volume levels in the range levelMinInDb to levelMaxInDb public float levelStepInDb; /// Indicates if the IAudioMute interface is supported by the "Microphone Boost" part of the audio capture device topology. [MarshalAs(UnmanagedType.Bool)] public bool muteSupported; /// The current state (enabled or disabled) of the mute control [MarshalAs(UnmanagedType.Bool)] public bool mute; } /// Represents a System Effects Audio Processing Object (sAPO) audio effect. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ns-audioengineextensionapo-audio_systemeffect typedef // struct AUDIO_SYSTEMEFFECT { GUID id; BOOL canSetState; AUDIO_SYSTEMEFFECT_STATE state; } AUDIO_SYSTEMEFFECT; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NS:audioengineextensionapo.AUDIO_SYSTEMEFFECT")] [StructLayout(LayoutKind.Sequential)] public struct AUDIO_SYSTEMEFFECT { /// The GUID identifier for an audio effect. Audio effect GUIDs are defined in ksmedia.h. public Guid id; /// A boolean value specifying whether the effect state can be modified. [MarshalAs(UnmanagedType.Bool)] public bool canSetState; /// A member of the AUDIO_SYSTEMEFFECT_STATE enumeration specifying the state of the audio effect. public AUDIO_SYSTEMEFFECT_STATE state; } /// Used to request audio system effects property change notifications on a specific endpoint and property context. [StructLayout(LayoutKind.Sequential)] public struct AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_APO_NOTIFICATION_DESCRIPTOR { /// Undocumented [MarshalAs(UnmanagedType.Interface)] public IMMDevice device; /// Undocumented public Guid propertyStoreContext; } /// Represents a system audio effect APO notification. // https://learn.microsoft.com/en-us/windows/win32/api/audioengineextensionapo/ns-audioengineextensionapo-audio_systemeffects_property_change_notification // typedef struct AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_NOTIFICATION { IMMDevice *endpoint; GUID propertyStoreContext; // AUDIO_SYSTEMEFFECTS_PROPERTYSTORE_TYPE propertyStoreType; IPropertyStore *propertyStore; PROPERTYKEY propertyKey; } AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_NOTIFICATION; [PInvokeData("audioengineextensionapo.h", MSDNShortId = "NS:audioengineextensionapo.AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_NOTIFICATION")] [StructLayout(LayoutKind.Sequential)] public struct AUDIO_SYSTEMEFFECTS_PROPERTY_CHANGE_NOTIFICATION { /// An IMMDevice representing the audio endpoint associated with the notification. [MarshalAs(UnmanagedType.Interface)] public IMMDevice endpoint; /// A GUID identifying the APO property store associated with the notification. public Guid propertyStoreContext; /// /// A value from the AUDIO_SYSTEMEFFECTS_PROPERTYSTORE_TYPE enumeration specifying the type of the property store associated with the notification. /// public AUDIO_SYSTEMEFFECTS_PROPERTYSTORE_TYPE propertyStoreType; /// An IPropertyStore representing the property store associated with the notification. [MarshalAs(UnmanagedType.Interface)] public IPropertyStore propertyStore; /// A PROPERTYKEY structure identifying the property associated with the notification. public PROPERTYKEY propertyKey; } /// Undocumented [PInvokeData("audioengineextensionapo.h")] [StructLayout(LayoutKind.Sequential)] public struct AUDIO_VOLUME_NOTIFICATION_DATA2 { /// Undocumented public IntPtr /*PAUDIO_VOLUME_NOTIFICATION_DATA*/ notificationData; /// Specifies the current master volume level of the audio stream in dB. public float masterVolumeInDb; /// /// The minimum volume level of the endpoint in decibels. This value remains constant for the lifetime of audio device specified in AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR. /// public float volumeMinInDb; /// /// The maximum volume level of the endpoint in decibels. This value remains constant for the lifetime of the audio device specified /// in AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR. /// public float volumeMaxInDb; /// /// The volume increment in decibels. This increment remains constant for the lifetime the audio device specified in AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR. /// public float volumeIncrementInDb; /// /// Current step in the volume range. 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. Audio applications can call the IAudioEndpointVolume::VolumeStepUp and /// IAudioEndpointVolume::VolumeStepDown methods to increase or decrease the volume level by one interval. /// public uint step; /// /// The number of steps in the volume range. This number remains constant for the lifetime of the audio device specified in AUDIO_ENDPOINT_VOLUME_APO_NOTIFICATION_DESCRIPTOR. /// public uint stepCount; /// /// The first element in an array of channel volumes in dB. 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_DATA2 structure. /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public float[] channelVolumesInDb; } }