|
|
Subscribe / Log in / New account

Whole-house audio with free hardware and software

By Jonathan Corbet
February 1, 2016

linux.conf.au 2016
The Black Forest fire destroyed over 500 Colorado houses in June 2013; one of those belonged to longtime Debian developer Bdale Garbee. As he reported during his talk at the 2016 linux.conf.au Multimedia and Music miniconf, the house has been redesigned and rebuilt and life is generally better now. Part of the rebuilding process included the incorporation of a whole-house audio system; naturally, Bdale took a unique approach to that task. His talk showed what can be done when one starts from scratch — and doesn't mind designing a circuit board along the way.

A common approach to whole-house audio is to use a network — typically WiFi — to distribute audio bits to various places within the house. Companies like Sonos and others happily sell that kind of system; there are, Bdale said, a number of free-software projects working to replicate those products. His approach was different, though. The system was designed around speakers built into the ceiling of each room; all are wired back to a central audio server installed in a mechanical closet. In other words, analog audio, rather than a digital stream, is distributed around the house.

There are plenty of proprietary products that follow that sort of design as well. They are typically built around a two-dimensional crossbar switch that can connect specific audio sources to any of a number of audio zones. He would have been happy enough with a proprietary solution, he said; in the end, it's just an appliance installed into the house. There was, though, one absolute deal-breaker: his due-diligence work turned up the existence of probable GPL-infringement issues with these products. Just reading the manuals was enough to make it clear that they were Linux-based, but there was no mention of software licenses, and no downloadable firmware in any form, much less source code. So some other sort of solution was called for.

The revised plan called for the builder to put in the speakers and wire them back to the central closet, but to install no server; Bdale would supply that part. He spent some time looking into commercially available amplifiers and switches, but he found them to be "clunky and expensive." The products were designed as if they were to be installed into professional recording studios; they had a level of complexity that he just didn't need. If only, he said, there were a nice USB-attached device with stereo output, the rest could easily be assembled from available hardware and software. Such things do exist, of course, but there were [The usbclassd board] none that met his requirements; they required things like wall-wart power supplies, something that gets awkward when you mean to install nine of them. So he ended up designing his own hardware.

The result was the small board shown to the right. It features a PCM2705C digital-to-analog converter — essentially a USB stereo audio chip. Among its advantages are the fact that it already has good support in the Linux kernel. Tied to that is a TPA3118D2 class-D audio amplifier with 30 watts/channel of output power. Some of his audiophile friends evidently give him grief about using a class-D amplifier, but, he said, these amplifiers are good enough for a system built around ceiling-mounted speakers.

(Given that, as he said earlier in the talk, his previous office audio system was a tablet playing out of its built-in speaker, there can be no doubt that the new system sounds much better even if the gold-cable crowd would turn up its collective nose at it).

Nine of these modules (which go by the name usbclassd) are plugged into a MinnowBoard Max system. That board provides what's needed: a network interface and a USB port. The Intel architecture also seems to be important: some of the software components needed to obtain audio from commercial streaming services (he mentioned Spotify in particular) are binary-only. He is not entirely happy with that but, he said, keeping the family happy trumps adherence to open-source software principles.

The MinnowBoard is running a minimal Debian system; in general, he said, the earlier one can get out of the distribution's installer, the better. The directory tree for media is automounted (using NFS) from another server on the network. The audio software system is built around Mopidy. It was, he said, designed to be part of a desktop environment, so running it on this type of audio server is moving it a bit out of its native mode, but it works well enough. It supports the MPD protocol allowing for remote control, and has a web-interface protocol as well. He is not, he said, using Debian's packaged version of Mopidy since he needs the proprietary Spotify plugin which, naturally, Debian does not provide.

One interesting problem that had to be worked out is USB enumeration. The usbclassd boards are plugged into an inexpensive ten-port hub obtained online; those hubs, he said, are "randomly wired." The usbclassd boards [Bdale Garbee] lack unique serial IDs (something he could have added with another chip, but chose not to), so there is no way to tell them apart in the software. Fortunately, with a fixed hardware configuration, USB enumeration in the kernel is deterministic so, once he worked out which was which, it was a simple matter to map each device to the zone it serves.

One of the nice features of the amplifier he chose is that it can power down when the USB interface suspends itself. But, after realizing that those amplifiers were hot when no music was being played, he realized that things didn't quite work as he had expected. The USB audio interface doesn't suspend itself when there is no packet traffic; it depends on the suspend state of the interface in general. USB autosuspend tends not to be enabled by default, since there is a lot of second-rate hardware that doesn't support it well. His hardware does support it, though. A simple udev rule tweak was enough to get around that issue. It is still necessary to actually stop the audio stream out of Mopidy to get things to suspend, though; simply pausing it is not sufficient.

Getting back to Mopidy, he noted that it is designed to only support a single audio stream — a bit of a mismatch to his use case, with nine independent zones. His solution is to just run nine instances of Mopidy; it's a "clunky workaround," but it works. Each instance has its own MPD socket; the Mopidy Mobile app can be configured to know about all of the zones.

His final topic was clock skew. Digital audio interfaces work by streaming a series of samples to the digital-to-analog converter; that converter converts them to audio at the rate determined by the on-board clock. If you are feeding the same stream to multiple boards simultaneously, even small differences in the clock rate will accumulate over time. That can lead to the different zones being out of phase (an audiophile issue that Bdale found kind of laughable, especially given that the different zones are in different rooms) or eventual buffer underruns on the board with the faster clock. Bdale said that he could have gotten around this issue by creating a nine-output board with a single clock; a member of the audience suggested he could look into the clock synchronization support in GStreamer (which Mopidy uses). The simple fact, though, is that he doesn't really care about this issue. That could be reviewed if he ever develops the wish to drive multiple zones in parallel, but it is not an issue now.

The system is working, and the entire family seems to be happy with it. There are always improvements that can be made (he mentioned replacing the power-supply fan with "one that has ball bearings"), but, in a sense, the project can be seen as complete. For the curious, some more information, including schematics for the usbclassd board, can be found on his web site.

[Your editor thanks LCA for assisting with his travel expenses.]

Index entries for this article
Conferencelinux.conf.au/2016


to post comments

Whole-house audio with free hardware and software

