{"id":142,"date":"2014-02-13T16:07:52","date_gmt":"2014-02-13T21:07:52","guid":{"rendered":"https:\/\/jimandnoreen.com\/?p=142"},"modified":"2014-03-16T09:38:25","modified_gmt":"2014-03-16T14:38:25","slug":"switching-between-hdmi-and-analog-audio-on-a-mac","status":"publish","type":"post","link":"https:\/\/jimandnoreen.com\/?p=142","title":{"rendered":"Switching between HDMI and analog audio on a Mac"},"content":{"rendered":"<p>Here&#8217;s a proven fix if you need both analog and HDMI audio outputs and require a way of switching between them. \u00a0In my case, I had an application where a rack mounted Mac Mini serves as both a media server and an audio source for a whole house paging system.<\/p>\n<p>I first tried using the headphone output as an analog audio output. \u00a0The problem is that if anything is plugged into the headphone jack, it is not possible to select HDMI for sound output via the Sound preference panel or via any other means. \u00a0Various people have posted methods for outputting audio to both HDMI and headphone out\u00a0<em>simultaneously<\/em>, but my application requires only one output to be active at any given time.<\/p>\n<p>The hardware piece of the solution is a relatively cheap <a title=\"Turtle Beach Audio Advantage Micro II USB Analog and Digital  Audio Adapter\" href=\"http:\/\/www.amazon.com\/gp\/product\/B0036VO4X4\/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B0036VO4X4&amp;linkCode=as2&amp;tag=therat00-20\" target=\"_blank\">Turtle Beach USB DAC<\/a>. \u00a0I&#8217;d imagine other USB audio converters would work equally well.<\/p>\n<p>After plugging in the DAC, I confirmed that I could switch audio sources from the Sound preference panel.<\/p>\n<p>The next step was to to automate the audio switching. \u00a0I found various Applescript techniques on the web for doing this by scripting the sound preference panel UI, but that approach seemed kludgy and probably slower than using a compiled command line tool. \u00a0If such a tool is included in OS X Mavericks, I couldn&#8217;t find it. \u00a0Fortunately, a generous developer created an output switching utility called audiodevice, which is available <a title=\"audiodevice\" href=\"http:\/\/whoshacks.blogspot.com\/2009\/01\/change-audio-devices-via-shell-script.html\" target=\"_blank\">here<\/a>.<\/p>\n<p>Audiodevice works perfectly but has one minor quirk. \u00a0Some output devices have\u00a0<strong>trailing spaces<\/strong> after their names, which need to be included in audiodevice commands.<\/p>\n<p>Here is an example of a shell script that uses audiodevice to switch audio output from HDMI to USB DAC, plays a sound effect, outputs a string that was passed to it from the command line as text to speech, and then switches back to HDMI:<\/p>\n<pre>\/usr\/local\/bin\/Audiodevice\/audiodevice output \"USB Sound Device\u00a0 \u00a0 \u00a0 \u00a0 \"\r\n\/usr\/bin\/afplay \"\/Library\/Audio\/Apple Loops\/Apple\/iLife Sound Effects\/Machines\/Communication Engaged.caf\"\r\nsay $1\r\n\/usr\/local\/bin\/Audiodevice\/audiodevice output \"HDMI Matrix\u00a0 \"<\/pre>\n<p>Notice the spaces after USB Sound Device and HDMI Matrix. \u00a0If you are not using the Turtle Beach DAC, the USB DAC may have a different name. \u00a0Use the <strong>audiodevice output list<\/strong> command to get a list of the audio output devices installed on your Mac.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a proven fix if you need both analog and HDMI audio outputs and require a way of switching between them. \u00a0In my case, I had an application where a rack mounted Mac Mini serves as both a media server and an audio source for a whole house paging system. I first tried using the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[7,31],"tags":[38,39],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8sNNV-2i","jetpack-related-posts":[{"id":253,"url":"https:\/\/jimandnoreen.com\/?p=253","url_meta":{"origin":142,"position":0},"title":"A nice display for Raspberry Pi","date":"March 8, 2017","format":false,"excerpt":"I needed a compact computer setup for my cramped electronics workbench.\u00a0 The SunFounder 10.1 inch display is both space- and cost-efficient.\u00a0 Instead of using molded parts for the case, SunFounder uses laser cut acrylic sheets, presumably to keep the cost of production down.\u00a0 A Raspberry Pi computer can be mounted\u2026","rel":"","context":"In &quot;Apple&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jimandnoreen.com\/wp-content\/uploads\/2017\/03\/IMG_3279.jpg?fit=640%2C480&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":259,"url":"https:\/\/jimandnoreen.com\/?p=259","url_meta":{"origin":142,"position":1},"title":"A USB adapter for the Apple Newton keyboard","date":"March 9, 2017","format":false,"excerpt":"Back in the pre-smartphone days, the Apple Newton was the first device in the PDA category.\u00a0 Newtons were only sold for five years between 1993 and 1998, when Steve Jobs pulled the plug on the program.\u00a0 Although Apple frequently took a ribbing for problems with the Newton's handwriting recognition feature,\u2026","rel":"","context":"In &quot;Apple&quot;","img":{"alt_text":"","src":"https:\/\/i1.wp.com\/jimandnoreen.com\/wp-content\/uploads\/2017\/03\/IMG_3278.jpg?fit=640%2C480&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":96,"url":"https:\/\/jimandnoreen.com\/?p=96","url_meta":{"origin":142,"position":2},"title":"An Indigo plugin for Lutron RadioRA 2 and Caseta","date":"September 25, 2013","format":false,"excerpt":"Lutron got a lot of things right with its RadioRA 2 lighting control system. \u00a0There are over 25 device types, including dimmers, thermostats, shades, keypads, and handheld controls. \u00a0The switches work equally well in new construction and retrofit applications. \u00a0Wireless communication is robust and the device build quality is flawless.\u2026","rel":"","context":"In &quot;Electrical&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":443,"url":"https:\/\/jimandnoreen.com\/?p=443","url_meta":{"origin":142,"position":3},"title":"More fun with AI: customization of a local LLM with a Modelfile","date":"September 23, 2025","format":false,"excerpt":"If you've played around with a generic Large Language Model (LLM) like ChatGPT for a bit of time, it's likely that you've already been frustrated by its limitations. Despite being powerful \u201cSwiss\u2011army\u2011knives\u201d that can get you started quickly, general purpose models like ChatGPT are often poorly suited to domain\u2011specific tasks.\u2026","rel":"","context":"In &quot;AI&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":304,"url":"https:\/\/jimandnoreen.com\/?p=304","url_meta":{"origin":142,"position":4},"title":"13\" Retina MacBook Pro Retina won't boot, fan running full blast","date":"March 8, 2018","format":false,"excerpt":"So this repair is mildly interesting. \u00a0The user's late 2012 MacBook Pro just wouldn't start up one morning. \u00a0It would get as far as a \"missing boot disk\" icon and shortly thereafter the fans started running full blast. Apple Diagnostics recognized that an SSD was installed but was unable to\u2026","rel":"","context":"In &quot;Apple&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":170,"url":"https:\/\/jimandnoreen.com\/?p=170","url_meta":{"origin":142,"position":5},"title":"An excellent SSD upgrade","date":"June 23, 2014","format":false,"excerpt":"I was tasked with upgrading 36 aging corporate desktop computers (HP model DC5700) to defer the next hardware refresh by 2-3 years. \u00a0Bumping the RAM to the maximum 4 GB didn't result in a satisfactory speed improvement so I decided to explore Solid State Disk (SSD) options. Users store their\u2026","rel":"","context":"In &quot;Reviews&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jimandnoreen.com\/index.php?rest_route=\/wp\/v2\/posts\/142"}],"collection":[{"href":"https:\/\/jimandnoreen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jimandnoreen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jimandnoreen.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jimandnoreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=142"}],"version-history":[{"count":1,"href":"https:\/\/jimandnoreen.com\/index.php?rest_route=\/wp\/v2\/posts\/142\/revisions"}],"predecessor-version":[{"id":143,"href":"https:\/\/jimandnoreen.com\/index.php?rest_route=\/wp\/v2\/posts\/142\/revisions\/143"}],"wp:attachment":[{"href":"https:\/\/jimandnoreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jimandnoreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jimandnoreen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}