Whole-house audio with free hardware and software
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
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
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 | |
|---|---|
| Conference | linux.conf.au/2016 |
Posted Feb 2, 2016 9:37 UTC (Tue)
by petur (guest, #73362)
[Link] (4 responses)
Wiring analog feels so last century
Posted Feb 2, 2016 13:49 UTC (Tue)
by pizza (subscriber, #46)
[Link] (1 responses)
(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.
Posted Feb 9, 2016 18:14 UTC (Tue)
by davidstrauss (guest, #85867)
[Link]
Or, at home, devices like Chromecast Audio or Sonos that support synchronized audio and control over Wi-Fi.
Posted Feb 2, 2016 16:24 UTC (Tue)
by cruff (subscriber, #7201)
[Link] (1 responses)
Posted Feb 2, 2016 16:40 UTC (Tue)
by pizza (subscriber, #46)
[Link]
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.
Posted Feb 2, 2016 11:21 UTC (Tue)
by gevaerts (subscriber, #21521)
[Link] (1 responses)
Posted Feb 2, 2016 11:56 UTC (Tue)
by arnd (subscriber, #8866)
[Link]
Posted Feb 2, 2016 14:07 UTC (Tue)
by tialaramex (subscriber, #21167)
[Link] (11 responses)
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.
Posted Feb 2, 2016 14:44 UTC (Tue)
by MattJD (subscriber, #91390)
[Link] (1 responses)
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.
Posted Feb 2, 2016 16:29 UTC (Tue)
by daney (guest, #24551)
[Link]
Wired or optical Ethernet, or WiFi eliminate these types of issues.
Posted Feb 2, 2016 15:13 UTC (Tue)
by matthias (subscriber, #94967)
[Link] (3 responses)
Posted Feb 2, 2016 15:57 UTC (Tue)
by hthoma (subscriber, #4743)
[Link]
Posted Feb 3, 2016 10:54 UTC (Wed)
by tialaramex (subscriber, #21167)
[Link] (1 responses)
Posted Feb 4, 2016 23:48 UTC (Thu)
by rahvin (guest, #16953)
[Link]
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.
Posted Feb 2, 2016 18:36 UTC (Tue)
by Cyberax (✭ supporter ✭, #52523)
[Link]
Posted Feb 2, 2016 23:16 UTC (Tue)
by k8to (guest, #15413)
[Link] (1 responses)
Of course that doesn't escape the problem that you're broadcasting radio emissions via your speaker cable.
Posted Feb 3, 2016 16:53 UTC (Wed)
by jhoblitt (subscriber, #77733)
[Link]
Posted Feb 3, 2016 0:09 UTC (Wed)
by pr1268 (guest, #24648)
[Link] (1 responses)
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).
Posted Feb 3, 2016 4:51 UTC (Wed)
by bronson (subscriber, #4806)
[Link]
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.
Posted Feb 2, 2016 23:39 UTC (Tue)
by pr1268 (guest, #24648)
[Link]
"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.)
Posted Feb 5, 2016 17:27 UTC (Fri)
by dowdle (subscriber, #659)
[Link]
Posted Feb 7, 2016 22:06 UTC (Sun)
by ppisa (subscriber, #67307)
[Link] (3 responses)
idVendor
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.
Posted Feb 9, 2016 23:13 UTC (Tue)
by bdale (subscriber, #6829)
[Link] (2 responses)
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".
Posted Feb 10, 2016 0:32 UTC (Wed)
by ppisa (subscriber, #67307)
[Link] (1 responses)
Posted Feb 11, 2016 22:32 UTC (Thu)
by itvirta (guest, #49997)
[Link]
Posted Feb 11, 2016 13:07 UTC (Thu)
by nye (subscriber, #51576)
[Link]
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.
Whole-house audio with free hardware and software
Whole-house audio with free hardware and software
Whole-house audio with free hardware and software
Whole-house audio with free hardware and software
Whole-house audio with free hardware and software
Whole-house audio with free hardware and software
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
Why so much analogue?
Why so much analogue?
Why so much analogue?
Why so much analogue?
Why so much analogue?
Why so much analogue?
Why so much analogue?
Why so much analogue?
Why so much analogue?
Why so much analogue?
Gold cables are a waste of time and money
I've got no time for the "gold-cable crowd"
Gold cables are a waste of time and money
Class-D amps are the bomb
Some of his audiophile friends evidently give him grief about using a class-D amplifier
Whole-house audio with free hardware and software
Whole-house audio with free hardware and software
idProduct
busnum
devnum
devpath
Whole-house audio with free hardware and software
Whole-house audio with free hardware and software
Whole-house audio with free hardware and software
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
