Message Boards Message Boards

Get Mathematica on OS X to use the system audio output setting?

Posted 8 years ago

I'm using Mathematica 11.0.0.0 on a Mac, OS X 10.11.6. When I'm using HDMI or DisplayPort output for the display and I have the system audio set to output to HDMI or DisplayPort, Mathematica sound output (for example from ListPlay or ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"] ) still comes out of the speakers (or analog headphone jack) on the Mac Book Pro, and is not sent to HDMI or DisplayPort. All other system audio (for example, from the web browser or QuickTime) is correctly sent to HDMI or DisplayPort. I haven't found a setting anywhere in Mathematica to change this. Any ideas on how to fix this? I need this for our classroom A/V systems, since my laptop speakers are nowhere near loud enough for the classroom. As a temporary work-around I'm using VGA output and the analog headphone jack, but the video quality of VGA is not as good as digital video out, and I can't use the analog audio with the digital video.

POSTED BY: Mike Goss
4 Replies

I've come up with a solution using the init.m initialization file. I put the following lines in that file, which will set the default audio output to HDMI if it is connected, and built-in audio if not. I define the functions so I can switch if I connect/disconnect HDMI while Mathematica is running. Note that this can be defined to select either DisplayPort or HDMI by using the pattern "DisplayPort"|"HDMI" instead of just "HDMI". I'm posting here in case anyone else needs this capability.

(* Set default audio device to DisplayPort or HDMI if connected *)
resetAudio[] := $DefaultAudioOutputDevice = "Built-in Output";
setAudio[] := $DefaultAudioOutputDevice = First[Join[Cases[$AudioOutputDevices, "HDMI"], {"Built-in Output"}]];
setAudio[];
POSTED BY: Mike Goss
Posted 8 years ago

Rouge Amoeba's ( https://rogueamoeba.com/freebies/soundflower/ ) free Soundflower might do it, it has been a couple years since I used it.. Their not free Loopback software extension will definitely allow you to redirect Mathematica audio outside at the system level. I guess Mathematica does not follow MacOS's 'rules' because it needs to run on other platforms in a common way. Some of the far more experienced folks here may know of a way to do a 'within Mathematica' global redirection, all the information seems to be available.

POSTED BY: David Proffer

Thanks, that does seem to work but doesn't really solve the problem, since it requires changing all audio output cells every time I connect to a different device (this is on a laptop that I sometimes use in my office or on the bus or train with the laptop speakers or headphones, and sometimes in a classroom with HDMI). If I set it to "HDMI" and then try to use it without an HDMI device connected, I get an error until I change the setting.

What I'd really like to find is an option to just use the default OS X output device like every other application. Ideally $DefaultAudioOutputDevice would follow the OS X system settings, and not default to the built-in output (internal speakers for a Mac Book Pro).

POSTED BY: Mike Goss
Posted 8 years ago

Try:

Audio["ExampleData/rule30.wav", AudioDevice -> "HDMI"]
Audio[ExampleData[{"Audio", "Apollo11SmallStep"}, "Audio"], 
 AudioDevice -> "HDMI"]

as per Help: ref/AudioDevice

I tested and seems to work on a similar MacBookPro with LG Monitor on HDMI.

POSTED BY: David Proffer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract