First project: Audio

This has definitely been a huge learning experience.

Relay board video demo with my board:

There’s obviously a couple issues with my board even though it does technically function for the relay control. Changes for when (if) I do a rev2:

  1. The DAC is getting power through the pins but isn’t properly recognized through the stacking headers. I made sure none of my pins overlapped with the pins it should be using for sound but in discussion with a friend we suspect either we messed up and it does overlap someplace or it’s because the pins I (naively) chose overlap several of the i2c pins. I may cut these traces and reroute with wires or I may just move the DAC to a different Pi.
  2. Space out the transistor pads a bit. Others may not have as much problem as I had but this was an absolute nightmare for me soldering with my shaky hands.
  3. Move the relay board header over so I can properly plug into it without colliding with the tall capacitors on the relay board.

Instead of a revision and reprint of my actual board I may simply use the one I’ve got as-is and either cut the traces and place new wires to switch a couple pins or just keep what I’ve got and use a different pi to go with my DAC. Though a friend suggested I may be able to print my board and sell it to other DIY’ers so I may still do the revision even if I don’t use it for this project.

Next step: MQTT relay control

1 Like

Thanks for the video link. I’m watching it now.

I like the part of my idea where it’s just a couple boxes in a central location. It’s shortcoming is definitely that I can’t play different things in different rooms. I’ve wondered on a way of using 2 amps to allot for 2 different streams and using another relay board. The current one I’ve got would determine “on/off” and the new one would determine for each speaker whether it’s listening to amp A or amp B. This doesn’t really “solve” my limitation but it does alleviate it a bit simply by changing my limit from “1” to “2” as opposed to a fully distributed system.

The part I’m not AS happy with right now is the smoothness of the audio integration as far as playing whatever it is I want it to play from whatever device I want it to play from and the flexibility thereof. I’m trying to determine if simply I haven’t configured it all enough yet, or if I need to go another route instead of mopidy and upmpdcli.

The way it’s done in commercial audio installations is to use a thing called an audio matrix. 8x8 is common, which means it has 8 inputs and 8 outputs, and it can link any input to any output. What you’ve effectively done is make a 1x8 matrix, with one output switched to 8 outputs. If you look up “8x8 audio matrix” there should be some useful info. Most of them are very expensive rack-mount things, but there’s a really cheap matrix with a serial interface that was connected to an Arduino by a guy in the UK a few years ago. I can’t find the details now though :frowning:

1 Like

Mounting in a 2u rackmount case with plenty of room for other devices:

Next up: strain relief and cable management for the power cord and all the speakers, and getting it listening to MQTT for actually switching the relays.

4 Likes

Integration with Home-Assistant works. This is proof-of-concept. When I actually put it in the house I’ll be labeling the speakers more intuitively in the UI as opposed to simply 1-16 (and I probably won’t have all 16). I also added auto-discovery so the speakers get announced to home-assistant as switches, and sets their icon to that of a speaker as well as the appropriate MQTT command topics.

As for the code, once I add proper error handling, as well as making the architecture a bit cleaner and more generic I’ll supply a link to my code on github.

I used a JSON payload to control the speakers. So a command to “home/speakers” with a json payload:

{
    "cmd": "ON",
    "speakers": [0, 1, 4]
}

will turn on speakers 1, 2, and 5 (zero-indexed python array corresponding to the appropriate wiringpi pins).

Additional software changes to do:

  1. The “All Speakers” group is a home-assistant group that simply toggles all the switches - firing 16 MQTT messages. Instead I’ll have it send a single “ON-ALL” or “OFF-ALL” command that does them all and once (reducing the staggered “clicking” sound of the relays as well as the extra message chatter).
  2. Add groups that control the speakers per room (control to only have one speaker on in a given room, or to turn on/off an entire room at once)
  3. Add groups that set rooms into logical aliases. For example, “All Bedrooms”, “Common Areas” (Living Room + Kitchen), as in #1 above it’ll be a single request.

Additional hardware changes:

  1. Add strain relief for the cabling
  2. Once the house is going up and the speakers go in, terminate them into either RCA or banana-plug sockets at the location this setup is going.
  3. After #2: Wire the individual relays into plugs that will go into the wall sockets
  4. After #3: Install the system in a server rack - Amp, Distribution, Relay + pi case

But I think that’s it… I think what I’ve got at the moment is a working system even though I’ve got a bit more polish to go on it before it’s “production-ready”. The house it’s intended for hasn’t even broken ground yet. We’re still waiting on the appraisal.

EDIT: After more thought I’m not liking where the wiring setup is looking like it’s heading. I think I may take the extra room that is in the case and move the audio distribution panel inside of it and mount a bunch of 6.35mm TS sockets on the back. That way I’ve got 1 audio “in” and 16 audio “outs”. I can mount an internal power supply inside so I can use a standard, detachable power cable. I also won’t need a bunch of strain relief this way. I’d hoped to use the extra internal space for another Pi or 2 but I think otherwise this thing will be gnarly and accident-prone.

1 Like

Now that is what I call taking the ball and running with it! Great job! I too am watching eagerly as you are taking what is generally a commercial only application (affordability wise) and making it something a home-build kind of person can do. Kudos!

Progress is still being made:

I’ve still got to carry the ethernet from the Pi to the back of the box, as well as mounting the outputs from the Pi to the relay, and the inputs from the amp to the relay.

3 Likes

I hope you don’t mind, I’ve started creating categories so that things can be grouped together and I’ve moved this thread into the new “Home Audio” category.

1 Like

Makes complete sense.

In other news I should have this project finished today. I’ll post some more pictures and a video of it in action sometime in the next week.

2 Likes

There’s a similar project/tutorial on the Arduino forums:
https://forum.arduino.cc/index.php?topic=256759.0

Takes 6 channels for input and 6 channels for output (or 3 stereo input/outputs) but lacks the matrix switching between these. Which is what I’m most interested in. Does anyone know a way to apply matrix switching to analog signals, preferably Arduino controlled?

Relays I think is the way. Or if you want to get nitty gritty you could get a source selector IC and build a board around it.

https://www.maximintegrated.com/en/products/analog/analog-switches-multiplexers/audio.html

1 Like

Super easy, layers of relays!!! I had one sketched out on paper years ago before I went a different route due to video requirements, I’ll try to find my old notes & diagram on my old tablet to post them within the next day or 2… it’s way way easier than ud think it would be… adapting a sketch to control it would be super easy…

1 Like

I bought a speaker switcher a few years back for my daughter…
https://www.hacs.com/ab8ss.php

Never did post it. Here’s a video overview: https://photos.app.goo.gl/c8pg1G4pwnccfLhE7

1 Like