Jump to content

SwitchSound Script


ANARCHiNTOSH
 Share

21 posts in this topic

Recommended Posts

SwitchSound v2.0

An audio device toggling solution written in Applescript, with support for visual and audio notifications.

Especially useful for those using their motherboard's multiple analog audio outs for surround sound.

eg. ALC889a ALC888 etc

 

Handy Hint

You can quickly bring up a full list of sound devices by Alt+Clicking on the volume icon in the OSX menubar.

This is neat if you regularly use more than two sound devices.

 

Info for Surround Sound users:

I made this pack as a resource for users with analog surround sound gear like myself.

Real macs don't have built-in analog surround sound, so users have to do it themselves.

SwitchSound should also be useful for real mac owners with external analog audio output hubs...

You will notice in OSX that you cannot adjust global surround volume via the sound hotkeys. There is no way round this. Whilst you will want to use your aggregate device when you want surround sound, most of the time, you will be only wanting to use stereo (eg. use front speakers for iTunes, Youtube etc, surround for XBMC or VLC).

So i (with the help of other people's work) made something that will do this.

I wanted my surround sound to fully gel into the mac experience, so i wrote this applescript pack, with full installation instructions.

 

Who is this script for?

People who regularly use two different sound devices. Like surround + stereo,

or surround + headphones (if your headphone socket doesn't automaticly switch device when you plug in/remove headphones). Please note, this script can also be used for Digital and Soundflower outputs, as well as inputs.

Any device that shows up in Audio MIDI Setup.app can be controlled by the script.

 

Why might you want it?

So that you can switch quickly between your most used sound output devices.

To more fully integrate surround sound into the mac experience.

Apple provides no hotkey method to switch between sound devices.

 

What does it do?

Lets you use a hotkey (F1, F2 etc any other key or combination of keys you want) to swap sound device.

Thanks to growl, when activated it provides you with a nice and non-intrusive visual popup notification.

It also provides an audio notification. (You can edit almost every aspect of the script in the user settings)

Just like how the genuine volume hotkeys work on OSX.

 

How does it work?

When you hit the hotkey, Quicksilver (or any other hotkey app) runs the applescript, which intelligently toggles between your sound devices by executing an unseen shell script which tells the core commandline utility SwitchAudioSource which device to switch to. At the same time it tells Play Sound to play a sound file silently and sends a notification to Growl, complete with the device-name, informative text and image. Play Sound.app and SwitchAudioSource executable are contained in a hidden folder in the SwitchSound folder.

 

If you do not want the bloat of Growl (for slow macs/hacs), the script functions fine without it. You can also disable Play Sound in the scripts user settings.

 

Growl's Bezel style is very close to the genuine apple volume adjustment pop-up.

Heres a preview of just a few ways the notifications can be configured:

FrontSpeakersweb.jpg51web.jpg

 

ipodweb.jpgCinemaweb.jpg

 

Download the SwitchSound diskimage below, and follow the How-To Guide.pdf to get it set-up.

The installer asks you if you want to install the switchaudiosource utility to terminal but it is completely optional.

 

Download SwitchSound-v2.0.1.dmg:

[Mirror 1] [Mirror 2] [Mirror 3] [Mirror 4]

 

The next major version (2.1) will have these features added:

>Support for cycling through more than two devices

>A second script set up for only switching to one device.

Why? so hotkeys are static and used for switching to one device only.

 

Long term To-Do

>Some easier/simpler way to configure settings, GUI based. (possibly)

Link to comment
Share on other sites

do you have a script to uninstall please because i have no sounds in any output

 

i m running vgn-ar61zu vaio with needed kext alc262 and stac 7664 +hdmi

script is very high level, doesnt change anything at system level, so you don't need to uninstall (to uninstall you delete switchsound folder).

 

 

To select a sound device manually (this might be what you need to do?)

use system preferences > sound > output

or Audio MIDI Setup.app ctrl + click on device in left toolbar you want to use and click "Use this device for sound output"

Link to comment
Share on other sites

As a suggestion, if you intend to add a GUI to the script, it would make sense to keep it as it is, that is, as a script which is executed once and then closes, not running in the background all the time. This feature is perhaps one of the few reasons why I prefer it to, for instance, SoundSource, a free application from Rogue Amoeba.

Link to comment
Share on other sites

As a suggestion, if you intend to add a GUI to the script, it would make sense to keep it as it is, that is, as a script which is executed once and then closes, not running in the background all the time. This feature is perhaps one of the few reasons why I prefer it to, for instance, SoundSource, a free application from Rogue Amoeba.

i agree with your idea of a once-run script... its lite on the cpu

btw, SoundSource is kind of defunct in 10.6 --- if you alt+click on the sound icon in the menubar, you can change input/output device. i'll add this hint to the first post

Link to comment
Share on other sites

This sounds interesting, one question though. When I look at the PDF it does´nt say anything about Pci soundcards so I´m wondering if it would see my M-Audio Delta 1010 or 44 multichannel soundcards.

 

Why I´m asking is cause I broadcast web tv on justintv, Livestream tv and few more. Some sites have their own broadcaster and on some I use Camtwist and Flash Media Live Encoder for my cast. This gives I would like to be able to switch soundcards while casting if I need to. For example at one point I might want to cast video from my desktop or from Camtwist and use soundflower for internal sound and then I might wanna go over to cast when I record music in Logic using my M-Audio delta card. In Livestreams Procaster all I can go for is internal line in sound which would be cool if I could trick/get pass in some way.

Link to comment
Share on other sites

This sounds interesting, one question though. When I look at the PDF it does´nt say anything about Pci soundcards so I´m wondering if it would see my M-Audio Delta 1010 or 44 multichannel soundcards.

 

Why I´m asking is cause I broadcast web tv on justintv, Livestream tv and few more. Some sites have their own broadcaster and on some I use Camtwist and Flash Media Live Encoder for my cast. This gives I would like to be able to switch soundcards while casting if I need to. For example at one point I might want to cast video from my desktop or from Camtwist and use soundflower for internal sound and then I might wanna go over to cast when I record music in Logic using my M-Audio delta card. In Livestreams Procaster all I can go for is internal line in sound which would be cool if I could trick/get pass in some way.

 

the script uses SwitchAudioSource as it's backend for switches.

SwitchAudioSource can see any device that can be seen in Audio MIDI Setup.app, this includes inputs as well as outputs.

If your PCI card shows up in Audio MIDI Setup.app then it will switch to it.

However... i don't know about tricking webcasters....

Link to comment
Share on other sites

Been looking at this and what I wanted to use it for I´m not sure it can do actually. Came to my mind both the livestream procaster and flash media live encoder kind of locks to the switching that actually can be done inside the programs which is mostly when not broadcasting. At least for FMLE, Procaster probably can do it on air though but does´nt seem to like any of my soundcards but onboard sound line in, it uses something they call Audioredirector which might even be a script already. Why it doesn´t like nothing but line in is probably cause this is a hackmac lol.

 

The device switching with this script I believe would be on a "lower" level so the device already set inside the programs would either play back or just get muted if I switch devices with this script.

 

Am I right?

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...
Any progress towards reaching 2.1 version? It would be nice to be able to switch between multiple sources.

hey, i know i promised 2.1, but it turns out more than two devices introduces quite a few complications in the already bloated applescript. I reccommend using Alt+Click on the sound icon in menubar for switching to and from your most rarely used device. I've been heavily involved in Python coding recently for my xbmc addon.

Link to comment
Share on other sites

  • 10 months later...

QUOTE (HCE @ Jan 13 2011, 08:37 PM)

Any progress towards reaching 2.1 version? It would be nice to be able to switch between multiple sources.

 

hey, i know i promised 2.1, but it turns out more than two devices introduces quite a few complications in the already bloated applescript. I reccommend using Alt+Click on the sound icon in menubar for switching to and from your most rarely used device. I've been heavily involved in Python coding recently for my xbmc addon.

the download address was outdate please release a new one!

Link to comment
Share on other sites

  • 5 months later...

i have the same error and it doesn't show in growl

 

 

error "AppleScript Editor got an error: alias \"Lion:Library:Scripts:SwitchSound:Sounds:drumshigh.aif\" doesn’t understand the «event µSNDplay» message." number -1708 from alias "Lion:Library:Scripts:SwitchSound:Sounds:drumshigh.aif"

 

Lion 10.7.3

Quicksilver ß60 (3850)

Growl 1.3.3

 

when i press hotkey Apple Script Editor with empty window opens and thats it and when i run script in Apple Script Editor i got error from above

Link to comment
Share on other sites

 Share

×
×
  • Create New...