Escape Cable Hell With An Audio I/O Multiplexer

If you ever find yourself swapping between a mix of audio inputs and outputs and get tired of plugging cables all the time, check out [winslomb]’s audio multiplexer with integrated amplifier. The device can take any one of four audio inputs, pass the signal through an amplifier, and send it to any one of four outputs.

The audio amplifier has a volume control, and the inputs and outputs can be selected via button presses. An Arduino Pro Mini takes care of switching the relays based on the button presses. On the input side, you can plug in devices like a phone, TV, digital audio player or a computer. The output can be fed to speakers, headsets or earphones.

At the center of the build lies a TI TPA152 75-mW stereo audio power amplifier. This audio op-amp is designed to drive 32 ohm loads, so performance might suffer when connecting it to lower impedance devices, but it seems to work fine for headphones and small computer speakers. The dual-gang potentiometer controls the volume, and the chip has a useful de-pop feature. The circuit is pretty much a copy of the reference shown in the data sheet. Switching between inputs or outputs is handled by a bank of TLP172A solid state relays with MOSFET outputs, and it’s all tied together with a micro-controller, allowing for WiFi or BLE functionality to be added on later.

[winslomb] laid out the design using Eagle and he made a couple of footprint mistakes for the large capacitors and the opto-relays. (As he says, always double-check part footprints!) In the end, he solder-bridged them on to the board, but they should probably be fixed for the next revision.

[winslomb] built the switch as his capstone project while on his way to getting a Masters in EE, and although the device did function as required, there is still room for improvement. The GitHub repository contains all the hardware and software sources. Check out the video below where he walks through a demo of the device in action. If you are looking for something simpler, here is a two input – one output audio switcher with USB control and on the other end of the spectrum, here’s an audio switch that connects to the Internet.