Posted Feb 2, 2016 9:37 UTC (Tue) by petur (guest, #73362) [Link] (4 responses)

I'm still sad about Slim Devices selling out to Logitech and then Logitech killing their nice system entirely...

Wiring analog feels so last century

Whole-house audio with free hardware and software

Posted Feb 2, 2016 13:49 UTC (Tue) by pizza (subscriber, #46) [Link] (1 responses)

FWIW, Logitech still actively maintains the (GPL) server software, and thanks to the likes of squeezelite, nearly anything can act as a client.

(I still have an original SLiMP3, but it's been augmented by an SB Boom, a SB2, and a Raspberry Pi running squeezelite..)

Still, I understand why Logitech exited the market. It's hard to meaningfully compete with the likes of smartphones running pandora hooked up to a set of bluetooth speakers.

Whole-house audio with free hardware and software

Posted Feb 9, 2016 18:14 UTC (Tue) by davidstrauss (guest, #85867) [Link]

> It's hard to meaningfully compete with the likes of smartphones running pandora hooked up to a set of bluetooth speakers.

Or, at home, devices like Chromecast Audio or Sonos that support synchronized audio and control over Wi-Fi.

Whole-house audio with free hardware and software

Posted Feb 2, 2016 16:24 UTC (Tue) by cruff (subscriber, #7201) [Link] (1 responses)

I decided I needed to have some redundancy for my SB2 since its vacuum fluorescent display was getting burned in and dim. I managed to find a new in box SB Touch. Now to find a replacement display for the SB2 so I can restore it to its glory!

Whole-house audio with free hardware and software

Posted Feb 2, 2016 16:40 UTC (Tue) by pizza (subscriber, #46) [Link]

All of the SB displays are stock Noritake VFDs, so it's fairly straightforward to find replacements. But they do tend to be expensive.

In practice though, the my main use for the SB displays is a glorified clock. I tend to control them with the server's UI or squeezer on various android devices.

Whole-house audio with free hardware and software

Posted Feb 2, 2016 11:21 UTC (Tue) by gevaerts (subscriber, #21521) [Link] (1 responses)

I can sympathise with the randomly wired hub issue.
Ten port USB hubs are usually three four-port hubs internally. I have one where one of those claims to only have three ports, but provides four port sized data structures. The end result is that only nine of the ten ports work, but the non-working one is different depending on whether you run windows or linux.

Whole-house audio with free hardware and software

Posted Feb 2, 2016 11:56 UTC (Tue) by arnd (subscriber, #8866) [Link]

I have a four-port hub with an additional software controlled RGB LED connected to one of the internal ports. Two of the four external ports are simply wired together on a single internal port, so each works individually, but you can't plug two devices into them at the same time.

Why so much analogue?

Posted Feb 2, 2016 14:07 UTC (Tue) by tialaramex (subscriber, #21167) [Link] (11 responses)

"the gold-cable crowd would turn up its collective nose at it"

I've got no time for the "gold-cable crowd", a friend with a serious audio background recommends simply "anything thicker than bell wire" to connect speakers to amplifiers. However, I do wince at the idea of distributing the analogue signal over long distances unnecessarily. Analogue cables (whether re-purposed mains power wiring or fancy $300 per metre audiophile nonsense) love to soak up interference and running them through an entire (presumably fairly large) house means a lot of interference, why not put the analogue stage nearer the speakers ? Maybe Bdale covers that in the talk but it didn't come across to me in this article.

Why so much analogue?

Posted Feb 2, 2016 14:44 UTC (Tue) by MattJD (subscriber, #91390) [Link] (1 responses)

They probably run the amplified signal instead of digital to avoid spreading amplifiers (+ power distribution, which can affect the output) all over the house. I don't know building codes well enough to say for sure, but it probably isn't easy to stash amplifiers in ceilings either.

Also, while I agree running digital is better for as long as you can, analogue doesn't pick up that much interference with good (especially shielded) cables. And by good, I don't mean gold :). I dealt with large analogue sound system with multiple channel cables and low voltage signals, and so far I haven't had any interference issues because of that. As long as the installer avoids running all the cable next to large noise generators, it probably doesn't make any difference.

Why so much analogue?

Posted Feb 2, 2016 16:29 UTC (Tue) by daney (guest, #24551) [Link]

Analogue generally works fine as long as all the active components handling the low level signals share a common ground (mains socket). When running low level single-ended (non-differential pair) signals between rooms, Beware the ground loop! It can be nearly impossible to eliminate the 50/60Hz hum induced by the mains power wiring. Also, if you live in a location that experiences lightning storms, a nearby lightning strike can induce circuit destroying voltages if you have a design with ground/signal-wire loops in it.

Wired or optical Ethernet, or WiFi eliminate these types of issues.

Why so much analogue?

Posted Feb 2, 2016 15:13 UTC (Tue) by matthias (subscriber, #94967) [Link] (3 responses)

I do not think that running the amplified signal should be a big problem. There might be a difference if you run some low voltage analogue signal and put the amplifier at the end, as you would also amplify any interferences, but running the already amplified signal should not be that much of an issue. And we are not talking about hundreds of meters but tens of meters.

Why so much analogue?

Posted Feb 2, 2016 15:57 UTC (Tue) by hthoma (subscriber, #4743) [Link]

I agree. These are low impedance. fairly high power signals. If you run the speaker lines a long way closely parallel to a power line with high load, then they may pick up sum hum. But it is easy to avoid that.

Why so much analogue?

Posted Feb 3, 2016 10:54 UTC (Wed) by tialaramex (subscriber, #21167) [Link] (1 responses)

That's a good point and one I didn't think much about. No "might" about it for low power signals, you can hear the hum from an audio cable (at line levels, not amplified) running just a couple of metres vaguely near some other electrical equipment, but for interference after amplification the problem should indeed be much reduced because of the SNR.

Why so much analogue?

Posted Feb 4, 2016 23:48 UTC (Thu) by rahvin (guest, #16953) [Link]

You won't hear interference in amplified signals being distributed to a in ceiling speaker short of running it parallel and within a few inches of the power feeding the oven or dryer for a long distance. The maximum runs you will encounter in a residential house are less than 100' (33meters) and that's in a rotten installation point. A well centered distribution closet is more than likely going to be closer than 50' (15m) for your longer runs.

Now these distances are for average homes, not a McMansion where 100' runs may be typical. I've got whole house audio and my shortest run of speaker cable is about 10' and my longest is about 60'. I ensured I didn't run parallel to any power lines in the walls and you can't hear any hum. It's just not that complicated at the distances involved in whole home audio.

Why so much analogue?

Posted Feb 2, 2016 18:36 UTC (Tue) by Cyberax (✭ supporter ✭, #52523) [Link]

Just use shielded cables. There's no need for anything fancy, just simple cables with aluminum shielding. Be careful with the grounding and it should work fine.

Why so much analogue?

Posted Feb 2, 2016 23:16 UTC (Tue) by k8to (guest, #15413) [Link] (1 responses)

You can avoid the interference problem for quite a long way by use of balanced XLR w/ground. Simple two-wire you of course have to keep it somewhat tight.

Of course that doesn't escape the problem that you're broadcasting radio emissions via your speaker cable.

Why so much analogue?

Posted Feb 3, 2016 16:53 UTC (Wed) by jhoblitt (subscriber, #77733) [Link]

^^^This. If you "really care", this is a solved problem in the professional audio world with balanced cabling and/or powered monitors.

Gold cables are a waste of time and money

Posted Feb 3, 2016 0:09 UTC (Wed) by pr1268 (guest, #24648) [Link] (1 responses)

I've got no time for the "gold-cable crowd"

Agreed. As someone who once worked at a big box electronics retailer (which shall remain unnamed), I know from personal experience that the markup on so-called "specialty" cables was/is astronomical.

As for interference, my first idea would be to use a band-stop filter tuned to 60 Hz (or 50 Hz), but that would also block out frequencies near the note B1 (or G1).

Gold cables are a waste of time and money

Posted Feb 3, 2016 4:51 UTC (Wed) by bronson (subscriber, #4806) [Link]

> my first idea would be to use a band-stop filter tuned to 60 Hz (or 50 Hz)

In addition to modifying your audio, that won't do anything about the harmonics. It won't work well but it might be good enough.

Class-D amps are the bomb

Posted Feb 2, 2016 23:39 UTC (Tue) by pr1268 (guest, #24648) [Link]

Some of his audiophile friends evidently give him grief about using a class-D amplifier

"Dammit, Jim, I'm an audio signal amplifier, not a whole-house heater!"

I kinda feel the same way about CF/LED light bulbs vs. incandescent. (Going further off-topic: I like to say that the coil elements on an electric stove-top range are giant light bulb filaments.)

Whole-house audio with free hardware and software

Posted Feb 5, 2016 17:27 UTC (Fri) by dowdle (subscriber, #659) [Link]

Here is a video of his talk:
https://www.youtube.com/watch?v=gMTKyW6MXME

Whole-house audio with free hardware and software

Posted Feb 7, 2016 22:06 UTC (Sun) by ppisa (subscriber, #67307) [Link] (3 responses)

If single USB hub is connected or if hierarchy of hubs is connected to the single USB port then the precise topology and devices to physical ports assignment can be obtained from /sys/bus/usb/devices hierarchy examination. If you locate only physical devices (directories with pattern '^[0-9]+-[0-9]+(\.[0-9]*)*$' ) then each device is characterized by file entries

idVendor
idProduct
busnum
devnum
devpath

If you concatenate busnum and devnum you can find which USB device it is in /dev/bus/usb/BBB/DDD. The devpath is stable topological location in the USB tree.

We have used automatic topology enumeration and mapping in the hospital bed stands network for our complete infusion system design (which due to 2 kV requirement has optoisolated USB to serial inside each pump instead of direct connection to a CPU USB device port).

We have issues with FTDI driver when about 6 devices has been connected to the single 2.0 hubs hierarchy and solved this by more reliable userspace driver directly accessing kernel USB subsystem over USBDEVFS_SUBMITURB ioctl.

But if mapping to the sound device is required then /sys hierarchy can be examined deeper through the directories representing interfaces and exact mapping to the sound device name, major and minor can be found easily

/sys/bus/usb/devices/6-1/6-1:1.0/sound/card1/pcmC1D0/116:12

If there is interest then drop me an e-mail and I can try to release some part of our company code under reasonable license and it could be maintained open way with community contributions.

Whole-house audio with free hardware and software

Posted Feb 9, 2016 23:13 UTC (Tue) by bdale (subscriber, #6829) [Link] (2 responses)

The point I think you may have missed is that all of the boards I built are literally identical. It it not possible to tell them apart since they have identical USB descriptors...

The USB audio chips I selected can support an optional I2C eeprom part for holding extended descriptor information (which could, for example, include a serial number, or zone number, or something else like that), but the additional cost and complexity of having to program those didn't seem worthwhile.

So, we have 9 identical devices and a 1-time need to figure out which zone each of the enumerated devices is connected to... nothing more. In practice, that just means "play some audio through each of the 9 zones in enumerated order and see which room has sound in it".

Whole-house audio with free hardware and software

Posted Feb 10, 2016 0:32 UTC (Wed) by ppisa (subscriber, #67307) [Link] (1 responses)

The topological address (route from USB HCD to the given port on switch) is unique to each device. So even if enumeration order is not stable or if you power devices in different order you can still precisely distinguish which device is connected to which port. And yes, it is probably easiest to do initial setup once by playing sample to single zone. But if you know the cables wiring from device to room and hub port number the device is connected to then there is no need for any device serial number (which we usually have anyway) in descriptors.

Whole-house audio with free hardware and software

Posted Feb 11, 2016 22:32 UTC (Thu) by itvirta (guest, #49997) [Link]

Of course, if the routing from the chip to the physical connectors on the side of the box is random, there's still need for some
one-time mapping. :) But that can be done by just plugging something in one port at a time.

Whole-house audio with free hardware and software

Posted Feb 11, 2016 13:07 UTC (Thu) by nye (subscriber, #51576) [Link]

>Some of his audiophile friends evidently give him grief about using a class-D amplifier

I wonder if that's due to "lol class D!" or because of any particular shortcomings with this device. Based on a quick scan of the datasheet this thing looks pretty good on paper, especially for the price. Decent PSRR and SNR, with a THD of 0.1% - not outstanding but pretty close to popular chip amp parts like the LM3875 that are generally well-received, only the TPA3118D2 is much more efficient.

I'm kind of considering building something simple with one just to see what it sounds like.


Copyright © 2016, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds