PDA

View Full Version : Swap default sound device



tanffn
28-06-2006, 01:10 PM
In case you have several SoundBlasters installed you can switch between them by going to the “Sounds and Audio Devices” under the Control-panel (under the Audio tab).

Now, how can I set the default device in code?

I found plenty of neat stuff in MMSystem but nothing that allowed me to change the default device.

Please let me know if you have any idea..

Update! this maybe works:

function SetMasterDevice(const DeviceID: Integer): MMResult;
var
Details: TMixerControlDetails;
MasterVal: TMixerControlDetailsUnsigned;
begin
with Details do
begin
cbStruct := SizeOf(Details);
dwControlID := DeviceID;
cChannels := 1; // does it really matter?
cMultipleItems := 0;
cbDetails := SizeOf(TMixerControlDetailsUnsigned);
paDetails := @MasterVal;
end;
MasterVal.dwValue := 0;
result := mixerSetControlDetails(DeviceID, @Details, MIXER_OBJECTF_AUX);

if result <> MMSYSERR_NOERROR then
raise Exception.CreateFmt('mixerSetControlDetails failure, ' +
'multimedia system error #%d', [result]);
end;

I get a MMSYSERR_BADDEVICEID error but thats maybe becouse I try to move SB 0 to SB 0 (only one SB in this computer)

savage
28-06-2006, 03:29 PM
Does this help - HKEY_CURRENT_USER\Software\Microsoft\Multimedia\So und Mapper?

If you use RegMon - http://www.sysinternals.com/ntw2k/source/regmon.shtml - you can find out which registry settings have changed when you change something in the control panel ( or elsewhere ).
PS. I have not used the tool myself, but a few people have found it usefull.

tanffn
28-06-2006, 03:31 PM
It works by changing the registry key:

HKEY_CURRENT_USER\Software\Microsoft\Multimedia\So und Mapper&#58;Playback

And I was looking for the API call :doh:

Thanks Dom :D