46 thoughts on “Escape Cable Hell With An Audio I/O Multiplexer

      1. Those are far from the only analog switches on the market. However, with 35 ohm output resistance, they’re not suitable for placing after a power amplifier; it’d make much more sense to have one amplifier per output and use analog switches on the input in that case.

  1. His comment at wanting to find another board with more GPIO to add more channels is…. awkward. A budding EE should be aware of more solutions than just throwing a bigger MCU at the problem.

    1. Two shift registers and this can be done with even PIC10F, Also for audio one should use “normal” relays instead. And who would need 4 selectable outputs? I would be happy with two outputs: one for headphones and one for PA.

      1. I would. I have three MORSE CODE Keys and each could be selectable to any one of four radios used for transmitting. The basic premise is to switch any device to any radio. and the radios have 3.5mm jacks for the inputs and surprise the the output too.

    2. Most of the times throwing a bigger MCU is the cheapest solution, especially in a 1 of circuit when you consider the time. I really don’t get the people using a small $1 MCU with a $1 port expander when a $2 micro would be a much simpler and better solution. there’s no extra code for an expander.

    3. My point wasn’t that he shouldn’t use a larger MCU or that he should use shift registers or expanders. My point was that such an offhand remark gives the impression that he’s either not aware of his options and the why behind it or he’s just a crappy budding engineer that throws bigger things at the problem.

      Point… the Atmega328 has 23 GPIO and +2ADC (on some packages). Tossing away 3 GPIO leaves him 20 GPIO. A dumb split yields 11 audio ports for his enjoyment using his current design choices. That’s 3 more ports than he designed for. If he failed to note this and his alternatives for a capstone project, I’d dock him for it. I can easily double the audio port count without resorting to IC’s or putting too much thought into it.

      In addition, I’m prety sure the Arduino has libraries for most basic input configurations so it’s not like he’ll be blowing hours debugging it.

  2. Great work winslomb! I am really curious what is the effect of the SSR on the output signal….i don’t think they are designed for that, however there is nothing in the datasheet to point that it would not work. Any analysis?

    I am working on a similar thing, but by combining with this http://www.electrobob.com/auto-amp/ i will do auto detection and source selection. In my case I don’t need multiple outputs, so the thing does not need any buttons, it will just be a magic box hidden somewhere.

  3. I want to user a Raspberry to switch between three audio input sources to an amp that has only one input. I’ve tried using two Y splitters but that degraded the sound quality. Point me (in newbie language) to some components to use for this please. Simpler and cheaper is better. Would the MAX4571 mentioned above be a match for this task? If not what would? The Raspberry is part of the plan because it is already close to the amp and I’m familiar with using its GPIO.

    An advanced bonus feature would be to somehow have it sense when there is audio input coming in only one of the three inputs and then automatically direct that input into the amp.

    1. Just grab a board with 2 DPDT relays (i assume stereo sources). One relay selects source 1 or 2, the second relay selects source 3 or relay 1, thus you have a 3 input selector.
      http://www.ebay.com/itm/Two-DPDT-Signal-Relay-Module-Board-DC5V-Version-for-PIC-Arduino-8051-AVR-/400272908552
      Of course, you could also build the board, but that would be fastest.

      An easy way to detect with the RPI would be more complicated, there is no analog input….

  4. Mixers are great for this task on the input side, and a speaker switch on the amp. With a mixer though you might find that just tying all the sources together will suffice as each source has it’s own power and volume or mute button. This has to be done with resistors mixing usually.
    My computers are in series with the final sounds going to a simple 4 channel mixer along with the radio (often on) and a cassette deck. I need to stuff a preamp into the turntable, then it could be the fourth line level input. It’s getting dusty since the stereo amp went because of age. I am now 4.1 with on old organ amp set and a fancy home theater style amp that has no power amps (lightning strike) or phono input. The amp will also give me a single Quad input from both computers together or one with 4 channels out.
    I wouldn’t mess around with 32 ohm stuff as far as the load, get an amp. 32 ohm sources are fine. Listening to your phone’s player on headphones with anything else in the path is a boat anchor.

    1. I thought so too, when i started my auto selection box. But, some sources are poorer quality, like bluetooth. If i mix the bluetooth output and PC i will always hear the small hiss from the bluetooth, damaging the quality output from the PC.
      What I am working on is a 4 to 1 selection, with PC, bluetooth, tablet and one aux automatically selected for the amplifier.

          1. Well, i can see what you mean. From my point there is never a need to listen to 2 at the same time. so even a mixer is still a switching mechanism, if i turn off the sources without a signal.

  5. I’m an audio guy (ie, I like to design and build DIY audio systems) and here’s some links to my own arduino open-source (hw+sw) relay attenuator (volume control) and i/o selector (also relay based):

    http://www.amb.org/audio/lcduino1/
    http://www.amb.org/audio/delta1/
    http://www.amb.org/audio/delta2/
    http://www.amb.org/audio/alpha10/

    https://c1.staticflickr.com/1/290/18622950416_89c04fc4e5_z.jpg

    the LCDuino was my first arduino project and its been a very popular lcd ‘backpack’ with an intent to be used to create simple lcd interfaces for audio (and other) projects. the delta1 relay attenuator can be configured via an online resistor value calculator to use up to 8 relays and the usual config is 0.5dB steps with 127.5dB max attenuation (going up to 0.0, which is a full pass-thru). we’ve been able to send close to 1mhz thru it, so its definitely good enough for audio band coverage ;)

    and now I’m working on xbee-based remote controls for this system, which also includes DIY spdif switching, analog audio switching and hdmi video switching.

    I work with AMB.org and we use his website to sell bare boards; all the parts can be bought at mouser/etc.

    so, there’s another audio-based arduino project. I also gave a half hour talk at the last ‘burning amp’ DIY audio event: https://www.youtube.com/watch?v=7fvRZYyTh90 and that features many of my arduino-based audio projects (lots of blinkenlights, too, of course).

      1. I could talk for hours about the why’s ;)

        I do use solild state controls for some applications (the PGA is ok but fussy about layout and other issues; the cirrus 3318 is my chip of choice for vol control with 8chans of nearly noiseless attenuation). but for the cleanest sound, you cannot beat the relay atten. it has no max input (I’ve put 60v thru it just to be able to see microvolts come out from the 127.5dB atten), it has perfect left/right balance at all steps, I use latching relays so there’s no holding current after the latch switch-over, and there is no specific need for a buffer after the atten, if you are driving an amp directly (as long as you keep the cable short; as you are not low-z anymore after you exit the atten stages). all other vol controls that use chips have noise as you get closer to 0dB, but the relay atten does not. and the solid state controls all have max input ranges before they clip and all need dual 8 or dual 12v supplies; the relay atten runs from simple 5v.

        finally, you can configure it to be whatever you want; I built one that did 32db of range at 0.1dB steps; meant for subwoofer control and tweaking. there are no solid state chips that can run at .1dB steps.

        the down-side is that each time you turn the knob or use the remote, there is relay mechanical sound. its only during vol changes, but its still audible as subtle clicks in the audio and mechanical relay noise. I did my best to minimize the relay clicks due to software timing tricks but since there is no zero-crossing circuit (solid state audio attens usually have deferred vol changes based on zero crossing events) there will always be clicks on even the best relay attens. then again, the solid state ones also have dc offset issues and you must ensure the input is not riding on any dc or you WILL get clicks no matter what tech you use.

        1. oh, and in regards to the dac, that works fine for when the source is digital; but what about analog sources? you don’t want to go thru an a/d just so you can use the dac’s vol control. and most dac’s do a bad job on vol control; it usually just truncates bits rather than doing the vol control scaling the hard way. very few dacs do vol control well enough to justify using them.

          digi pots don’t have any zero crossing detection so they are not well suited to audio and they are also not meant to pass audio cleanly, they usually are not audio log taper and they usually don’t have a large enough calibrated range to be useful for audio.

      2. “I specified a multiplying DAC – you use the audio input as the ‘reference’ voltage, and use the DAC to control attenuation.”

        but where does the analog source get its attenuation? again, if your signal is already digital, that’s fine; but not every source is digital and so, going thru an a/d just to use a dac’s attenuation is not a very good solutuion at all.

        1. The output of the DAC is (codepoint / max_codepoint) * vref, and vref varies with the audio input signal. It’s a perfectly legitimate use of a DAC – see section 6.9 of MCP4922’s datasheet, for instance, though as a single-supply DAC it’s obviously not the ideal choice in a situation like this.

        1. ah! now I get what you guys are saying. interesting use of a dac. not sure I ever saw one used that way for analog vol control. wonder if it has any advantages over the other methods?

          there must be some drawbacks, as I have not heard of a single diy’er or vendor doing analog audio atten this way.

      1. the clicks are not all that bad, but it depends on where you are in the dB value range. some values are much more clicky than others; for example the binary rollovers from 31.5 to 32 and 63.5 to 64. that’s where lots of relays need to change state. on the cases where there are only 1 or 2 relays, the clicks are barely audible.

        I have an idea on how to completely remove the clicks but until I’ve tried the idea on actual hardware, I can’t be sure it will work as well as the theory suggests. if I ever get to try it, I’ll certainly write up my idea.

        for 2ch stereo, the relays are not all that bad; but I’d NEVER use this for 4ch or 6ch or 8ch. just too many relay boards ‘in flight’ and it gets out of hand quickly. I did try building one to see what it would be like and while it did work, it made the devil’s own noise as you turned the knob.

        https://c2.staticflickr.com/6/5208/5312514633_f9e1b702eb_z.jpg

        1. the only way i can think of is to add a fast switching element…. for example at the input. disconnect the signal on a zero cross, change the relays, reconnect at the next zero cross. this will blank the signal fro 10-20ms needed for relays to switch, I don’t know how that would sound.

          To avoid the high clicks you are getting when many relays switch you should use grey code. That way, there is only one relay toggling between 2 successive steps.

        2. I would use motorized faders for multichannel attenuators. If it is good enough for the pros on a mixer for working in the studio, the it should be more than enough for the rest. There is also ADC to DSP back to DAC.

          Analog guys, at least for the few that I worked with tend to get too specialized and not consider other solutions outside of their comfort zone. i.e. DAC or digital domain of doing thing etc

  6. I’m sorry, but isn’t this a bit poor for a master(!) in EE? An inapt amplifier (with schematic c&p from datasheet), some questionnable choice of SSR according to Bogdan’s comment, an arduino and some calls to digitalWrite(), that’s it basically. Well….
    (Yes, my english is probably quite bad.)

    1. Was exactly my thoughts. As a DIY for a newbie, it’s a decent project that shows some mistakes made through the learning process of designing and building a PCB. As a “capstone for a Masters in EE” project, it’s rather discouraging. The Arduino isn’t even necessary.

  7. I love seeing flying caps and pcb ‘oopsies’ because they remind me that everyone is human, and I shouldnt be so hard on myself when a board comes back from OSHpark and I realized I forgot a decoupling cap or the resistor I need isn’t available is the size I wanted :)

Leave a Reply to BogdanCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.