Advertisement
Guest User

Untitled

a guest
Apr 14th, 2019
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Script originally from David Shine! (youtube: https://www.youtube.com/watch?v=BUyzpLihfzE)
  2.  
  3. device := VA_GetDevice("Playback")
  4. audioMeter := VA_GetAudioMeter(device)
  5. silenceTimer := 0
  6.  
  7. VA_IAudioMeterInformation_GetMeteringChannelCount(audioMeter, channelCount)
  8.  
  9. ; "The peak value for each channel is recorded over one device
  10. ;  period and made available during the subsequent device period."
  11. VA_GetDevicePeriod("playback", devicePeriod)
  12. Loop
  13. {
  14. if(peakValue < 0.00001) ;if no sound
  15.  {
  16.   if(silenceTimer >= 6) ;If the silence timer is >= 6 means silence for 3 seconds (6 * 500)
  17.   {
  18.    send, {media_play_pause}
  19.    silenceTimer = 0
  20.   }
  21.   else{
  22.    silenceTimer++
  23.   }
  24.  
  25.  }
  26.  else{ ;if some sound
  27.   silenceTimer = 0
  28.  }
  29.  sleep 500
  30.  
  31.     ; Get the peak value across all channels.
  32.     VA_IAudioMeterInformation_GetPeakValue(audioMeter, peakValue)    
  33.     meter := MakeMeter(peakValue, MeterLength)
  34.    
  35.     ; Get the peak values of all channels.
  36.     VarSetCapacity(peakValues, channelCount*4)
  37.     VA_IAudioMeterInformation_GetChannelsPeakValues(audioMeter, channelCount, &peakValues)
  38.     Loop %channelCount%
  39.         meter .= "`n" MakeMeter(NumGet(peakValues, A_Index*4-4, "float"), MeterLength)
  40.  
  41. ;ToolTip, %meter% %A_index%
  42.     Sleep, %devicePeriod%
  43. }
  44. MakeMeter(fraction, size)
  45. {
  46.     global MeterLength
  47.     Loop % fraction*size
  48.         meter .= "|"
  49.     Loop % (1-fraction)*size
  50.         meter .= "."
  51.     meter .= "  " fraction
  52.     return meter
  53. }  
  54. f12::pause
  55. f2::Media_play_pause
  56.  
  57.  
  58. ; VA v2.3
  59.  
  60. ; MASTER CONTROLS
  61.  
  62. VA_GetMasterVolume(channel="", device_desc="playback")
  63. {
  64.     if ! aev := VA_GetAudioEndpointVolume(device_desc)
  65.         return
  66.     if channel =
  67.         VA_IAudioEndpointVolume_GetMasterVolumeLevelScalar(aev, vol)
  68.     else
  69.         VA_IAudioEndpointVolume_GetChannelVolumeLevelScalar(aev, channel-1, vol)
  70.     ObjRelease(aev)
  71.     return Round(vol*100,3)
  72. }
  73.  
  74. VA_SetMasterVolume(vol, channel="", device_desc="playback")
  75. {
  76.     vol := vol>100 ? 100 : vol<0 ? 0 : vol
  77.     if ! aev := VA_GetAudioEndpointVolume(device_desc)
  78.         return
  79.     if channel =
  80.         VA_IAudioEndpointVolume_SetMasterVolumeLevelScalar(aev, vol/100)
  81.     else
  82.         VA_IAudioEndpointVolume_SetChannelVolumeLevelScalar(aev, channel-1, vol/100)
  83.     ObjRelease(aev)
  84. }
  85.  
  86. VA_GetMasterChannelCount(device_desc="playback")
  87. {
  88.     if ! aev := VA_GetAudioEndpointVolume(device_desc)
  89.         return
  90.     VA_IAudioEndpointVolume_GetChannelCount(aev, count)
  91.     ObjRelease(aev)
  92.     return count
  93. }
  94.  
  95. VA_SetMasterMute(mute, device_desc="playback")
  96. {
  97.     if ! aev := VA_GetAudioEndpointVolume(device_desc)
  98.         return
  99.     VA_IAudioEndpointVolume_SetMute(aev, mute)
  100.     ObjRelease(aev)
  101. }
  102.  
  103. VA_GetMasterMute(device_desc="playback")
  104. {
  105.     if ! aev := VA_GetAudioEndpointVolume(device_desc)
  106.         return
  107.     VA_IAudioEndpointVolume_GetMute(aev, mute)
  108.     ObjRelease(aev)
  109.     return mute
  110. }
  111.  
  112. ;
  113. ; SUBUNIT CONTROLS
  114. ;
  115.  
  116. VA_GetVolume(subunit_desc="1", channel="", device_desc="playback")
  117. {
  118.     if ! avl := VA_GetDeviceSubunit(device_desc, subunit_desc, "{7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC}")
  119.         return
  120.     VA_IPerChannelDbLevel_GetChannelCount(avl, channel_count)
  121.     if channel =
  122.     {
  123.         vol = 0
  124.        
  125.         Loop, %channel_count%
  126.         {
  127.             VA_IPerChannelDbLevel_GetLevelRange(avl, A_Index-1, min_dB, max_dB, step_dB)
  128.             VA_IPerChannelDbLevel_GetLevel(avl, A_Index-1, this_vol)
  129.             this_vol := VA_dB2Scalar(this_vol, min_dB, max_dB)
  130.            
  131.             ; "Speakers Properties" reports the highest channel as the volume.
  132.             if (this_vol > vol)
  133.                 vol := this_vol
  134.         }
  135.     }
  136.     else if channel between 1 and channel_count
  137.     {
  138.         channel -= 1
  139.         VA_IPerChannelDbLevel_GetLevelRange(avl, channel, min_dB, max_dB, step_dB)
  140.         VA_IPerChannelDbLevel_GetLevel(avl, channel, vol)
  141.         vol := VA_dB2Scalar(vol, min_dB, max_dB)
  142.     }
  143.     ObjRelease(avl)
  144.     return vol
  145. }
  146.  
  147. VA_SetVolume(vol, subunit_desc="1", channel="", device_desc="playback")
  148. {
  149.     if ! avl := VA_GetDeviceSubunit(device_desc, subunit_desc, "{7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC}")
  150.         return
  151.    
  152.     vol := vol<0 ? 0 : vol>100 ? 100 : vol
  153.    
  154.     VA_IPerChannelDbLevel_GetChannelCount(avl, channel_count)
  155.    
  156.     if channel =
  157.     {
  158.         ; Simple method -- resets balance to "center":
  159.         ;VA_IPerChannelDbLevel_SetLevelUniform(avl, vol)
  160.        
  161.         vol_max = 0
  162.        
  163.         Loop, %channel_count%
  164.         {
  165.             VA_IPerChannelDbLevel_GetLevelRange(avl, A_Index-1, min_dB, max_dB, step_dB)
  166.             VA_IPerChannelDbLevel_GetLevel(avl, A_Index-1, this_vol)
  167.             this_vol := VA_dB2Scalar(this_vol, min_dB, max_dB)
  168.            
  169.             channel%A_Index%vol := this_vol
  170.             channel%A_Index%min := min_dB
  171.             channel%A_Index%max := max_dB
  172.            
  173.             ; Scale all channels relative to the loudest channel.
  174.             ; (This is how Vista's "Speakers Properties" dialog seems to work.)
  175.             if (this_vol > vol_max)
  176.                 vol_max := this_vol
  177.         }
  178.        
  179.         Loop, %channel_count%
  180.         {
  181.             this_vol := vol_max ? channel%A_Index%vol / vol_max * vol : vol
  182.             this_vol := VA_Scalar2dB(this_vol/100, channel%A_Index%min, channel%A_Index%max)            
  183.             VA_IPerChannelDbLevel_SetLevel(avl, A_Index-1, this_vol)
  184.         }
  185.     }
  186.     else if channel between 1 and %channel_count%
  187.     {
  188.         channel -= 1
  189.         VA_IPerChannelDbLevel_GetLevelRange(avl, channel, min_dB, max_dB, step_dB)
  190.         VA_IPerChannelDbLevel_SetLevel(avl, channel, VA_Scalar2dB(vol/100, min_dB, max_dB))
  191.     }
  192.     ObjRelease(avl)
  193. }
  194.  
  195. VA_GetChannelCount(subunit_desc="1", device_desc="playback")
  196. {
  197.     if ! avl := VA_GetDeviceSubunit(device_desc, subunit_desc, "{7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC}")
  198.         return
  199.     VA_IPerChannelDbLevel_GetChannelCount(avl, channel_count)
  200.     ObjRelease(avl)
  201.     return channel_count
  202. }
  203.  
  204. VA_SetMute(mute, subunit_desc="1", device_desc="playback")
  205. {
  206.     if ! amute := VA_GetDeviceSubunit(device_desc, subunit_desc, "{DF45AEEA-B74A-4B6B-AFAD-2366B6AA012E}")
  207.         return
  208.     VA_IAudioMute_SetMute(amute, mute)
  209.     ObjRelease(amute)
  210. }
  211.  
  212. VA_GetMute(subunit_desc="1", device_desc="playback")
  213. {
  214.     if ! amute := VA_GetDeviceSubunit(device_desc, subunit_desc, "{DF45AEEA-B74A-4B6B-AFAD-2366B6AA012E}")
  215.         return
  216.     VA_IAudioMute_GetMute(amute, muted)
  217.     ObjRelease(amute)
  218.     return muted
  219. }
  220.  
  221. ;
  222. ; AUDIO METERING
  223. ;
  224.  
  225. VA_GetAudioMeter(device_desc="playback")
  226. {
  227.     if ! device := VA_GetDevice(device_desc)
  228.         return 0
  229.     VA_IMMDevice_Activate(device, "{C02216F6-8C67-4B5B-9D00-D008E73E0064}", 7, 0, audioMeter)
  230.     ObjRelease(device)
  231.     return audioMeter
  232. }
  233.  
  234. VA_GetDevicePeriod(device_desc, ByRef default_period, ByRef minimum_period="")
  235. {
  236.     defaultPeriod := minimumPeriod := 0
  237.     if ! device := VA_GetDevice(device_desc)
  238.         return false
  239.     VA_IMMDevice_Activate(device, "{1CB9AD4C-DBFA-4c32-B178-C2F568A703B2}", 7, 0, audioClient)
  240.     ObjRelease(device)
  241.     ; IAudioClient::GetDevicePeriod
  242.     DllCall(NumGet(NumGet(audioClient+0)+9*A_PtrSize), "ptr",audioClient, "int64*",default_period, "int64*",minimum_period)
  243.     ; Convert 100-nanosecond units to milliseconds.
  244.     default_period /= 10000
  245.     minimum_period /= 10000    
  246.     ObjRelease(audioClient)
  247.     return true
  248. }
  249.  
  250. VA_GetAudioEndpointVolume(device_desc="playback")
  251. {
  252.     if ! device := VA_GetDevice(device_desc)
  253.         return 0
  254.     VA_IMMDevice_Activate(device, "{5CDF2C82-841E-4546-9722-0CF74078229A}", 7, 0, endpointVolume)
  255.     ObjRelease(device)
  256.     return endpointVolume
  257. }
  258.  
  259. VA_GetDeviceSubunit(device_desc, subunit_desc, subunit_iid)
  260. {
  261.     if ! device := VA_GetDevice(device_desc)
  262.         return 0
  263.     subunit := VA_FindSubunit(device, subunit_desc, subunit_iid)
  264.     ObjRelease(device)
  265.     return subunit
  266. }
  267.  
  268. VA_FindSubunit(device, target_desc, target_iid)
  269. {
  270.     if target_desc is integer
  271.         target_index := target_desc
  272.     else
  273.         RegExMatch(target_desc, "(?<_name>.*?)(?::(?<_index>\d+))?$", target)
  274.     ; v2.01: Since target_name is now a regular expression, default to case-insensitive mode if no options are specified.
  275.     if !RegExMatch(target_name,"^[^\(]+\)")
  276.         target_name := "i)" target_name
  277.     r := VA_EnumSubunits(device, "VA_FindSubunitCallback", target_name, target_iid
  278.             , Object(0, target_index ? target_index : 1, 1, 0))
  279.     return r
  280. }
  281.  
  282. VA_FindSubunitCallback(part, interface, index)
  283. {
  284.     index[1] := index[1] + 1 ; current += 1
  285.     if (index[0] == index[1]) ; target == current ?
  286.     {
  287.         ObjAddRef(interface)
  288.         return interface
  289.     }
  290. }
  291.  
  292. VA_EnumSubunits(device, callback, target_name="", target_iid="", callback_param="")
  293. {
  294.     VA_IMMDevice_Activate(device, "{2A07407E-6497-4A18-9787-32F79BD0D98F}", 7, 0, deviceTopology)
  295.     VA_IDeviceTopology_GetConnector(deviceTopology, 0, conn)
  296.     ObjRelease(deviceTopology)
  297.     VA_IConnector_GetConnectedTo(conn, conn_to)
  298.     VA_IConnector_GetDataFlow(conn, data_flow)
  299.     ObjRelease(conn)
  300.     if !conn_to
  301.         return ; blank to indicate error
  302.     part := ComObjQuery(conn_to, "{AE2DE0E4-5BCA-4F2D-AA46-5D13F8FDB3A9}") ; IID_IPart
  303.     ObjRelease(conn_to)
  304.     if !part
  305.         return
  306.     r := VA_EnumSubunitsEx(part, data_flow, callback, target_name, target_iid, callback_param)
  307.     ObjRelease(part)
  308.     return r ; value returned by callback, or zero.
  309. }
  310.  
  311. VA_EnumSubunitsEx(part, data_flow, callback, target_name="", target_iid="", callback_param="")
  312. {
  313.     r := 0
  314.    
  315.     VA_IPart_GetPartType(part, type)
  316.    
  317.     if type = 1 ; Subunit
  318.     {
  319.         VA_IPart_GetName(part, name)
  320.        
  321.         ; v2.01: target_name is now a regular expression.
  322.         if RegExMatch(name, target_name)
  323.         {
  324.             if target_iid =
  325.                 r := %callback%(part, 0, callback_param)
  326.             else
  327.                 if VA_IPart_Activate(part, 7, target_iid, interface) = 0
  328.                 {
  329.                     r := %callback%(part, interface, callback_param)
  330.                     ; The callback is responsible for calling ObjAddRef()
  331.                     ; if it intends to keep the interface pointer.
  332.                     ObjRelease(interface)
  333.                 }
  334.  
  335.             if r
  336.                 return r ; early termination
  337.         }
  338.     }
  339.    
  340.     if data_flow = 0
  341.         VA_IPart_EnumPartsIncoming(part, parts)
  342.     else
  343.         VA_IPart_EnumPartsOutgoing(part, parts)
  344.    
  345.     VA_IPartsList_GetCount(parts, count)
  346.     Loop %count%
  347.     {
  348.         VA_IPartsList_GetPart(parts, A_Index-1, subpart)        
  349.         r := VA_EnumSubunitsEx(subpart, data_flow, callback, target_name, target_iid, callback_param)
  350.         ObjRelease(subpart)
  351.         if r
  352.             break ; early termination
  353.     }
  354.     ObjRelease(parts)
  355.     return r ; continue/finished enumeration
  356. }
  357.  
  358. ; device_desc = device_id
  359. ;               | ( friendly_name | 'playback' | 'capture' ) [ ':' index ]
  360. VA_GetDevice(device_desc="playback")
  361. {
  362.     static CLSID_MMDeviceEnumerator := "{BCDE0395-E52F-467C-8E3D-C4579291692E}"
  363.         , IID_IMMDeviceEnumerator := "{A95664D2-9614-4F35-A746-DE8DB63617E6}"
  364.     if !(deviceEnumerator := ComObjCreate(CLSID_MMDeviceEnumerator, IID_IMMDeviceEnumerator))
  365.         return 0
  366.    
  367.     device := 0
  368.    
  369.     if VA_IMMDeviceEnumerator_GetDevice(deviceEnumerator, device_desc, device) = 0
  370.         goto VA_GetDevice_Return
  371.    
  372.     if device_desc is integer
  373.     {
  374.         m2 := device_desc
  375.         if m2 >= 4096 ; Probably a device pointer, passed here indirectly via VA_GetAudioMeter or such.
  376.         {
  377.             ObjAddRef(device := m2)
  378.             goto VA_GetDevice_Return
  379.         }
  380.     }
  381.     else
  382.         RegExMatch(device_desc, "(.*?)\s*(?::(\d+))?$", m)
  383.    
  384.     if m1 in playback,p
  385.         m1 := "", flow := 0 ; eRender
  386.     else if m1 in capture,c
  387.         m1 := "", flow := 1 ; eCapture
  388.     else if (m1 . m2) = ""  ; no name or number specified
  389.         m1 := "", flow := 0 ; eRender (default)
  390.     else
  391.         flow := 2 ; eAll
  392.    
  393.     if (m1 . m2) = ""   ; no name or number (maybe "playback" or "capture")
  394.     {
  395.         VA_IMMDeviceEnumerator_GetDefaultAudioEndpoint(deviceEnumerator, flow, 0, device)
  396.         goto VA_GetDevice_Return
  397.     }
  398.  
  399.     VA_IMMDeviceEnumerator_EnumAudioEndpoints(deviceEnumerator, flow, 1, devices)
  400.    
  401.     if m1 =
  402.     {
  403.         VA_IMMDeviceCollection_Item(devices, m2-1, device)
  404.         goto VA_GetDevice_Return
  405.     }
  406.    
  407.     VA_IMMDeviceCollection_GetCount(devices, count)
  408.     index := 0
  409.     Loop % count
  410.         if VA_IMMDeviceCollection_Item(devices, A_Index-1, device) = 0
  411.             if InStr(VA_GetDeviceName(device), m1) && (m2 = "" || ++index = m2)
  412.                 goto VA_GetDevice_Return
  413.             else
  414.                 ObjRelease(device), device:=0
  415.  
  416. VA_GetDevice_Return:
  417.    ObjRelease(deviceEnumerator)
  418.     if devices
  419.         ObjRelease(devices)
  420.    
  421.     return device ; may be 0
  422. }
  423.  
  424. VA_GetDeviceName(device)
  425. {
  426.     static PKEY_Device_FriendlyName
  427.     if !VarSetCapacity(PKEY_Device_FriendlyName)
  428.         VarSetCapacity(PKEY_Device_FriendlyName, 20)
  429.         ,VA_GUID(PKEY_Device_FriendlyName :="{A45C254E-DF1C-4EFD-8020-67D146A850E0}")
  430.         ,NumPut(14, PKEY_Device_FriendlyName, 16)
  431.     VarSetCapacity(prop, 16)
  432.     VA_IMMDevice_OpenPropertyStore(device, 0, store)
  433.     ; store->GetValue(.., [out] prop)
  434.     DllCall(NumGet(NumGet(store+0)+5*A_PtrSize), "ptr", store, "ptr", &PKEY_Device_FriendlyName, "ptr", &prop)
  435.     ObjRelease(store)
  436.     VA_WStrOut(deviceName := NumGet(prop,8))
  437.     return deviceName
  438. }
  439.  
  440. VA_SetDefaultEndpoint(device_desc, role)
  441. {
  442.     /* Roles:
  443.          eConsole        = 0  ; Default Device
  444.          eMultimedia     = 1
  445.          eCommunications = 2  ; Default Communications Device
  446.     */
  447.     if ! device := VA_GetDevice(device_desc)
  448.         return 0
  449.     if VA_IMMDevice_GetId(device, id) = 0
  450.     {
  451.         cfg := ComObjCreate("{294935CE-F637-4E7C-A41B-AB255460B862}"
  452.                           , "{568b9108-44bf-40b4-9006-86afe5b5a620}")
  453.         hr := VA_xIPolicyConfigVista_SetDefaultEndpoint(cfg, id, role)
  454.         ObjRelease(cfg)
  455.     }
  456.     ObjRelease(device)
  457.     return hr = 0
  458. }
  459.  
  460.  
  461. ;
  462. ; HELPERS
  463. ;
  464.  
  465. ; Convert string to binary GUID structure.
  466. VA_GUID(ByRef guid_out, guid_in="%guid_out%") {
  467.     if (guid_in == "%guid_out%")
  468.         guid_in :=   guid_out
  469.     if  guid_in is integer
  470.         return guid_in
  471.     VarSetCapacity(guid_out, 16, 0)
  472.     DllCall("ole32\CLSIDFromString", "wstr", guid_in, "ptr", &guid_out)
  473.     return &guid_out
  474. }
  475.  
  476. ; Convert binary GUID structure to string.
  477. VA_GUIDOut(ByRef guid) {
  478.     VarSetCapacity(buf, 78)
  479.     DllCall("ole32\StringFromGUID2", "ptr", &guid, "ptr", &buf, "int", 39)
  480.     guid := StrGet(&buf, "UTF-16")
  481. }
  482.  
  483. ; Convert COM-allocated wide char string pointer to usable string.
  484. VA_WStrOut(ByRef str) {
  485.     str := StrGet(ptr := str, "UTF-16")
  486.     DllCall("ole32\CoTaskMemFree", "ptr", ptr)  ; FREES THE STRING.
  487. }
  488.  
  489. VA_dB2Scalar(dB, min_dB, max_dB) {
  490.     min_s := 10**(min_dB/20), max_s := 10**(max_dB/20)
  491.     return ((10**(dB/20))-min_s)/(max_s-min_s)*100
  492. }
  493.  
  494. VA_Scalar2dB(s, min_dB, max_dB) {
  495.     min_s := 10**(min_dB/20), max_s := 10**(max_dB/20)
  496.     return log((max_s-min_s)*s+min_s)*20
  497. }
  498.  
  499.  
  500. ;
  501. ; INTERFACE WRAPPERS
  502. ;   Reference: Core Audio APIs in Windows Vista -- Programming Reference
  503. ;       http://msdn2.microsoft.com/en-us/library/ms679156(VS.85).aspx
  504. ;
  505.  
  506. ;
  507. ; IMMDevice : {D666063F-1587-4E43-81F1-B948E807363F}
  508. ;
  509. VA_IMMDevice_Activate(this, iid, ClsCtx, ActivationParams, ByRef Interface) {
  510.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr", VA_GUID(iid), "uint", ClsCtx, "uint", ActivationParams, "ptr*", Interface)
  511. }
  512. VA_IMMDevice_OpenPropertyStore(this, Access, ByRef Properties) {
  513.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", Access, "ptr*", Properties)
  514. }
  515. VA_IMMDevice_GetId(this, ByRef Id) {
  516.     hr := DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint*", Id)
  517.     VA_WStrOut(Id)
  518.     return hr
  519. }
  520. VA_IMMDevice_GetState(this, ByRef State) {
  521.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint*", State)
  522. }
  523.  
  524. ;
  525. ; IDeviceTopology : {2A07407E-6497-4A18-9787-32F79BD0D98F}
  526. ;
  527. VA_IDeviceTopology_GetConnectorCount(this, ByRef Count) {
  528.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "uint*", Count)
  529. }
  530. VA_IDeviceTopology_GetConnector(this, Index, ByRef Connector) {
  531.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", Index, "ptr*", Connector)
  532. }
  533. VA_IDeviceTopology_GetSubunitCount(this, ByRef Count) {
  534.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint*", Count)
  535. }
  536. VA_IDeviceTopology_GetSubunit(this, Index, ByRef Subunit) {
  537.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint", Index, "ptr*", Subunit)
  538. }
  539. VA_IDeviceTopology_GetPartById(this, Id, ByRef Part) {
  540.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "uint", Id, "ptr*", Part)
  541. }
  542. VA_IDeviceTopology_GetDeviceId(this, ByRef DeviceId) {
  543.     hr := DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "uint*", DeviceId)
  544.     VA_WStrOut(DeviceId)
  545.     return hr
  546. }
  547. VA_IDeviceTopology_GetSignalPath(this, PartFrom, PartTo, RejectMixedPaths, ByRef Parts) {
  548.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "ptr", PartFrom, "ptr", PartTo, "int", RejectMixedPaths, "ptr*", Parts)
  549. }
  550.  
  551. ;
  552. ; IConnector : {9c2c4058-23f5-41de-877a-df3af236a09e}
  553. ;
  554. VA_IConnector_GetType(this, ByRef Type) {
  555.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int*", Type)
  556. }
  557. VA_IConnector_GetDataFlow(this, ByRef Flow) {
  558.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "int*", Flow)
  559. }
  560. VA_IConnector_ConnectTo(this, ConnectTo) {
  561.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "ptr", ConnectTo)
  562. }
  563. VA_IConnector_Disconnect(this) {
  564.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this)
  565. }
  566. VA_IConnector_IsConnected(this, ByRef Connected) {
  567.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "int*", Connected)
  568. }
  569. VA_IConnector_GetConnectedTo(this, ByRef ConTo) {
  570.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "ptr*", ConTo)
  571. }
  572. VA_IConnector_GetConnectorIdConnectedTo(this, ByRef ConnectorId) {
  573.     hr := DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "ptr*", ConnectorId)
  574.     VA_WStrOut(ConnectorId)
  575.     return hr
  576. }
  577. VA_IConnector_GetDeviceIdConnectedTo(this, ByRef DeviceId) {
  578.     hr := DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this, "ptr*", DeviceId)
  579.     VA_WStrOut(DeviceId)
  580.     return hr
  581. }
  582.  
  583. ;
  584. ; IPart : {AE2DE0E4-5BCA-4F2D-AA46-5D13F8FDB3A9}
  585. ;
  586. VA_IPart_GetName(this, ByRef Name) {
  587.     hr := DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr*", Name)
  588.     VA_WStrOut(Name)
  589.     return hr
  590. }
  591. VA_IPart_GetLocalId(this, ByRef Id) {
  592.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint*", Id)
  593. }
  594. VA_IPart_GetGlobalId(this, ByRef GlobalId) {
  595.     hr := DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "ptr*", GlobalId)
  596.     VA_WStrOut(GlobalId)
  597.     return hr
  598. }
  599. VA_IPart_GetPartType(this, ByRef PartType) {
  600.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "int*", PartType)
  601. }
  602. VA_IPart_GetSubType(this, ByRef SubType) {
  603.     VarSetCapacity(SubType,16,0)
  604.     hr := DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "ptr", &SubType)
  605.     VA_GUIDOut(SubType)
  606.     return hr
  607. }
  608. VA_IPart_GetControlInterfaceCount(this, ByRef Count) {
  609.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "uint*", Count)
  610. }
  611. VA_IPart_GetControlInterface(this, Index, ByRef InterfaceDesc) {
  612.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "uint", Index, "ptr*", InterfaceDesc)
  613. }
  614. VA_IPart_EnumPartsIncoming(this, ByRef Parts) {
  615.     return DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this, "ptr*", Parts)
  616. }
  617. VA_IPart_EnumPartsOutgoing(this, ByRef Parts) {
  618.     return DllCall(NumGet(NumGet(this+0)+11*A_PtrSize), "ptr", this, "ptr*", Parts)
  619. }
  620. VA_IPart_GetTopologyObject(this, ByRef Topology) {
  621.     return DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this, "ptr*", Topology)
  622. }
  623. VA_IPart_Activate(this, ClsContext, iid, ByRef Object) {
  624.     return DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), "ptr", this, "uint", ClsContext, "ptr", VA_GUID(iid), "ptr*", Object)
  625. }
  626. VA_IPart_RegisterControlChangeCallback(this, iid, Notify) {
  627.     return DllCall(NumGet(NumGet(this+0)+14*A_PtrSize), "ptr", this, "ptr", VA_GUID(iid), "ptr", Notify)
  628. }
  629. VA_IPart_UnregisterControlChangeCallback(this, Notify) {
  630.     return DllCall(NumGet(NumGet(this+0)+15*A_PtrSize), "ptr", this, "ptr", Notify)
  631. }
  632.  
  633. ;
  634. ; IPartsList : {6DAA848C-5EB0-45CC-AEA5-998A2CDA1FFB}
  635. ;
  636. VA_IPartsList_GetCount(this, ByRef Count) {
  637.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "uint*", Count)
  638. }
  639. VA_IPartsList_GetPart(this, INdex, ByRef Part) {
  640.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", Index, "ptr*", Part)
  641. }
  642.  
  643. ;
  644. ; IAudioEndpointVolume : {5CDF2C82-841E-4546-9722-0CF74078229A}
  645. ;
  646. VA_IAudioEndpointVolume_RegisterControlChangeNotify(this, Notify) {
  647.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr", Notify)
  648. }
  649. VA_IAudioEndpointVolume_UnregisterControlChangeNotify(this, Notify) {
  650.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "ptr", Notify)
  651. }
  652. VA_IAudioEndpointVolume_GetChannelCount(this, ByRef ChannelCount) {
  653.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint*", ChannelCount)
  654. }
  655. VA_IAudioEndpointVolume_SetMasterVolumeLevel(this, LevelDB, GuidEventContext="") {
  656.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "float", LevelDB, "ptr", VA_GUID(GuidEventContext))
  657. }
  658. VA_IAudioEndpointVolume_SetMasterVolumeLevelScalar(this, Level, GuidEventContext="") {
  659.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "float", Level, "ptr", VA_GUID(GuidEventContext))
  660. }
  661. VA_IAudioEndpointVolume_GetMasterVolumeLevel(this, ByRef LevelDB) {
  662.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "float*", LevelDB)
  663. }
  664. VA_IAudioEndpointVolume_GetMasterVolumeLevelScalar(this, ByRef Level) {
  665.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "float*", Level)
  666. }
  667. VA_IAudioEndpointVolume_SetChannelVolumeLevel(this, Channel, LevelDB, GuidEventContext="") {
  668.     return DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this, "uint", Channel, "float", LevelDB, "ptr", VA_GUID(GuidEventContext))
  669. }
  670. VA_IAudioEndpointVolume_SetChannelVolumeLevelScalar(this, Channel, Level, GuidEventContext="") {
  671.     return DllCall(NumGet(NumGet(this+0)+11*A_PtrSize), "ptr", this, "uint", Channel, "float", Level, "ptr", VA_GUID(GuidEventContext))
  672. }
  673. VA_IAudioEndpointVolume_GetChannelVolumeLevel(this, Channel, ByRef LevelDB) {
  674.     return DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this, "uint", Channel, "float*", LevelDB)
  675. }
  676. VA_IAudioEndpointVolume_GetChannelVolumeLevelScalar(this, Channel, ByRef Level) {
  677.     return DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), "ptr", this, "uint", Channel, "float*", Level)
  678. }
  679. VA_IAudioEndpointVolume_SetMute(this, Mute, GuidEventContext="") {
  680.     return DllCall(NumGet(NumGet(this+0)+14*A_PtrSize), "ptr", this, "int", Mute, "ptr", VA_GUID(GuidEventContext))
  681. }
  682. VA_IAudioEndpointVolume_GetMute(this, ByRef Mute) {
  683.     return DllCall(NumGet(NumGet(this+0)+15*A_PtrSize), "ptr", this, "int*", Mute)
  684. }
  685. VA_IAudioEndpointVolume_GetVolumeStepInfo(this, ByRef Step, ByRef StepCount) {
  686.     return DllCall(NumGet(NumGet(this+0)+16*A_PtrSize), "ptr", this, "uint*", Step, "uint*", StepCount)
  687. }
  688. VA_IAudioEndpointVolume_VolumeStepUp(this, GuidEventContext="") {
  689.     return DllCall(NumGet(NumGet(this+0)+17*A_PtrSize), "ptr", this, "ptr", VA_GUID(GuidEventContext))
  690. }
  691. VA_IAudioEndpointVolume_VolumeStepDown(this, GuidEventContext="") {
  692.     return DllCall(NumGet(NumGet(this+0)+18*A_PtrSize), "ptr", this, "ptr", VA_GUID(GuidEventContext))
  693. }
  694. VA_IAudioEndpointVolume_QueryHardwareSupport(this, ByRef HardwareSupportMask) {
  695.     return DllCall(NumGet(NumGet(this+0)+19*A_PtrSize), "ptr", this, "uint*", HardwareSupportMask)
  696. }
  697. VA_IAudioEndpointVolume_GetVolumeRange(this, ByRef MinDB, ByRef MaxDB, ByRef IncrementDB) {
  698.     return DllCall(NumGet(NumGet(this+0)+20*A_PtrSize), "ptr", this, "float*", MinDB, "float*", MaxDB, "float*", IncrementDB)
  699. }
  700.  
  701. ;
  702. ; IPerChannelDbLevel  : {C2F8E001-F205-4BC9-99BC-C13B1E048CCB}
  703. ;   IAudioVolumeLevel : {7FB7B48F-531D-44A2-BCB3-5AD5A134B3DC}
  704. ;   IAudioBass        : {A2B1A1D9-4DB3-425D-A2B2-BD335CB3E2E5}
  705. ;   IAudioMidrange    : {5E54B6D7-B44B-40D9-9A9E-E691D9CE6EDF}
  706. ;   IAudioTreble      : {0A717812-694E-4907-B74B-BAFA5CFDCA7B}
  707. ;
  708. VA_IPerChannelDbLevel_GetChannelCount(this, ByRef Channels) {
  709.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "uint*", Channels)
  710. }
  711. VA_IPerChannelDbLevel_GetLevelRange(this, Channel, ByRef MinLevelDB, ByRef MaxLevelDB, ByRef Stepping) {
  712.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", Channel, "float*", MinLevelDB, "float*", MaxLevelDB, "float*", Stepping)
  713. }
  714. VA_IPerChannelDbLevel_GetLevel(this, Channel, ByRef LevelDB) {
  715.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint", Channel, "float*", LevelDB)
  716. }
  717. VA_IPerChannelDbLevel_SetLevel(this, Channel, LevelDB, GuidEventContext="") {
  718.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint", Channel, "float", LevelDB, "ptr", VA_GUID(GuidEventContext))
  719. }
  720. VA_IPerChannelDbLevel_SetLevelUniform(this, LevelDB, GuidEventContext="") {
  721.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "float", LevelDB, "ptr", VA_GUID(GuidEventContext))
  722. }
  723. VA_IPerChannelDbLevel_SetLevelAllChannels(this, LevelsDB, ChannelCount, GuidEventContext="") {
  724.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "uint", LevelsDB, "uint", ChannelCount, "ptr", VA_GUID(GuidEventContext))
  725. }
  726.  
  727. ;
  728. ; IAudioMute : {DF45AEEA-B74A-4B6B-AFAD-2366B6AA012E}
  729. ;
  730. VA_IAudioMute_SetMute(this, Muted, GuidEventContext="") {
  731.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int", Muted, "ptr", VA_GUID(GuidEventContext))
  732. }
  733. VA_IAudioMute_GetMute(this, ByRef Muted) {
  734.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "int*", Muted)
  735. }
  736.  
  737. ;
  738. ; IAudioAutoGainControl : {85401FD4-6DE4-4b9d-9869-2D6753A82F3C}
  739. ;
  740. VA_IAudioAutoGainControl_GetEnabled(this, ByRef Enabled) {
  741.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int*", Enabled)
  742. }
  743. VA_IAudioAutoGainControl_SetEnabled(this, Enable, GuidEventContext="") {
  744.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "int", Enable, "ptr", VA_GUID(GuidEventContext))
  745. }
  746.  
  747. ;
  748. ; IAudioMeterInformation : {C02216F6-8C67-4B5B-9D00-D008E73E0064}
  749. ;
  750. VA_IAudioMeterInformation_GetPeakValue(this, ByRef Peak) {
  751.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "float*", Peak)
  752. }
  753. VA_IAudioMeterInformation_GetMeteringChannelCount(this, ByRef ChannelCount) {
  754.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint*", ChannelCount)
  755. }
  756. VA_IAudioMeterInformation_GetChannelsPeakValues(this, ChannelCount, PeakValues) {
  757.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "uint", ChannelCount, "ptr", PeakValues)
  758. }
  759. VA_IAudioMeterInformation_QueryHardwareSupport(this, ByRef HardwareSupportMask) {
  760.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint*", HardwareSupportMask)
  761. }
  762.  
  763. ;
  764. ; IAudioClient : {1CB9AD4C-DBFA-4c32-B178-C2F568A703B2}
  765. ;
  766. VA_IAudioClient_Initialize(this, ShareMode, StreamFlags, BufferDuration, Periodicity, Format, AudioSessionGuid) {
  767.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int", ShareMode, "uint", StreamFlags, "int64", BufferDuration, "int64", Periodicity, "ptr", Format, "ptr", VA_GUID(AudioSessionGuid))
  768. }
  769. VA_IAudioClient_GetBufferSize(this, ByRef NumBufferFrames) {
  770.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint*", NumBufferFrames)
  771. }
  772. VA_IAudioClient_GetStreamLatency(this, ByRef Latency) {
  773.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "int64*", Latency)
  774. }
  775. VA_IAudioClient_GetCurrentPadding(this, ByRef NumPaddingFrames) {
  776.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "uint*", NumPaddingFrames)
  777. }
  778. VA_IAudioClient_IsFormatSupported(this, ShareMode, Format, ByRef ClosestMatch) {
  779.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "int", ShareMode, "ptr", Format, "ptr*", ClosestMatch)
  780. }
  781. VA_IAudioClient_GetMixFormat(this, ByRef Format) {
  782.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "uint*", Format)
  783. }
  784. VA_IAudioClient_GetDevicePeriod(this, ByRef DefaultDevicePeriod, ByRef MinimumDevicePeriod) {
  785.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "int64*", DefaultDevicePeriod, "int64*", MinimumDevicePeriod)
  786. }
  787. VA_IAudioClient_Start(this) {
  788.     return DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this)
  789. }
  790. VA_IAudioClient_Stop(this) {
  791.     return DllCall(NumGet(NumGet(this+0)+11*A_PtrSize), "ptr", this)
  792. }
  793. VA_IAudioClient_Reset(this) {
  794.     return DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this)
  795. }
  796. VA_IAudioClient_SetEventHandle(this, eventHandle) {
  797.     return DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), "ptr", this, "ptr", eventHandle)
  798. }
  799. VA_IAudioClient_GetService(this, iid, ByRef Service) {
  800.     return DllCall(NumGet(NumGet(this+0)+14*A_PtrSize), "ptr", this, "ptr", VA_GUID(iid), "ptr*", Service)
  801. }
  802.  
  803. ;
  804. ; IAudioSessionControl : {F4B1A599-7266-4319-A8CA-E70ACB11E8CD}
  805. ;
  806. /*
  807. AudioSessionStateInactive = 0
  808. AudioSessionStateActive = 1
  809. AudioSessionStateExpired = 2
  810. */
  811. VA_IAudioSessionControl_GetState(this, ByRef State) {
  812.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int*", State)
  813. }
  814. VA_IAudioSessionControl_GetDisplayName(this, ByRef DisplayName) {
  815.     hr := DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "ptr*", DisplayName)
  816.     VA_WStrOut(DisplayName)
  817.     return hr
  818. }
  819. VA_IAudioSessionControl_SetDisplayName(this, DisplayName, EventContext) {
  820.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "wstr", DisplayName, "ptr", VA_GUID(EventContext))
  821. }
  822. VA_IAudioSessionControl_GetIconPath(this, ByRef IconPath) {
  823.     hr := DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "ptr*", IconPath)
  824.     VA_WStrOut(IconPath)
  825.     return hr
  826. }
  827. VA_IAudioSessionControl_SetIconPath(this, IconPath) {
  828.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "wstr", IconPath)
  829. }
  830. VA_IAudioSessionControl_GetGroupingParam(this, ByRef Param) {
  831.     VarSetCapacity(Param,16,0)
  832.     hr := DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "ptr", &Param)
  833.     VA_GUIDOut(Param)
  834.     return hr
  835. }
  836. VA_IAudioSessionControl_SetGroupingParam(this, Param, EventContext) {
  837.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "ptr", VA_GUID(Param), "ptr", VA_GUID(EventContext))
  838. }
  839. VA_IAudioSessionControl_RegisterAudioSessionNotification(this, NewNotifications) {
  840.     return DllCall(NumGet(NumGet(this+0)+10*A_PtrSize), "ptr", this, "ptr", NewNotifications)
  841. }
  842. VA_IAudioSessionControl_UnregisterAudioSessionNotification(this, NewNotifications) {
  843.     return DllCall(NumGet(NumGet(this+0)+11*A_PtrSize), "ptr", this, "ptr", NewNotifications)
  844. }
  845.  
  846. ;
  847. ; IAudioSessionManager : {BFA971F1-4D5E-40BB-935E-967039BFBEE4}
  848. ;
  849. VA_IAudioSessionManager_GetAudioSessionControl(this, AudioSessionGuid) {
  850.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr", VA_GUID(AudioSessionGuid))
  851. }
  852. VA_IAudioSessionManager_GetSimpleAudioVolume(this, AudioSessionGuid, StreamFlags, ByRef AudioVolume) {
  853.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "ptr", VA_GUID(AudioSessionGuid), "uint", StreamFlags, "uint*", AudioVolume)
  854. }
  855.  
  856. ;
  857. ; IMMDeviceEnumerator
  858. ;
  859. VA_IMMDeviceEnumerator_EnumAudioEndpoints(this, DataFlow, StateMask, ByRef Devices) {
  860.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int", DataFlow, "uint", StateMask, "ptr*", Devices)
  861. }
  862. VA_IMMDeviceEnumerator_GetDefaultAudioEndpoint(this, DataFlow, Role, ByRef Endpoint) {
  863.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "int", DataFlow, "int", Role, "ptr*", Endpoint)
  864. }
  865. VA_IMMDeviceEnumerator_GetDevice(this, id, ByRef Device) {
  866.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "wstr", id, "ptr*", Device)
  867. }
  868. VA_IMMDeviceEnumerator_RegisterEndpointNotificationCallback(this, Client) {
  869.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "ptr", Client)
  870. }
  871. VA_IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(this, Client) {
  872.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "ptr", Client)
  873. }
  874.  
  875. ;
  876. ; IMMDeviceCollection
  877. ;
  878. VA_IMMDeviceCollection_GetCount(this, ByRef Count) {
  879.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "uint*", Count)
  880. }
  881. VA_IMMDeviceCollection_Item(this, Index, ByRef Device) {
  882.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "uint", Index, "ptr*", Device)
  883. }
  884.  
  885. ;
  886. ; IControlInterface
  887. ;
  888. VA_IControlInterface_GetName(this, ByRef Name) {
  889.     hr := DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "ptr*", Name)
  890.     VA_WStrOut(Name)
  891.     return hr
  892. }
  893. VA_IControlInterface_GetIID(this, ByRef IID) {
  894.     VarSetCapacity(IID,16,0)
  895.     hr := DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "ptr", &IID)
  896.     VA_GUIDOut(IID)
  897.     return hr
  898. }
  899.  
  900.  
  901. /*
  902.     INTERFACES REQUIRING WINDOWS 7 / SERVER 2008 R2
  903. */
  904.  
  905. ;
  906. ; IAudioSessionControl2 : {bfb7ff88-7239-4fc9-8fa2-07c950be9c6d}
  907. ;   extends IAudioSessionControl
  908. ;
  909. VA_IAudioSessionControl2_GetSessionIdentifier(this, ByRef id) {
  910.     hr := DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this, "ptr*", id)
  911.     VA_WStrOut(id)
  912.     return hr
  913. }
  914. VA_IAudioSessionControl2_GetSessionInstanceIdentifier(this, ByRef id) {
  915.     hr := DllCall(NumGet(NumGet(this+0)+13*A_PtrSize), "ptr", this, "ptr*", id)
  916.     VA_WStrOut(id)
  917.     return hr
  918. }
  919. VA_IAudioSessionControl2_GetProcessId(this, ByRef pid) {
  920.     return DllCall(NumGet(NumGet(this+0)+14*A_PtrSize), "ptr", this, "uint*", pid)
  921. }
  922. VA_IAudioSessionControl2_IsSystemSoundsSession(this) {
  923.     return DllCall(NumGet(NumGet(this+0)+15*A_PtrSize), "ptr", this)
  924. }
  925. VA_IAudioSessionControl2_SetDuckingPreference(this, OptOut) {
  926.     return DllCall(NumGet(NumGet(this+0)+16*A_PtrSize), "ptr", this, "int", OptOut)
  927. }
  928.  
  929. ;
  930. ; IAudioSessionManager2 : {77AA99A0-1BD6-484F-8BC7-2C654C9A9B6F}
  931. ;   extends IAudioSessionManager
  932. ;
  933. VA_IAudioSessionManager2_GetSessionEnumerator(this, ByRef SessionEnum) {
  934.     return DllCall(NumGet(NumGet(this+0)+5*A_PtrSize), "ptr", this, "ptr*", SessionEnum)
  935. }
  936. VA_IAudioSessionManager2_RegisterSessionNotification(this, SessionNotification) {
  937.     return DllCall(NumGet(NumGet(this+0)+6*A_PtrSize), "ptr", this, "ptr", SessionNotification)
  938. }
  939. VA_IAudioSessionManager2_UnregisterSessionNotification(this, SessionNotification) {
  940.     return DllCall(NumGet(NumGet(this+0)+7*A_PtrSize), "ptr", this, "ptr", SessionNotification)
  941. }
  942. VA_IAudioSessionManager2_RegisterDuckNotification(this, SessionNotification) {
  943.     return DllCall(NumGet(NumGet(this+0)+8*A_PtrSize), "ptr", this, "ptr", SessionNotification)
  944. }
  945. VA_IAudioSessionManager2_UnregisterDuckNotification(this, SessionNotification) {
  946.     return DllCall(NumGet(NumGet(this+0)+9*A_PtrSize), "ptr", this, "ptr", SessionNotification)
  947. }
  948.  
  949. ;
  950. ; IAudioSessionEnumerator : {E2F5BB11-0570-40CA-ACDD-3AA01277DEE8}
  951. ;
  952. VA_IAudioSessionEnumerator_GetCount(this, ByRef SessionCount) {
  953.     return DllCall(NumGet(NumGet(this+0)+3*A_PtrSize), "ptr", this, "int*", SessionCount)
  954. }
  955. VA_IAudioSessionEnumerator_GetSession(this, SessionCount, ByRef Session) {
  956.     return DllCall(NumGet(NumGet(this+0)+4*A_PtrSize), "ptr", this, "int", SessionCount, "ptr*", Session)
  957. }
  958.  
  959.  
  960. /*
  961.     UNDOCUMENTED INTERFACES
  962. */
  963.  
  964. ; Thanks to Dave Amenta for publishing this interface - http://goo.gl/6L93L
  965. ; IID := "{568b9108-44bf-40b4-9006-86afe5b5a620}"
  966. ; CLSID := "{294935CE-F637-4E7C-A41B-AB255460B862}"
  967. VA_xIPolicyConfigVista_SetDefaultEndpoint(this, DeviceId, Role) {
  968.     return DllCall(NumGet(NumGet(this+0)+12*A_PtrSize), "ptr", this, "wstr", DeviceId, "int", Role)
  969. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement