controlling two sound cards (really off-topic)
Posted by: mhf
Date: October 21, 2009 01:32AM

The scenario : I have a built-in sound card and a USB sound card (with mike and headphones) - I listen to the radio (RadioSure ! - the best) on the built-in sound card which outs to the speakers and I use the USB soundcard for Skype.
However sometimes I would like to listen to whatever is streaming through the browser (K-Meleon - dare I say the best ?) via the USB sound card while leaving the radio on the built-in sound card.

I hope that's clear - so I'm looking for a freeware that allows me to control what goes where.

Thanks in advance... !

XP sp2

Re: controlling two sound cards (really off-topic)
Posted by: disrupted
Date: November 05, 2009 11:56PM

i have 2 soundcards and i understand what you want.. i listen to online radio -usually default soundcard via speakers and then i would like to check an mp3 song before download to check if it's of good quality or the proper song etc..so i didn't want it to play through default one cause it would ruin my radio listening session and i wouldn't hear it properly with 2 streams playing at the same time.

in windows 98, there is something i think is very smart but it's not available on other win oses..when 1 sound card is engaged(busy) it would automatically route the 2 output through the 2 soundcard(non default) this was really smart but ms decided to stop that and play out all through your default soundcard|(unless ofcourse your audio player had an option to choose output)..this does not apply on directx playback which will always use your default soundcard. the reason why ms did that after windows 98 is because most users just have one soundcard and in win98 that caused problems with multiple streams or outputs and you would get an error message"soundcard not available" but ofcourse for those with multiple soundcards, win 98 was the best by auto routing.

unfortunately i never found a freeware program to do what win98 did by default.. i once did find a shareware product but it was very unstable and wouldn't always work..i forgot its name anyways.

what i do now is toggling the default sound card before i want to play something with an autoit script because it can read registry first but you can do the same thing directly with regedit and a reg key and can be easilt implemented with a macro

if you download the mp3 file, you don't need this procedure because you can add a context menu command to an mp3 player which is automatically set to use soundcard2 regardless of your default one(non sound mapper). almost all good mp3 players give you that option: nad, winamp, sonique etc

but if you want to listen to the stream via browser plugin it will use the default mapper (directx) and you will need to swap default card first.

first you will need to know the exact name for the soundcards registered as an audio device.. you can find that in sound and audio panel.

then you make a registry key with the desired soundcard set as default.

e.g. for soundcard1 as default:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper]
"Playback"="Creative Sound Blaster PCI"


e.g. soundcard2 as default:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper]
"Playback"="FM801 PCI Audio"


-change red parts according to your soundcard name

then you save each reg key in a path as *.reg file
eg. soundcard1.reg and soundcard2.reg
and make a macro with the exec command


soundcard1{
exec("c:\\windows\\regedit.exe /s c:\\soundcard1.reg");
}

soundcard2{
exec("c:\\windows\\regedit.exe /s c:\\soundcard2.reg");
}

soundcards_BuildMenu{
setmenu("&Tools",inline,sound_cards,WebServices);
setmenu(sound_cards,popup,"Soundcards");
setmenu("Soundcards",macro,"soundcard1 as default",soundcard1);
setmenu("Soundcards",macro,"soundcard2 as default",soundcard2);
}

$OnInit=$OnInit."soundcards_BuildMenu;";
$macroModules=$macroModules."togglesoundcards;";


(the /s switch is to make regedit use silent mode without prompting when adding the regkey)

now before you want to play your other stream etc, just click tools>soundcards and select soundcard 2 as default this will use your 2nd soundcard when you play that file.

if you prefer a specific soundcard to be default and in case you forgot to switch back to it, you can add a shortcut in startup to use the soundcard1.reg for e.g
regedit.exe /s c:\soundcard1.reg
this way the system with revert to default soundcard always after you logoff or startup.

Re: controlling two sound cards (really off-topic)
Posted by: mhf
Date: November 06, 2009 12:55AM

That's fantastic disrupted - thank you so much for spending your time on this.
Now I can watch and listen to the Simpsons while me wife listens to the radio ! grinning smiley

Re: controlling two sound cards (really off-topic)
Posted by: disrupted
Date: November 06, 2009 03:15AM

grinning smiley glad i could help and thanks for that lovely simpsons link

Re: controlling two sound cards (really off-topic)
Posted by: disrupted
Date: November 06, 2009 11:43PM

i think you will like this one better:
http://kmext.sourceforge.net/files/soundcontrol.7z

this functions much better and the default soundcard will have a checkmark.. unselecting the checked soundcard or selecting the unchecked soundcard will switch default device to the other card(super-toggle). this way you can easily tell which soundcard is currently the default one from the menu.


updates include a statusbar indication of which soundcard is default and there's also an audioalert saying which card has been set as default to ensure the device has been switched properly before opening a stream.

there's also an accelerator (ctrl+alt+l) for easy toggle.

kmeleon will now revert to default soundcard automatically upon exit so you don't need to worry about forgetting to set back the default one and there's no need for startup reg entry now.

the package includes the audio wav alerts, extratc in kmeleon folder and then open the macro to edit values according to device name and regkey paths. you can also use the extension manager kem'edit macro' button.

edit red paths according to audio devices names and the reg key paths

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# --------toggles soundcards(requires atleast 2 audio devices)

#--edit values below according to souncard names and regkey paths
$sc_primary=("Creative SB PCI");
$sc_secondary=("FM801 audio PCI");
$primary_key=("I:\\applications\\applications-x\\PopSel\\exras\\sound1.reg");
$secondary_key=("I:\\applications\\applications-x\\PopSel\\exras\\sound2.reg");
#--end of edit values
#-------------------------------------------------------------------------------------------------

$_tool_path=getfolder(RootFolder)."\\Tools";
$primary_alert=getfolder(RootFolder)."\\Tools\\soundcontrol\\sc1.wav";
$second_alert=getfolder(RootFolder)."\\Tools\\soundcontrol\\sc2.wav";


primarycreative{
menuchecked=(getpref(INT,"soundcard.default")=="1");
togglepref(INT,"soundcard.default",1,2);
$creativesb=getpref(INT,"soundcard.default");
$creativesb==1?&soundcard1:&soundcard2;
}

soundcard1{
exec("regedit.exe /s \"".$primary_key."\"");
$scprime=("soundcard switched: ".$sc_primary);
exec($_tool_path."\\soundcontrol\\scalert.exe " . $primary_alert);
statusbar($scprime);
}

setdefaultsc{
exec("regedit.exe /s \"".$primary_key."\"");
$scprime=("soundcard switched: ".$sc_primary);
exec($_tool_path."\\soundcontrol\\scalert.exe " . $primary_alert);
statusbar($scprime);
}

secondaryfm801{
menuchecked=(getpref(INT,"soundcard.default")=="2");
togglepref(INT,"soundcard.default",2,1);
$fm801=getpref(INT,"soundcard.default");
$fm801==2?&soundcard2:&setdefaultsc;
}

soundcard2{
exec("regedit.exe /s \"".$secondary_key."\"");
$scsecond=("soundcard switched: ".$sc_secondary);
exec($_tool_path."\\soundcontrol\\scalert.exe " . $second_alert);
statusbar($scsecond);
}

resettoprimary{
setpref(INT,"soundcard.default",1);
exec("regedit.exe /s \"".$primary_key."\"");
}

soundcards_BuildMenu{
#alternative menu for me:edit>configuration
#setmenu("_Config_General",popup,"SC Audiomapper",10);
setmenu("&Tools",popup,"SC Audiomapper",3);
setmenu("SC Audiomapper",macro,$sc_primary,primarycreative);
setmenu("SC Audiomapper",macro,$sc_secondary,secondaryfm801);
}

togglecards_SetAccels{
setaccel("CTRL ALT L","macros(primarycreative)");
}

#---------------------------------------------------------------
$OnInit=$OnInit."soundcards_BuildMenu;togglecards_SetAccels;";
$OnQuit=$OnQuit."resettoprimary;";
$macroModules=$macroModules."togglesoundcards;";


Re: controlling two sound cards (really off-topic)
Posted by: mhf
Date: November 07, 2009 05:14AM

Wow, disrupted thank you !
You're right, I do like this one better, much easier to use and harder to forget (impossible to forget) which card is running...!
Fantastic !



Edited 1 time(s). Last edit at 11/07/2009 05:16AM by mhf.

Re: controlling two sound cards (really off-topic)
Posted by: disrupted
Date: November 08, 2009 12:51AM

you're welcome smiling smiley and thanks to you because it's a good idea.. though probably only the 2 of us will use it :d .. but it gave me an idea for another extension

Re: controlling two sound cards (really off-topic)
Posted by: mhf
Date: November 08, 2009 01:58AM

Thanks again disrupted - if you do a scroogle on "controlling two sound cards in xp" you'll see that there are thousands of requests for information about how to do this very same thing ! So, maybe we won't be the only two to use it.

Apart from that I had a few problems with the macro, for one thing I'm somewhat colourblind so red and green don't go well together - it's hard to distinguish them. And then, I didn't realize at first that the soundcard names had to be changed further down. Here is what I've done - could you check it please for mistakes as I don't get the checkmark in the menu etc.

____________________________________________

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# --------toggles soundcards(requires at least 2 audio devices)

#--edit values below according to soundcard names and regkey paths
$sc_primary=("SoundMAX Digital Audio");
$sc_secondary=("USB Headphone Set");
$primary_key=("C:\Program Files\K-Meleon\soundcard1.reg");
$secondary_key=("C:\Program Files\K-Meleon\soundcard2.reg");
#--end of edit values
#-------------------------------------------------------------------------------------------------

$_tool_path=getfolder(RootFolder)."\\Tools";
$primary_alert=getfolder(RootFolder)."\\Tools\\soundcontrol\\sc1.wav";
$second_alert=getfolder(RootFolder)."\\Tools\\soundcontrol\\sc2.wav";


primarysoundmax{
menuchecked=(getpref(INT,"soundcard.default")=="1");
togglepref(INT,"soundcard.default",1,2);
$soundmax=getpref(INT,"soundcard.default");
$soundmax==1?&soundcard1:&soundcard2;
}

soundcard1{
exec("regedit.exe /s \"".$primary_key."\"");
$scprime=("soundcard switched: ".$sc_primary);
exec($_tool_path."\\soundcontrol\\scalert.exe " . $primary_alert);
statusbar($scprime);
}

setdefaultsc{
exec("regedit.exe /s \"".$primary_key."\"");
$scprime=("soundcard switched: ".$sc_primary);
exec($_tool_path."\\soundcontrol\\scalert.exe " . $primary_alert);
statusbar($scprime);
}

secondaryUSB{
menuchecked=(getpref(INT,"soundcard.default")=="2");
togglepref(INT,"soundcard.default",2,1);
$USB=getpref(INT,"soundcard.default");
$USB==2?&soundcard2:&setdefaultsc;
}

soundcard2{
exec("regedit.exe /s \"".$secondary_key."\"");
$scsecond=("soundcard switched: ".$sc_secondary);
exec($_tool_path."\\soundcontrol\\scalert.exe " . $second_alert);
statusbar($scsecond);
}

resettoprimary{
setpref(INT,"soundcard.default",1);
exec("regedit.exe /s \"".$primary_key."\"");
}

soundcards_BuildMenu{
#alternative menu for me:edit>configuration
#setmenu("_Config_General",popup,"SC Audiomapper",10);
setmenu("&Tools",popup,"SC Audiomapper",3);
setmenu("SC Audiomapper",macro,$sc_primary,primarycreative);
setmenu("SC Audiomapper",macro,$sc_secondary,secondaryfm801);
}

togglecards_SetAccels{
setaccel("CTRL ALT L","macros(primarycreative)");
}

#---------------------------------------------------------------
$OnInit=$OnInit."soundcards_BuildMenu;togglecards_SetAccels;";
$OnQuit=$OnQuit."resettoprimary;";
$macroModules=$macroModules."togglesoundcards;";

_____________________________________________________

And the two reg keys :

[HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper\soundcard1]
"Playback"="SoundMAX Digital Audio"

[HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper\soundcard2]
"Playback"="USB Headphone Set"

____________________________________________________

Thanks again !

Re: controlling two sound cards (really off-topic)
Posted by: mhf
Date: November 08, 2009 02:00AM

Looking through it again, I've just seen two places where I didn't change the names !

Re: controlling two sound cards (really off-topic)
Posted by: desga2
Date: November 08, 2009 02:19AM

@ mhf:
You must use double backslash "\\" in this lines:
$primary_key=("C:\\Program Files\\K-Meleon\\soundcard1.reg");
$secondary_key=("C:\\Program Files\\K-Meleon\\soundcard2.reg");

And change the name of functions called in BuildMenu function:

primarysoundmax{
menuchecked=(getpref(INT,"soundcard.default")=="1");
togglepref(INT,"soundcard.default",1,2);
$soundmax=getpref(INT,"soundcard.default");
$soundmax==1?&soundcard1:&soundcard2;
}

secondaryUSB{
menuchecked=(getpref(INT,"soundcard.default")=="2");
togglepref(INT,"soundcard.default",2,1);
$USB=getpref(INT,"soundcard.default");
$USB==2?&soundcard2:&setdefaultsc;
}

soundcards_BuildMenu{
#alternative menu for me:edit>configuration
#setmenu("_Config_General",popup,"SC Audiomapper",10);
setmenu("&Tools",popup,"SC Audiomapper",3);
setmenu("SC Audiomapper",macro,$sc_primary,primarycreative);
setmenu("SC Audiomapper",macro,$sc_secondary,secondaryfm801);
}

And change function called in default accelerator function:

togglecards_SetAccels{
setaccel("CTRL ALT L","macros(primarycreative)");
}

K-Meleon in Spanish



Edited 2 time(s). Last edit at 11/08/2009 02:29AM by desga2.

Re: controlling two sound cards (really off-topic)
Posted by: disrupted
Date: November 08, 2009 04:08AM

you only need to edit the parts at the beginning.. the rest doesn't really need to be changed..they might not sound correct for your soundcards but they are just statement commands and won't affect anything.. i just called them with my souncards so i don't get confused when working.

just change the parts in grey and leave rest of macro in its original code
sorry about green and red

#--edit values below according to souncard names and regkey paths
$sc_primary=("Creative SB PCI");
$sc_secondary=("FM801 audio PCI");
$primary_key=("I:\\applications\\applications-x\\PopSel\\exras\\sound1.reg");
$secondary_key=("I:\\applications\\applications-x\\PopSel\\exras\\sound2.reg");
#--end of edit values
#-------------------------------------------------------------------------------------------------

and ofcourse as desga has mentioned, the path must have double slashes \\ not just one

Re: controlling two sound cards (really off-topic)
Posted by: JFK
Date: November 19, 2009 06:06AM

Strangely I can not get this to work...

It is not changing the registry entry for some strange reason.

Edit, nevermind, I omitted a "\" in my path...

However it still refuses to play through the soundcard unless I change it manually.

I did however find another freeware utility with many more control options which stays resident in the system tray and that may be found here :

http://www.quicksoundswitch.toflo.de/



Edited 1 time(s). Last edit at 11/19/2009 07:02AM by JFK.

Re: controlling two sound cards (really off-topic)
Posted by: disrupted
Date: November 19, 2009 07:01AM

this is a nice find, thanks jfk.. it can't be integrated with km though(doesn't support commandline switches and has to be closed manually)

to use the extension, you need to make 2 separate regkeys for the 2 cards..each as default and the name for the soundcard in the regkey must be exactly as displayed under audio devices(controlpanel>audio).

also this extension will probably need administration rights or permissions to run regedit so it can merge the key and overwrite the default soundcard.. especially vista might not allow any user to merge into the registry without special rights

there's also another thing i'm not sure of because i didn't test it on 9x..it might not work on 98 because i;m not certain that the reg path for default audio device is the same there as in xp.. also for 9x even if the path is correct , the regkey must be 4.0 and not 5.0

regkey example for xp/2k etc
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper]
"Playback"="Creative Sound Blaster PCI"


but for 9x
Windows Registry Editor Version 4.00

[HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper]
"Playback"="Creative Sound Blaster PCI"


Re: controlling two sound cards (really off-topic)
Posted by: JFK
Date: November 19, 2009 07:04AM

Yes, I have it now changing the registry entry, however it is still only playing through the USB headphones unless I reconfigure my default sound device.

< shrugs >

Edit to add, my strings are :

Intel(r) Integrated Audio

Logitech USB Headset

OS - XP Pro SP2



Edited 2 time(s). Last edit at 11/19/2009 07:09AM by JFK.

