Vista Audio Control Functions
Question: Does a bear do its duty in the woods.
Answer: It most certainly does, as well as anywhere else it chooses.
In that case, try the following:Running your code came up with one of the Logitech microphones. I specifically want the Realtek HD Audio microphone.
COM_Init() device := VA_GetDevice("Microphone[color=red] (Realtek High Definition Audio)[/color]") if device MsgBox % VA_GetDeviceName(device) else MsgBox no device:roll:
Question: Does a bear do its duty in the woods.
Answer: It most certainly does, as well as anywhere else it chooses.
I find it a little difficult to explain the situation, but the script itself technically works fine. My issue is that it seems to 'invent' an entirely new line-in device for itself. The line-in in windows' mixer stays functional and is the same audio as whatever AHK affects (off by a few ms, so I get an 'echo' effect), so I have to mute it and exclusively use the script's controls. My sound card only has one input port with audio feeding into it so I'm fairly positive it's not a "you're using the wrong device!" issue.
To sum up, whatever AHK is affecting doesn't show up in the volume mixer, and I'd like it to. Please help!
Here is my code, it is a mess :\
HotKey, f10, vol_MasterUp HotKey, f9, vol_MasterDown COM_Init() Insert:: ;SoundSet, +1, microphone, mute VA_SetMute(!VA_GetMute("Microphone"),"Microphone") return vol_MasterUp: vol_tmp := VA_GetVolume("Microphone") vol_Master := (vol_tmp + 5) VA_SetVolume(vol_Master, "Microphone") return vol_MasterDown: vol_tmp := VA_GetVolume("Microphone") vol_Master := (vol_tmp - 5) VA_SetVolume(vol_Master, "Microphone") returnIt's pretty obvious I have no idea what I'm doing. I was a newb at normal AHK stuff, so these VA functions totally threw me for a loop. The above code is a weird hybrid of something I found on this board (probably this thread, I dunno) and a similar script I was using in XP, thrown together using pure guess-and-check.
Edit, cleanup:
COM_Init() Insert::VA_SetMute(!VA_GetMute("Microphone"), "Microphone") F10::VA_SetVolume(VA_GetVolume("Microphone") + 5, "Microphone") F9::VA_SetVolume(VA_GetVolume("Microphone") - 5, "Microphone")
I found the slider on the 'levels' tab, where you said it would be.
By "mixer", I had meant the window you get when you right click the speaker in the systray and choose "Open Volume Mixer", but as long as I know where to change the volume on the input via mouse, I'm satisfied. It really had just confused me that whatever my script was controlling didn't seem to appear anywhere in windows' interface.
Thanks for the help, especially that rewrite. Your code makes it look a lot more like simple AHK
All I want to do is mute my microphone by pressing a button. But I can't get this to work.
Here's the subunits I see.
VOLUME SUBUNITS Speakers Line In Volume Aux Volume CD Volume Mic Volume MUTE SUBUNITS Master Mute Line Mute Aux Mute CD Mute Mic Mute
Here's my AHK script
COM_Init() F11::VA_SetMute(!VA_GetMute("Mic"), "Mic") COM_Term()
However, this seems to only disable the playback side of the mic, not the recording side. I thought maybe I could just add a 2 because of duplicate devices. SO I tried this...
F11::VA_SetMute(!VA_GetMute("Mic"), 2, "Mic")
It didn't work. So I tried this.
F11::VA_SetMute(!VA_GetMute("Mic"), 1, "Mic")
I thought that should just work as if the 1 wasn't even there and mute the playback side of my mic. But it didn't do anything.
In fact, I can't seem to mute any of the input devices, I can only mute the playback sides of all of them.
Any help would be awesome!
With that said, I think I've solved it.
I used this line
F11::VA_SetMasterMute(!VA_GetMasterMute("capture"), "capture")
This appears to just toggle mute the default input device, exactly what I need! If there's some way I can get it to mute just the mic instead of the default input device, that would be better. But really, this is just splitting hairs and I'm just overjoyed to actually have it working!
Much thanks!
Do you mean when the microphone is not the default input device? You can use the device name (or part of it) in place of "capture". If there is ambiguity you may append ":n" to retrieve the nth matching device. This will list all available capture devices:If there's some way I can get it to mute just the mic instead of the default input device, that would be better.
COM_Init() While (dev := VA_GetDevice("capture:" A_Index)) { devlist .= A_Index ": " VA_GetDeviceName(dev) "`n" COM_Release(dev) } COM_Term() MsgBox %devlist%
First thanks for your great library!
Could you please help me with one issue.
I enabled Stereo Mix device in Vista sound settings and I want to use it as source for recording. I want to use Autohotkey and your excelent library to mute/unmute Mic playback with a single button.
I able to controll it with Vista Audio settings in Playback devices->Playback->Speakers->Levels->Rear Pink In. But I can't figure how to do it with VA_SetMute .
I tried different params but it just doesn't affect mic playback volume. I can control record volume of Mic using VA_* calls but I need to change its (Rear Pink In) playback.
Here is my topology:
+ (CONNECTOR) Realtek HD Audio output : {4509F757-2D46-4637-8E62-CE7DB944F57B} + Master Mute : IAudioMute + Speakers : IAudioVolumeLevel + Sum + (CONNECTOR) + Mute : IAudioMute + CD Audio : IAudioVolumeLevel + (CONNECTOR) CD Audio + Mute : IAudioMute + Rear Green In : IAudioVolumeLevel + (CONNECTOR) Rear Green In + Mute : IAudioMute + Rear Black In : IAudioVolumeLevel + (CONNECTOR) Rear Black In + Mute : IAudioMute + Rear Orange In : IAudioVolumeLevel + (CONNECTOR) Rear Orange In + Mute : IAudioMute + Rear Grey In : IAudioVolumeLevel + (CONNECTOR) Rear Grey In + Mute : IAudioMute + Rear Pink In : IAudioVolumeLevel + (CONNECTOR) Rear Pink In + Mute : IAudioMute + Front Pink In : IAudioVolumeLevel + (CONNECTOR) Front Pink In + Mute : IAudioMute + Rear Blue In : IAudioVolumeLevel + (CONNECTOR) Rear Blue In + Mute : IAudioMute + Front Green In : IAudioVolumeLevel + (CONNECTOR) Front Green In + Side : IAudioVolumeLevel + (CONNECTOR) Side + Center : IAudioVolumeLevel + (CONNECTOR) Center + Subwoofer : IAudioVolumeLevel + (CONNECTOR) Subwoofer + Rear : IAudioVolumeLevel + (CONNECTOR) Rear + Front : IAudioVolumeLevel + (CONNECTOR) Front VOLUME SUBUNITS Speakers CD Audio Rear Green In Rear Black In Rear Orange In Rear Grey In Rear Pink In Front Pink In Rear Blue In Front Green In Side Center Subwoofer Rear Front MUTE SUBUNITS Master Mute Mute Mute Mute Mute Mute Mute Mute Mute Mute
Thank you![/code]
Are you really trying to control volume (VA_SetVolume), or mute (VA_SetMute)?VA_SetMute ... I tried different params but it just doesn't affect mic playback volume.
It looks like your audio driver doesn't give unique names to the "Mute" subunits, so you would need to identify it by its number, as determined by the order it appears in the topology. On the other hand, since there is a volume subunit called "Rear Pink In", you may pass that to VA_SetVolume.
COM_Init() VA_SetVolume(100, "Rear Pink In") VA_SetMute(false, 6)If that doesn't work, experiment with different numbers while watching the volume levels/mute in the "Speakers" control panel.
I spent about 4 hours yesterday for that. I tried both VA_SetVolume and VA_SetMute. I tried VA_SetMute(1..10) and other Microphone:1, playback:n, capture:n, Pink Rear In, Microphone at Pink Rear In .... It doesn't affect any level unfortunately.
Maybe this (CONNECTOR) in my topology tree is problem:
+ Sum
+ (CONNECTOR)
+ Mute : IAudioMute
If so, you need to read the manual. The first parameter of SetMute must be true (to mute) or false (to unmute). True and false are synonymous with 1 and 0, respectively. The second parameter is the subunit name or number.I tried VA_SetMute(1..10)
These are all device names, not subunit names. Device names are specified in the third parameter of SetMute or fourth parameter of SetVolume. However, I suspect you need the default playback device, in which case you can omit the device parameter. Otherwise you could specify "Speakers" assuming the correct volume/mute controls can be found in "Speakers Properties".and other Microphone:1, playback:n, capture:n,
As the tree and list of subunits you posted shows, this is a volume subunit and will not work with SetMute. It should work with SetVolume, as long as you use the correct (second) parameter (and surround it with "quote marks").Pink Rear In
Since the somewhat outdated topolgy script is able to list the subunits, I doubt very much that is a problem.Maybe this (CONNECTOR) in my topology tree is problem:
+ Sum
+ (CONNECTOR)
+ Mute : IAudioMute
Try this:
COM_Init() MsgBox, ( Please open your Speakers Properties to the Levels tab. This script will toggle mute on and off repeatedly; while it is doing so, watch the Levels to see which one changes. Hold Ctrl to display the subunit number and advance to the next subunit. Hold Shift to quit. Click OK to continue. ) Loop { n_device := "playback:" A_Index if VA_GetMasterMute(n_device) = "" break Loop { n_subunit := A_Index if VA_GetMute(n_subunit, n_device) = "" break Loop { if GetKeyState("Ctrl") break if GetKeyState("Shift") ExitApp VA_SetMute(not VA_GetMute(n_subunit, n_device), n_subunit, n_device) Sleep 500 } MsgBox Device: %n_device%, Subunit: %n_subunit% } } MsgBox Ran out of controls. ExitAppOn my system at least, the controls on the Levels tab are listed in the same order that VA.ahk assigns them numbers, so the first is 1, the second is 2... and so on.
Edit: Updated script. Edit2: Slight fix. It's supposed to toggle, not just mute...
Of course I used correct syntax: VA_SetMute( true, 1..10)
Your test script breaks at
if VA_GetMute(n_subunit, n_device) = ""
I tried VA_GetMute before and it returns empty string for any index...
BTW is there any way to enumerate all guidEventContext (which is used in IAudioMute::SetMute) to specifiy it directly then ?
Do you mean it immediately breaks out of the loop and shows "Ran out of controls"? If so, the device name is probably incorrect. Try changing "Speakers" to "playback". Since you said "Playback devices->Playback->Speakers" I presumed "Speakers" was the correct device name.Your test script breaks at
if VA_GetMute(n_subunit, n_device) = ""
Altenately, you may try the script in my previous post again. I have updated it to cycle through all playback devices.
Were you specifying a device name? If so, it may be incorrect. To verify that a device name is correct, call VA_GetDevice:I tried VA_GetMute before and it returns empty string for any index...
COM_Init() dev := VA_GetDevice("the-device-name-here") if dev COM_Release(dev)In any case, the script may be failing for some other reason. Ensure COM_Init() has been called, you have a functioning audio device and drivers, you have a recent version of AutoHotkey, etc. I don't know what else to suggest.
guidEventContext is completely irrelevant.BTW is there any way to enumerate all guidEventContext (which is used in IAudioMute::SetMute) to specifiy it directly then ?
It is much more likely that the script is failing somewhere in VA_GetDeviceSubunit.pguidEventContext
[in] Context value for the IControlChangeNotify::OnNotify method. This parameter points to an event-context GUID. If the SetMute call changes the state of the mute control, all clients that have registered IControlChangeNotify interfaces with that control receive notifications. In its implementation of the OnNotify method, a client can inspect the event-context GUID to discover whether it or another client is the source of the control-change event. If the caller supplies a NULL pointer for this parameter, the client's notification method receives a NULL context pointer.
If you need further help, please post the actual code which you've tried. Guesses will only get me so far.Of course I used correct syntax: VA_SetMute( true, 1..10)
...
I tried VA_GetMute before and it returns empty string for any index...