Change speaker mode using command line (speakersetup)

Monday, March 24, 2008

Change speaker mode using command line (speakersetup)

switch speakers to headphones

My new program is yet another command line utility. This time it's about changing speaker settings mode found under control panel. I developed it mainly because I got tired of going to control panel to switch my mode to headphones every time I wanted to play Counterstrike. It's best suited for gamers and htpc addicts to change between speaker modes using shortcuts and remote controls. I myself just created two shortcuts. One for headphones mode ("speakersetup.exe hp") and one for stereo speakers ("speakersetup.exe 2"). I assigned a hotkey to each and now I can just press ctrl-f2 before starting Counterstrike to switch to headphones. You can also use it with AutoHotKey to assing a single hotkey to cycle between speaker modes (go there for an example). So here are the details:

Useage:

speakersetup.exe [Speaker Mode]

[Speaker Mode] can be one of the following:
hp: Stereo headphones
1: Monophonic speaker
2: Desktop stereo speakers (2.0)
4: Quadraphonic speakers (4.0)
5: Surround sound speakers (5.0)
5.1: 5.1 surround sound speakers
7.1: 7.1 speakers

Examples:

speakersetup.exe 5.1 will switch to 5.1 surround sound speakers.
speakersetup.exe hp will switch to headphones.

Download it here.

14 comments:

erickia said...

Great blog, hope to see more cool news soon XD

script said...

What does the Control Panel -> Sound and Audio
devices -> Advanced -> Speaker Settings actually do?

I have a laptop with internal speakers and I also plugged in external speakers.

I tried all the settings in the Control Panel -> Sound and Audio
devices -> Advanced -> Speaker Settings
But they all give me the same result... I hear the sound pretty much as expected. So what does this setting actually do?

P.S. I am on Windows XP Pro.

Vrok said...

If you only use your pc for 1 speaker setting (build in laptop speakers) then you don't need such a thing.

If you use the same PC for both (let's say) 8 speakers surround system and simple headphones you need to switch between those two modes using the control panel

script said...

Well, here is what I am trying to achieve.

I want to be able switch between these three modes:
1. only the internal loudspeakers are active.
2. only the external loudspeakers are active.
3. both the internal and external loudspeakers are active.

Right now, when the externals are plugged in, both the internals and the externals are active. I believe it should not have been like that, it might be something in the headphone jack is not tight enough. But, when I boot into Linux I was able to find a setting that will let me mute the internals while the externals keep operate. I was not able to find a setting on Windows that would let me do it.

So I was looking up for an application that will let me control this on Windows, and I hope yours can.

Frank said...

Just what I was looking for. But I cant get it to work or not sure what to do?
When I try to execute the speakersetup file the cmd window flashes and goes away.

Vrok said...

Frank: Make a shortcut for it and edit the shortcut target adding 5.1 or 2 after speakersetup.exe

frank said...

Vrok, I made a shortcut and in the target box I added the 5.1 and it gives me an error.

"C:\Documents and Settings\ME\Desktop\speakset\speakersetup.exe 5.1"

It said whats in the target box is not valid.

Thanks

Vrok said...

frank move the location of the quote like this:
"C:\Documents and Settings\ME\Desktop\speakset\speakersetup.exe" 5.1

Frank said...

Finally, got it thanks Vrok!

I look forward to using more of your useful programs.

Mike said...

This is just throwing an exception for me (XP-Pro SP3)

Is anything needed to get this running?

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyTok
en=31bf3856ad364e35' at Microsoft.DirectX.DirectSound.Device..ctor(Guid guidDev)
at speakersetup.Program.changeMode(String mode)
at speakersetup.Program.Main(String[] args)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Vrok said...

Search for the file Microsoft.DirectX.Dll and place it in the same folder with it

Mike said...

I did... I tried two different folders too.
Even if I run from cmd in the folder exe is in I get that exception. Do I need .NET 1 ?

Vrok said...

Are you sure you got the file Microsoft.DirextX.Dll? I'm not talking about Microsoft.DirectX.DirectSound.Dll. I haven't included that in the zip file.

Norbert said...

I needed to download both files:
- Microsoft.DirectX.dll
- Microsoft.DirectX.DirectSound.dll
and add them to directory from where the other dlls are and where FftGuitarTuner.exe is started from.
Now I donn't get the error anymore.

Post a Comment