Re: controlling two sound cards (really off-topic)
Posted by: disrupted
Date: November 20, 2009 03:31AM

that's strange..on my pc, it automatically swaps the soundcards..it's xp and using 2 pci soundcards, what's your operating system.. maybe it differs in another os..or maybe usb or integrated cards have to be set manually..i'm not sure

also note that if a sound is already playing and you switch to the other..the sound will still stay playing through the previous card, only when you open another stream or audio file is when the output uses the 2nd soundcard

Re: controlling two sound cards (really off-topic)
Posted by: mhf
Date: November 21, 2009 03:41AM

Sorry I didn't reply before to add my thanks for the extra help but I was away until yesterday.

Anyway, same problem here as for jfk - everything works : the menu entry, the toggle, the warning .wav and the statusbar message but the sound won't change from one card to the other !!!

So I reckon it must be a registry error but I can't see where or what.

Re: controlling two sound cards (really off-topic)
Posted by: disrupted
Date: November 21, 2009 07:31AM

ok,maybe the soundcard names are not set properly in the regkeys..in that case, windows will not change the soundcard and ignore the entry because it's not a valid audio device.

open regedit and browse to the location:
hkcu>software>micrisoft>multimedia>sound mapper


export the key as soundcard1.reg and save it to the location specified in the macro
(leave regedit open)

then open sound and audio devices and change your audio device to the you secondary(usb) click apply

go back to regedit and export the key as soundcard2.reg and save to same path specified from the macro
(leave regedit open)

now using kmeleon toggle the soundcards from the menu, refresh in regedit and see if any change happens to the playback value

if the reg value is not changed when you toggle..then check the path where you have the regkeys saved and in the macro make sure the path has double slashes like desga has mentioned not just one slash

e.g:
$primary_key=("C:\Program Files\K-Meleon\soundcard1.reg"); <-- wrong

$primary_key=("C:\\Program Files\\K-Meleon\\soundcard1.reg"); <-- correct

an easy way to test whther the path is correct is by replacing all regedit.exe entries to notepad.exe..restart kmeleon and toggle sounds.. does notepad opens the regkey to edit? if notepad opens the key..then the paths are correct..if not then the paths you've entered in the macro has an error..make sure notepad opens the regkeys and then edit the macro again and replace notepad.exe entries to regedit.exe

case 2: if the paths are all correct yet the key for playback is not changed in regedit, then that means that you need administrative rights because regedit or adding regkeys externally is disabled on your system

case 3: if the regkey is changed for playback when you toggle but the actual default device is not changed, then that means this can be something to do with limitations with usb or integrated(built-in) cards that require to be changed only from sound/control panel..in that case report back and i will try to do something with autoit that doesn't need the regkeys


i remembered something very important:
make sure in sound properties: the option 'use only the default device' is not selected..this one is trouble, make sure its unchecked before testing anything.. if it was already unchecked, then proceed normally with above steps




Edited 1 time(s). Last edit at 11/21/2009 07:36AM by disrupted.

Re: controlling two sound cards (really off-topic)
Posted by: mhf
Date: November 21, 2009 11:51PM

COOL - it works ! Thanks disrupted for taking all that time to reply and do those screen-shots and all.
It was the registry keys - when I followed your new method of exporting then changing default and then exporting again everything works fine. drool smiley

Looking forward to seeing what this idea gave you as another idea !

btw : that Simpsons link I put up now has crazy ads to go through before you can vision - hopefully that won't last sad smiley
Anyway, here's another one : The Simpsons



Edited 1 time(s). Last edit at 11/22/2009 12:42AM by mhf.

Re: controlling two sound cards (really off-topic)
Posted by: disrupted
Date: November 22, 2009 06:31AM

glad it worked, i hope that's the same error with jfk , incorrect regkeys.

that's strange becaus ei can still get to the videos directly without having to see ads, maybe it's adblockplus?



in adblockplus, i'm subscribed to those 2 filters:

easylist (usa)
cèdrics liste (deutschland)

p.s simpsons site is very bad.. addictive :d

Re: controlling two sound cards (really off-topic)
Posted by: mhf
Date: November 26, 2009 07:58PM

jfk - did you get this to work ?

K-Meleon forum is powered by Phorum.