AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Vista Audio Control Functions v2.0
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Washburn



Joined: 16 Dec 2008
Posts: 17
Location: Gainesville, FL

PostPosted: Tue Jan 20, 2009 10:36 pm    Post subject: Reply with quote

I tested your code and I need to stick with my version since I actually have three microphones, which are used for Intercom communication. Two are Logitech, and one is the Realtek HD Audio microphone. Running your code came up with one of the Logitech microphones. I specifically want the Realtek HD Audio microphone. My methodology allows me to search through the capture devices/subunits to find the specific microphone. Also, the order of the devices could change as we add new devices, so my methodology allows me to access the specific microphone regardless of order. Thanks for your suggestion, and I appreciate your time.
_________________
My Username comes from the name of a mountain peak in Yellowstone N.P.

Question: Does a bear do its duty in the woods.
Answer: It most certainly does, as well as anywhere else it chooses.
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4459
Location: Qld, Australia

PostPosted: Wed Jan 21, 2009 8:26 am    Post subject: Reply with quote

Washburn wrote:
Running your code came up with one of the Logitech microphones. I specifically want the Realtek HD Audio microphone.
In that case, try the following:
Code:
COM_Init()
device := VA_GetDevice("Microphone (Realtek High Definition Audio)")
if device
    MsgBox % VA_GetDeviceName(device)
else
    MsgBox no device

Rolling Eyes
Back to top
View user's profile Send private message Visit poster's website
Washburn



Joined: 16 Dec 2008
Posts: 17
Location: Gainesville, FL

PostPosted: Wed Jan 21, 2009 2:55 pm    Post subject: Reply with quote

That's a good refinement. I don't have to run a loop to find the device. It's alot more efficient. Thanks for your suggestion.
_________________
My Username comes from the name of a mountain peak in Yellowstone N.P.

Question: Does a bear do its duty in the woods.
Answer: It most certainly does, as well as anywhere else it chooses.
Back to top
View user's profile Send private message
protospork



Joined: 02 Apr 2009
Posts: 2

PostPosted: Thu Apr 02, 2009 12:34 am    Post subject: Reply with quote

I have a script using code that I adapted from someone's post on this board (I did it a month or so ago so I'm not sure exactly where I got it) that uses VA to assign f9/f10 to reduce/raise line-in volume and insert to toggle muting it.

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! Sad

Here is my code, it is a mess :\
Code:

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")
return

It'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.
Back to top
View user's profile Send private message AIM Address
Lexikos



Joined: 17 Oct 2006
Posts: 4459
Location: Qld, Australia

PostPosted: Fri Apr 03, 2009 3:33 pm    Post subject: Reply with quote

VA controls "subunits" of your audio device - in this case the subunit representing feedback of "Microphone" input through the default output device. It should appear on the Levels tab of your device's properties. (If that's what you meant by "windows' mixer", I'll be confused.)

Edit, cleanup:
Code:
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")
Back to top
View user's profile Send private message Visit poster's website
protospork



Joined: 02 Apr 2009
Posts: 2

PostPosted: Fri Apr 03, 2009 7:18 pm    Post subject: Reply with quote

Whoa, that's a hell of a cleanup Shocked

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 Very Happy
Back to top
View user's profile Send private message AIM Address
Dustin
Guest





PostPosted: Mon Aug 03, 2009 10:34 pm    Post subject: Help Reply with quote

I hope people don't get too mad for me bringing this thread back to life. I've looked but I haven't been able to find any help.

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.

Code:
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

Code:
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...

Code:
F11::VA_SetMute(!VA_GetMute("Mic"), 2, "Mic")


It didn't work. So I tried this.

Code:
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!
Back to top
Dustin
Guest





PostPosted: Mon Aug 03, 2009 11:57 pm    Post subject: Er, problem solved Reply with quote

Sorry, I'm pretty new to this stuff so I don't really understand much.

With that said, I think I've solved it.

I used this line
Code:

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!
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 4459
Location: Qld, Australia

PostPosted: Tue Aug 04, 2009 9:05 am    Post subject: Reply with quote

Quote:
If there's some way I can get it to mute just the mic instead of the default input device, that would be better.
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:
Code:
COM_Init()
While (dev := VA_GetDevice("capture:" A_Index))
{
    devlist .= A_Index ": " VA_GetDeviceName(dev) "`n"
    COM_Release(dev)
}
COM_Term()
MsgBox %devlist%
Back to top
View user's profile Send private message Visit poster's website
codex
Guest





PostPosted: Thu Aug 27, 2009 8:24 am    Post subject: Reply with quote

Hi Lexikos!

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 Sad.
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:
Code:
+ (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]
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 4459
Location: Qld, Australia

PostPosted: Thu Aug 27, 2009 8:42 am    Post subject: Reply with quote

codex wrote:
VA_SetMute ... I tried different params but it just doesn't affect mic playback volume.
Are you really trying to control volume (VA_SetVolume), or mute (VA_SetMute)?

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.
Code:
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.
Back to top
View user's profile Send private message Visit poster's website
codex



Joined: 27 Aug 2009
Posts: 8
Location: Kiev, Ukraine

PostPosted: Thu Aug 27, 2009 8:55 am    Post subject: Reply with quote

Thank you for answer!

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
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4459
Location: Qld, Australia

PostPosted: Thu Aug 27, 2009 10:09 am    Post subject: Reply with quote

codex wrote:
I tried VA_SetMute(1..10)
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.
Quote:
and other Microphone:1, playback:n, capture:n,
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".
Quote:
Pink Rear In
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").
Quote:
Maybe this (CONNECTOR) in my topology tree is problem:
+ Sum
+ (CONNECTOR)
+ Mute : IAudioMute
Since the somewhat outdated topolgy script is able to list the subunits, I doubt very much that is a problem.


Try this:
Code:
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.
ExitApp
On 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...


Last edited by Lexikos on Thu Aug 27, 2009 12:17 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
codex



Joined: 27 Aug 2009
Posts: 8
Location: Kiev, Ukraine

PostPosted: Thu Aug 27, 2009 10:23 am    Post subject: Reply with quote

Thanks!

Of course I used correct syntax: VA_SetMute( true, 1..10) Smile
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 ?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4459
Location: Qld, Australia

PostPosted: Thu Aug 27, 2009 10:50 am    Post subject: Reply with quote

When I suggested VA_SetMute(false, 6), I had not counted "Master Mute". I should have said VA_SetMute(false, 7).
codex wrote:
Your test script breaks at
if VA_GetMute(n_subunit, n_device) = ""
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.

Altenately, you may try the script in my previous post again. I have updated it to cycle through all playback devices.
Quote:
I tried VA_GetMute before and it returns empty string for any index...
Were you specifying a device name? If so, it may be incorrect. To verify that a device name is correct, call VA_GetDevice:
Code:
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.
Quote:
BTW is there any way to enumerate all guidEventContext (which is used in IAudioMute::SetMute) to specifiy it directly then ?
guidEventContext is completely irrelevant.
MSDN wrote:
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.
It is much more likely that the script is failing somewhere in VA_GetDeviceSubunit.
codex wrote:
Of course I used correct syntax: VA_SetMute( true, 1..10)
...
I tried VA_GetMute before and it returns empty string for any index...
If you need further help, please post the actual code which you've tried. Guesses will only get me so far.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Page 5 of 7

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group