Guest User

Untitled

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