IAudioEndpointVolume.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. // -----------------------------------------
  2. // SoundScribe (TM) and related software.
  3. //
  4. // Copyright (C) 2007-2011 Vannatech
  5. // http://www.vannatech.com
  6. // All rights reserved.
  7. //
  8. // This source code is subject to the MIT License.
  9. // http://www.opensource.org/licenses/mit-license.php
  10. //
  11. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. // THE SOFTWARE.
  18. // -----------------------------------------
  19. using System;
  20. using System.Runtime.InteropServices;
  21. namespace Vannatech.CoreAudio.Interfaces
  22. {
  23. /// <summary>
  24. /// Represents the volume controls on the audio stream to or from an audio endpoint device.
  25. /// </summary>
  26. /// <remarks>
  27. /// MSDN Reference: http://msdn.microsoft.com/en-us/library/dd370892.aspx
  28. /// </remarks>
  29. public partial interface IAudioEndpointVolume
  30. {
  31. // Note: Any changes to this interface should be repeated in IAudioEndpointVolumeEx.
  32. /// <summary>
  33. /// Registers a client's notification callback interface.
  34. /// </summary>
  35. /// <param name="client">The <see cref="IAudioEndpointVolumeCallback"/> interface that is registering for notification callbacks.</param>
  36. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  37. [PreserveSig]
  38. int RegisterControlChangeNotify(
  39. [In] [MarshalAs(UnmanagedType.Interface)] IAudioEndpointVolumeCallback client);
  40. /// <summary>
  41. /// Deletes the registration of a client's notification callback interface.
  42. /// </summary>
  43. /// <param name="client">The <see cref="IAudioEndpointVolumeCallback"/> interface that previously registered for notification callbacks.</param>
  44. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  45. [PreserveSig]
  46. int UnregisterControlChangeNotify(
  47. [In] [MarshalAs(UnmanagedType.Interface)] IAudioEndpointVolumeCallback client);
  48. /// <summary>
  49. /// Gets a count of the channels in the audio stream.
  50. /// </summary>
  51. /// <param name="channelCount">The number of channels.</param>
  52. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  53. [PreserveSig]
  54. int GetChannelCount(
  55. [Out] [MarshalAs(UnmanagedType.U4)] out UInt32 channelCount);
  56. /// <summary>
  57. /// Sets the master volume level of the audio stream, in decibels.
  58. /// </summary>
  59. /// <param name="level">The new master volume level in decibels.</param>
  60. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  61. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  62. [PreserveSig]
  63. int SetMasterVolumeLevel(
  64. [In] [MarshalAs(UnmanagedType.R4)] float level,
  65. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  66. /// <summary>
  67. /// Sets the master volume level, expressed as a normalized, audio-tapered value.
  68. /// </summary>
  69. /// <param name="level">The new master volume level expressed as a normalized value between 0.0 and 1.0.</param>
  70. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  71. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  72. [PreserveSig]
  73. int SetMasterVolumeLevelScalar(
  74. [In] [MarshalAs(UnmanagedType.R4)] float level,
  75. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  76. /// <summary>
  77. /// Gets the master volume level of the audio stream, in decibels.
  78. /// </summary>
  79. /// <param name="level">The volume level in decibels.</param>
  80. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  81. [PreserveSig]
  82. int GetMasterVolumeLevel(
  83. [Out] [MarshalAs(UnmanagedType.R4)] out float level);
  84. /// <summary>
  85. /// Gets the master volume level, expressed as a normalized, audio-tapered value.
  86. /// </summary>
  87. /// <param name="level">The volume level expressed as a normalized value between 0.0 and 1.0.</param>
  88. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  89. [PreserveSig]
  90. int GetMasterVolumeLevelScalar(
  91. [Out] [MarshalAs(UnmanagedType.R4)] out float level);
  92. /// <summary>
  93. /// Sets the volume level, in decibels, of the specified channel of the audio stream.
  94. /// </summary>
  95. /// <param name="channelNumber">The channel number.</param>
  96. /// <param name="level">The new volume level in decibels.</param>
  97. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  98. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  99. [PreserveSig]
  100. int SetChannelVolumeLevel(
  101. [In] [MarshalAs(UnmanagedType.U4)] UInt32 channelNumber,
  102. [In] [MarshalAs(UnmanagedType.R4)] float level,
  103. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  104. /// <summary>
  105. /// Sets the normalized, audio-tapered volume level of the specified channel in the audio stream.
  106. /// </summary>
  107. /// <param name="channelNumber">The channel number.</param>
  108. /// <param name="level">The new master volume level expressed as a normalized value between 0.0 and 1.0.</param>
  109. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  110. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  111. [PreserveSig]
  112. int SetChannelVolumeLevelScalar(
  113. [In] [MarshalAs(UnmanagedType.U4)] UInt32 channelNumber,
  114. [In] [MarshalAs(UnmanagedType.R4)] float level,
  115. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  116. /// <summary>
  117. /// Gets the volume level, in decibels, of the specified channel in the audio stream.
  118. /// </summary>
  119. /// <param name="channelNumber">The zero-based channel number.</param>
  120. /// <param name="level">The volume level in decibels.</param>
  121. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  122. [PreserveSig]
  123. int GetChannelVolumeLevel(
  124. [In] [MarshalAs(UnmanagedType.U4)] UInt32 channelNumber,
  125. [Out] [MarshalAs(UnmanagedType.R4)] out float level);
  126. /// <summary>
  127. /// Gets the normalized, audio-tapered volume level of the specified channel of the audio stream.
  128. /// </summary>
  129. /// <param name="channelNumber">The zero-based channel number.</param>
  130. /// <param name="level">The volume level expressed as a normalized value between 0.0 and 1.0.</param>
  131. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  132. [PreserveSig]
  133. int GetChannelVolumeLevelScalar(
  134. [In] [MarshalAs(UnmanagedType.U4)] UInt32 channelNumber,
  135. [Out] [MarshalAs(UnmanagedType.R4)] out float level);
  136. /// <summary>
  137. /// Sets the muting state of the audio stream.
  138. /// </summary>
  139. /// <param name="isMuted">True to mute the stream, or false to unmute the stream.</param>
  140. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  141. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  142. [PreserveSig]
  143. int SetMute(
  144. [In] [MarshalAs(UnmanagedType.Bool)] Boolean isMuted,
  145. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  146. /// <summary>
  147. /// Gets the muting state of the audio stream.
  148. /// </summary>
  149. /// <param name="isMuted">The muting state. True if the stream is muted, false otherwise.</param>
  150. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  151. [PreserveSig]
  152. int GetMute(
  153. [Out] [MarshalAs(UnmanagedType.Bool)] out Boolean isMuted);
  154. /// <summary>
  155. /// Gets information about the current step in the volume range.
  156. /// </summary>
  157. /// <param name="step">The current zero-based step index.</param>
  158. /// <param name="stepCount">The total number of steps in the volume range.</param>
  159. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  160. [PreserveSig]
  161. int GetVolumeStepInfo(
  162. [Out] [MarshalAs(UnmanagedType.U4)] out UInt32 step,
  163. [Out] [MarshalAs(UnmanagedType.U4)] out UInt32 stepCount);
  164. /// <summary>
  165. /// Increases the volume level by one step.
  166. /// </summary>
  167. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  168. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  169. [PreserveSig]
  170. int VolumeStepUp(
  171. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  172. /// <summary>
  173. /// Decreases the volume level by one step.
  174. /// </summary>
  175. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  176. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  177. [PreserveSig]
  178. int VolumeStepDown(
  179. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  180. /// <summary>
  181. /// Queries the audio endpoint device for its hardware-supported functions.
  182. /// </summary>
  183. /// <param name="hardwareSupportMask">A hardware support mask that indicates the capabilities of the endpoint.</param>
  184. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  185. [PreserveSig]
  186. int QueryHardwareSupport(
  187. [Out] [MarshalAs(UnmanagedType.U4)] out UInt32 hardwareSupportMask);
  188. /// <summary>
  189. /// Gets the volume range of the audio stream, in decibels.
  190. /// </summary>
  191. /// <param name="volumeMin">The minimum volume level in decibels.</param>
  192. /// <param name="volumeMax">The maximum volume level in decibels.</param>
  193. /// <param name="volumeStep">The volume increment level in decibels.</param>
  194. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  195. [PreserveSig]
  196. int GetVolumeRange(
  197. [Out] [MarshalAs(UnmanagedType.R4)] out float volumeMin,
  198. [Out] [MarshalAs(UnmanagedType.R4)] out float volumeMax,
  199. [Out] [MarshalAs(UnmanagedType.R4)] out float volumeStep);
  200. }
  201. }