Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Vista Audio Control Functions


  • Please log in to reply
182 replies to this topic
FabianBengtsson
  • Members
  • 18 posts
  • Last active: Oct 15 2013 08:31 AM
  • Joined: 14 Nov 2006
I possible, in some way, to set the volume/mute a specified application with this script ?

For example if you want to set volume of foobar music player, could you do something like this?

VA_SetMasterVolume("10"," ","foobar2000 Application")

Don't capture me again!!

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

I'm so stupid.. I Quoted the Integer i.e. "5" as the parameter, and should have just passed the integer

There must have been something else, because either way the value is stored as a string (the character "5") in the subunit_desc parameter of VA_GetMute. Your previous code works for me.

I possible, in some way, to set the volume/mute a specified application with this script ?

No. I looked into it a while ago, and unfortunately it does not seem possible.

thefant
  • Guests
  • Last active:
  • Joined: --
I feel somewhat unintelligent asking this, but...how exactly do I get this to work? I downloaded the Vista Audio Control Functions v2.0 in the .zip file...now what?

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Get COM.ahk if you haven't already. VA.ahk and COM.ahk should be placed in your function library.

In the auto-execute section of the script you will be using VA from, call COM_Init(). This initializes COM, which is used by VA. Find the function you want to call in the VA documentation, then simply call it.

I cannot be more specific without knowing what it is you want to do with VA.

thefant
  • Guests
  • Last active:
  • Joined: --
Where is the function library? And how do I "call"?

I just want to mute my MIDI. I went looking for solutions on how to do this about a week ago, and I eventually found this.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
This is a function call:
function(parameter1, parameter2)
The function library is behind that blue thing we call a link. ;)

The script in the first post of this thread lists the available subunits. Unless there is a subunit "MIDI Mute" or similar, you'll need to use trial and error to determine which one it is. If they all have the same name, use numbering.
; In the auto-execute section (the top of the script):
COM_Init()

;...

VA_SetMute(true, "MIDI Mute")
; or
VA_SetMute(true, 1) ; 2, 3, etc.
It may help to have the properties of your playback device open as you run the script, to see if anything happens. (Usually Control Panel -> Sound -> Playback -> Speakers -> Properties -> Levels.)

thefant
  • Guests
  • Last active:
  • Joined: --
And with that, I think I have it figured out. I don't have much experience with stuff like this, so thanks for your help!

LPent
  • Members
  • 6 posts
  • Last active: Sep 21 2008 10:37 AM
  • Joined: 10 May 2008
I can only mute playback devices, not recording devices. Why is that? I really want to be able to mute my microphone input by means of a hotkey.

GreenLevel
  • Guests
  • Last active:
  • Joined: --
Hello! I know this is a Vista audio thread,.... but wondering if is it possible in some way, that will hopefully work in XP & Vista, output in a Tooltip the active peak value of the default audio device? :D

adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006
This is beautiful, thank you for your work on this.

Washburn
  • Members
  • 17 posts
  • Last active: Jan 20 2009 11:04 PM
  • Joined: 16 Dec 2008
I used the VA library to set volume and mute for the Stereo Mix and Microphone on a box with the Vista OS. I was able to get the Stereo Mix to work, but not able to get the Microphone to work. I tried several ways to call out the microphone subunit, based on the comments listed in the Vista Audio Control Function line of discussion, such as:
1
Mic Volume
Mic Mute
Microphone

Here is my code:
#NoEnv

COM_CoInitialize()
VA_SetVolume(100.0,1,1,"Stereo Mix:1")
VA_SetVolume(100.0,1,2,"Stereo Mix:1")
VA_SetMute(0,1,"Stereo Mix:1")
VA_SetVolume(100.0,1,1,"Microphone:1")
VA_SetVolume(100.0,1,2,"Microphone:1")
VA_SetMute(0,1,"Microphone:1")
COM_CoUninitialize()

If you have any ideas as to why the microphone settings for volume and mute will not work, please let me know. Thanks in advance.
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.

Washburn
  • Members
  • 17 posts
  • Last active: Jan 20 2009 11:04 PM
  • Joined: 16 Dec 2008
I was able to set the microphone volume and mute by using the following code:

#NoEnv 

COM_CoInitialize() 
VA_SetVolume(100.0,1,1,"Stereo Mix:1") 
VA_SetVolume(100.0,1,2,"Stereo Mix:1") 
VA_SetMute(0,1,"Stereo Mix:1") 
VA_SetVolume(100.0,1,1,"capture:4")  ;microphone channel 1 volume
VA_SetVolume(100.0,1,2,"capture:4")  ;microphone channel 2 volume
VA_SetMute(0,1,"capture:4")  ;microphone mute
COM_CoUninitialize()

This is all good because it gets me a step closer, but I have a problem with this. It's possible because of the ordering of other devices, that the microphone will not always be at the index 4. Is there a way that I can check to see that I have the microphone in index 4?
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.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
It should work if you specify whole or part of the correct name. I was going to suggest using the topology script in my first post, but then I realised I still haven't updated it to support multiple devices. :oops: You may use the following script to list device names:
COM_Init()
prefix_list = playback:,capture:
Loop, Parse, prefix_list, `,
{
    Loop {
        if !(device := VA_GetDevice(A_LoopField A_Index))
            break
        device_list .= A_LoopField A_Index "=" VA_GetDeviceName(device) "`n"
        COM_Release(device)
    }
}
COM_Term()
MsgBox % device_list


Washburn
  • Members
  • 17 posts
  • Last active: Jan 20 2009 11:04 PM
  • Joined: 16 Dec 2008
Hi Lexikos,

Here is what I figured out with my next step. Once I knew that "capture:4" worked for the device description, I used that to create a script test to get the device name, which is "Microphone (Realtek High Definition Audio)". With the device name, I was able to write the script so it could find the microphone and then use the correct capture index to access the device in order to set the volume and mute values. Here is the code:

#NoEnv

COM_CoInitialize()
VA_SetVolume(100.0,1,1,"Stereo Mix:1")
VA_SetVolume(100.0,1,2,"Stereo Mix:1")
VA_SetMute(0,1,"Stereo Mix:1")

;Loop to find the microphone capture device
i := 1
notFound := true
Loop
{
  if (notFound = false)
    break  ;Terminate the loop

  ;Get the device name
  device_desc := "capture:" . i
  device := VA_GetDevice(device_desc)
  device_name := VA_GetDeviceName(device)

  ;Compare the device name for loop termination
  if (device_name == "Microphone (Realtek High Definition Audio)")
    notFound := false
  else
    i := i+1
}

VA_SetVolume(100.0,1,1,device_desc)
VA_SetVolume(100.0,1,2,device_desc)
VA_SetMute(0,1,device_desc)
COM_CoUninitialize()

It has been a challenge to figure out a way to set the volume and mute for the microphone and stereo mix devices/subunits. I hope this helps the other folks out there that are trying to solve this problem. I need to integrate this with the rest of my script and make sure it all works together. I will report back and thanks for your assistance as well as the assistance of others.
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.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
"Microphone:1" should be sufficient... Would you like to try the following?
COM_Init()
device := VA_GetDevice("Microphone:1")
if device
    MsgBox % VA_GetDeviceName(device)
else
    MsgBox no device