Jump to content

SwitchSound Script


  • Please log in to reply
20 replies to this topic

#1
ANARCHiNTOSH

ANARCHiNTOSH

    Loldermort!!!!

  • Members
  • PipPipPipPip
  • 221 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:
Posted ImagePosted Image

Posted ImagePosted Image

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)

#2
jlvaio

jlvaio

    InsanelyMac Geek

  • Members
  • PipPipPipPip
  • 220 posts
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

Attached Files



#3
ANARCHiNTOSH

ANARCHiNTOSH

    Loldermort!!!!

  • Members
  • PipPipPipPip
  • 221 posts

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"

#4
HCE

HCE

    InsanelyMac Protégé

  • Members
  • Pip
  • 30 posts
Very nice. Thanks for this. It takes a bit of tinkering to configure everything "just right", but once configured it does what it is supposed to do.

#5
ANARCHiNTOSH

ANARCHiNTOSH

    Loldermort!!!!

  • Members
  • PipPipPipPip
  • 221 posts

Very nice. Thanks for this. It takes a bit of tinkering to configure everything "just right", but once configured it does what it is supposed to do.

@HCE glad to hear it works for you

@everyone
suggestions are welcomed and encouraged

#6
HCE

HCE

    InsanelyMac Protégé

  • Members
  • Pip
  • 30 posts
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.

#7
ANARCHiNTOSH

ANARCHiNTOSH

    Loldermort!!!!

  • Members
  • PipPipPipPip
  • 221 posts

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

#8
asdfeas

asdfeas

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 7 posts
it's very nice .i prefer it and already have it .Posted Image
and it running well Ion my system.

#9
starobrno1

starobrno1

    InsanelyMac Legend

  • Banned
  • PipPipPipPipPipPipPip
  • 930 posts
  • Gender:Male
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.

#10
ANARCHiNTOSH

ANARCHiNTOSH

    Loldermort!!!!

  • Members
  • PipPipPipPip
  • 221 posts

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....

#11
starobrno1

starobrno1

    InsanelyMac Legend

  • Banned
  • PipPipPipPipPipPipPip
  • 930 posts
  • Gender:Male
Ok thanks, just one way to find out I guess lol.

#12
starobrno1

starobrno1

    InsanelyMac Legend

  • Banned
  • PipPipPipPipPipPipPip
  • 930 posts
  • Gender:Male
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?

#13
ANARCHiNTOSH

ANARCHiNTOSH

    Loldermort!!!!

  • Members
  • PipPipPipPip
  • 221 posts
sorry for the long wait:
er, im not sure, i think you'll just have to give it a try
it changes the device authentically like System Preferences > Sound does

#14
sama7896

sama7896

    InsanelyMac Sage

  • Members
  • PipPipPipPipPipPip
  • 440 posts
  • Gender:Male
i was using Sound menu

#15
starobrno1

starobrno1

    InsanelyMac Legend

  • Banned
  • PipPipPipPipPipPipPip
  • 930 posts
  • Gender:Male
Google for the LineIn app does the same but no surround though

#16
ANARCHiNTOSH

ANARCHiNTOSH

    Loldermort!!!!

  • Members
  • PipPipPipPip
  • 221 posts

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.

you dont actually need those apps

#17
HCE

HCE

    InsanelyMac Protégé

  • Members
  • Pip
  • 30 posts
Any progress towards reaching 2.1 version? It would be nice to be able to switch between multiple sources.

#18
ANARCHiNTOSH

ANARCHiNTOSH

    Loldermort!!!!

  • Members
  • PipPipPipPip
  • 221 posts

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.

#19
generaltlt

generaltlt

    InsanelyMac Protégé

  • Members
  • Pip
  • 7 posts

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!

#20
Acid_Burn

Acid_Burn

    Crash&Burn

  • Members
  • PipPipPipPipPipPipPip
  • 757 posts
  • Gender:Female
  • Location:011011100111001001110111
  • Interests:Hack the Planet!
When i starts the Script, comes a fail message...

Posted Image





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy