ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

Audio output device manager

(1/4) > >>

aljhenry:
hi folks,

I have an annoyance that you may be able to help me with, there may even be software out there to solve this already.

I work on a laptop with a docking station in work, the docking station has desktop speakers through which i play music if I'm alone in the office, then I have USB headphones which I use to listen to music while people are in the office and for Skype. When i go home I listen to music through the internal laptop speaker or connect to an amplifier through my headphone jack.

My problem is that when switching between these output modes I often have to fiddle around for ages to get sound out of the appropriate device. Plug into the headphone jack means i have to restart itunes. Skype gives me real hassle and I can't seem to work out the correct procedure or sequence to plugging things in and starting programs.....

In windows (XP) there does not appear to be a central (or even useful) audio output manager, where the output device (or port) can be readily selected from a list of possibilities. That volume control thingy in the tray is useless...

Can anyone suggest existing software that could help me? or can someone write a wee bit of code that might allow me to keep my hair for another couple of years.

Thanks in advance,
al

Nod5:
hi aljhenry,

If I understand what you write correctly you have three different sound devices. If so, then maybe I can help. You can switch between audio devices in Windows XP here:
control panel > sound and audio device properties > audio > default device

Any application running before you change the device (like a browser) must usually be closed and restarted for the change to take effect on its audio. So the process would each time be:
1. change device
2. restart/start the application you want to play the sound from
My stationary home computer has two audio devices that I switch between daily.  I wrote a script in AHK (autohotkey.com) to speed up the switching. Since the script includes the device names on my particular system, it must be modified a bit to work on your system. The script changes the default device by changing a registry key:
HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback

Here's the core of my script:

--- ---#SingleInstance force
dev1 = Realtek AC97 Audio
dev2 = C-Media USB Headphone Set%A_Space%%A_Space%
RegRead, x, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback
If x = %dev1%
{
RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback, %dev2%
TrayTip, ,%dev2%, 2,
}
else
{
RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback, %dev1%
TrayTip, ,%dev1%, 2,
}
sleep 2000If you have 3 audio devices, it could in your case look something like this:

--- ---#SingleInstance force
dev1 = name-of-device-1
dev2 = name-of-device-2
dev3 = name-of-device-3
RegRead, x, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback
If x = %dev1%
{
RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback, %dev2%
TrayTip, ,%dev2%, 2,
}
if x = %dev2%
{
RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback, %dev3%
TrayTip, ,%dev3%, 2,
}
if x = %dev3%
{
RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback, %dev1%
TrayTip, ,%dev1%, 2,
}
sleep 2000Where you should replace "name-of-device-1" and so on with the name of your audio devices as they are displayed in the sound and audio device properties. Be sure to check if there are spaces at the end of the device names! If there are spaces, add "%A_Space%" (without the quotes) in the AHK script for each space. For example, one of my audio devices is called "C-Media USB Headphone Set  " in the audio device properties and in the registry. Therefore, I have "C-Media USB Headphone Set%A_Space%%A_Space%" in the code above (again, without the quotes).

You then put the script file on the desktop and doubleclick to switch audio device.

Was this of any help?

lanux128:
there was a similar request here: DONE: A shortcut/hotkey to switch between audio devices?

maybe it will help you.. :)

Nod5:
lanux128, ok I hadn't seen that thread. This means aljhenry now has two script solutions to choose between. :Thmbsup: An advantage with the script above is that no audio device properties window pops up.

Come to think of it, one way to improve both scripts would be to somehow bypass the need to setup device name(s) manually in the script. When I do a quick search in the registry I find my devices listed here:

[HKEY_CURRENT_USER\Software\Microsoft\ActiveMovie\devenum\{33D9A762-90C8-11D0-BD43-00A0C911CE86}]
like this:
[HKEY_CURRENT_USER\Software\Microsoft\ActiveMovie\devenum\{33D9A762-90C8-11D0-BD43-00A0C911CE86}\C-Media USB Headphone Set  ]
"FriendlyName"="C-Media USB Headphone Set  "
[HKEY_CURRENT_USER\Software\Microsoft\ActiveMovie\devenum\{33D9A762-90C8-11D0-BD43-00A0C911CE86}\Realtek AC97 Audio]
"FriendlyName"="Realtek AC97 Audio"
Does anyone know if that location is the same for all XP installs? If so, then it would be easy to write a script that automatically grabs the names of all audio devices and then switches between them.

edit: I also find them here:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Volume Control]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Volume Control\C-Media USB Headphone Set  ]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Volume Control\Realtek AC97 Audio]

edit2:
Ok, I just put this together. Works fine on my XP system but note that it relies on the fact that my audio device names are listed in the registry at the last location noted above. It would be great if someone could quickly check if that registry location lists audio device names on his/her PC too.


--- ---#SingleInstance force
AutoTrim, Off
;________GET AUDIO DEVICE NAMES INTO ARRAY________________
xcount = 1
Loop, HKEY_CURRENT_USER , Software\Microsoft\Windows\CurrentVersion\Applets\Volume Control,2,0
{
if A_LoopRegName = Options                 ;ignore subkey "Options"
 continue
dev%xcount% = %A_LoopRegName%     ;put audio device name in array
xcount += 1
}
xcount -= 1

;________GET CURRENT AUDIO DEVICE NAME____________________
RegRead, x, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback

;________LOOP OVER ARRAY. IF MATCH, SWITCH TO NEXT________
Loop, %xcount%
{
if dev%A_index% != %x%                ;not match current device?
 continue
xc := A_index + 1
if xc > %xcount%
xc = 1
xnew := dev%xc%                           ;name of new device
RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Multimedia\Sound Mapper, Playback, %xnew%
TrayTip, ,%xnew%, 2,
break
}
sleep 2000

lanux128:
Nod5, actually your solution is more elegant.. :up: the reason i linked the other thread is just to highlight that this feature is much needed.. :) btw, how do you change the output device?

Navigation

[0] Message Index

[#] Next page

Go to full version