<?xml version="1.0" encoding="utf-8"?>
<!-- name="generator" content="pyblosxom/1.4.3 01/10/2008" -->
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">

<rss version="0.91">
<channel>
<title>rozzin's journal   </title>
<link>http://www.hackerposse.com/~rozzin/weblog</link>
<description>an online journal</description>
<language>en</language>
<item>
  <title>Whole-Home Audio with MPD + PulseAudio</title>
  <link>http://www.hackerposse.com/~rozzin/weblog/whole-home-pulseaudio.html</link>
  <description><![CDATA[
<p>I have a <a href="http://en.wikipedia.org/wiki/Whole_House_Audio">whole-home audio</a>
system that I cobbled together out of spare PCs and low-cost, low-power
<a href="http://www.plugcomputer.org/">plug-computers</a> running a mostly-stock
<a href="http://www.debian.org/releases/squeeze">Debian 6.0</a> with
<a href="http://www.musicpd.org/">MPD</a> and <a href="http://www.pulseaudio.org">PulseAudio</a>,
and which works better than any of the prefabricated solutions that I could
find. Not only is it <em>better</em>, but it deployed <em>cheaper</em>, <em>and</em> it was
actually <em>quicker</em> to build it than it would have been to finish evaluating
the canned solutions and buy one. And, since the protocols (and software)
in use are all open standards and Open Source, there's no danger of
<a href="http://en.wikipedia.org/wiki/Vendor_lock-in">vendor-lock</a>.</p>

<p>This setup uses <a href="http://en.wikipedia.org/wiki/IP_multicast">multicast</a>
<a href="http://en.wikipedia.org/wiki/Real-time_Transport_Protocol">RTP</a>
with latency-matching across all nodes in the network; I have only
one `channel' right now (in the radio-tuner or input-switching sense,
not in the `mono vs. stereo' sense), but it's possible to define
multiple channels (or `sources', in proper home-audio vocabulary)
by giving them separate multicast addresses, and then a given receiver
can be siwtched to another channel just by changing the multicast address
on which that receiver listens.</p>

<p>Because of the latency-matching, multiple receiver-nodes (to the
extent that the ear can tell) all have their playback <em>perfectly
time-synced</em> such that there's no `echo' or `reverb' effect
when standing between two adjacent rooms with separate receivers.
I actually compared this against how well two different FM radios
in adjacent rooms sync to the same radio station, and <em>the RTP system
did better</em>. Really, multicast RTP over ethernet + dynamic
resampling-algorithms with latency-analysis on pentium-class CPUs
with network time-sync... provides quite a convincing emulation
of speaker-wire. Of course, it also provides a lot of dreamy features
that speaker-wire... can't even dream about.</p>

<p>That it's MPD-based means that I can have a single playback- and
playlist-control server for the entire house, accessible from anywhere
on the network; in other words, I have multiple `single points
of control': client UIs are available for desktop and laptop computers
of all OSes, Android devices, my friends' Apple iThings
(which can automagically discover the MPD server via
<a href="http://en.wikipedia.org/wiki/Zeroconf#DNS-SD">ZeroConf</a>),
etc.--there's even <a href="http://code.google.com/p/remuco/">an adaptor</a> that
enables `dumb phones' with <a href="http://en.wikipedia.org/wiki/Javame">Java ME</a>
to control MPD via bluetooth (or Wi-Fi, if they have it).</p>

<p>MPD manages playlists on the server, and can be told by the clients
to load them or to create and store new ones--and playlists
can include not just any of the tracks stored on the server,
but also anything available via an HTTP URL (e.g.: Internet radio,
or an audio-file shared by a laptop or other system on the LAN).</p>

<p>Of course, Using MPD also means that I can use all of the tools and plugins
that exist for MPD--like
<a href="http://en.wikipedia.org/wiki/Audioscrobbler">last.fm/audioscrobbler</a> support,
and my `<a href="http://www.hackerposse.com/~rozzin/mpdjay">mpdjay</a>' autojockey script
(which elicited such a positive response from my wife--along the lines of
 `OMG it's so awesome! Can you make me a portable version‽'--that we now
 both have <a href="http://en.qi-hardware.com/wiki/Ben_NanoNote">NanoNote</a> units
 running a pocket-sized setup similar to this, but without the multicast).</p>

<p>And MPD does <a href="http://en.wikipedia.org/wiki/Gapless_playback">gapless playback</a>,
and it can use <a href="http://en.wikipedia.org/wiki/ReplayGain">ReplayGain</a> to
automatically adjust for differences in overall volume between
different tracks or albums--or even do <a href="http://en.wikipedia.org/wiki/Dynamic_range_compression#Common_uses">dynamicrange compression</a> when you want
background-music in a relatively noisy environment. And, on the subject
of volume-control: there's even a central volume-control--so that you can
turn the whole house's volume up or down, after you've got the individual
output-volumes set relative to each other.</p>

<p>We generally run <a href="http://gmpc.wikia.com/wiki/Gnome_Music_Player_Client">GMPC</a>
or <a href="http://sonata.berlios.de/">Sonata</a> on our desktop and laptop systems
(though I sometimes like <a href="http://mpd.wikia.com/wiki/Client:Ncmpc">ncmpc</a>
for its extremem keyboard-friendliness--and it's what I run on my
NanoNote..., but that's mostly another story), my wife runs the
<a href="http://code.google.com/p/remuco/">Remuco</a> JME app on her Nokia (Symbian)
phone, we use <a href="https://code.google.com/p/pmix/">PMix</a> on our Android
tablet, and our iFriends use something called
"<a href="http://www.katoemba.net/makesnosenseatall/mpod/">MPoD</a>",
when they're visiting. And there are <a href="http://mpd.wikia.com/wiki/Clients"><em>plenty</em> of other clients
available</a>.</p>

<h2>How does it all work?</h2>

<p>MPD runs on the machine hosting all of the audio-files, which is set-up
as an RTP <em>sender</em>--and, in my case, without any local speakers:
all of the `actual audio output' is done on `receiver' nodes
elsewhere on the network (my MPD server is a noisy old machine
that we keep down in the oubliette/basement).</p>

<p>In <code>/etc/mpd.conf</code>, MPD can be told to use PulseAudio for output with
a stanza like:</p>

<blockquote><pre><code>audio_output {
    type            "pulse"
    name            "MPD Stream"
    sink            "rtp"
    description     "what's playing on the stereo"
    mixer_type      "software"
}</code></pre></blockquote>

<p>... where "rtp" is the name of a sink defined in <code>/etc/pulse/default.pa</code> via:</p>

<blockquote><pre><code>load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100
load-module module-rtp-send source=rtp.monitor</code></pre></blockquote>

<p>That last line is the one that actually makes the RTP multicasting happen.</p>

<p>Now, keep all of the system clocks tightly synchronised so that PulseAudio
can actually determine the network latency (by comparing the source
timestamp on the RTP packets to the system time on the receiver), and
then it's just a matter of also running Pulseaudio on the other hosts--but
with those PulseAudio instances setup as <em>receivers</em>, which can be done
in the respective <code>/etc/pulseaudio/default.pa</code> files with...:</p>

<blockquote><pre><code>load-module module-rtp-recv</code></pre></blockquote>

<p>... or, if you have a GUI running on the receiver machine(s), you can
just toggle-on the `enable Multicast/RTP receiver' setting in <code>paprefs</code>.</p>

<h2>Caveats</h2>

<p>Actually, it can be a <em>little</em> more complicated, because:</p>

<ul>
<li><p>PulseAudio defaults to doing <a href="http://0pointer.de/blog/projects/pulse-glitch-free.html">something clever that <em>should</em> make
playback better</a>
 but which, as I understand it, <a href="https://wiki.archlinux.org/index.php/PulseAudio#Glitches.2C_skips_or_crackling">tends to trigger bugs in ALSA</a>; so any
 "load-module module-udev-detect" directives in default.pa may
 need to be modified to be "load-module module-udev-detect tsched=0"
 on each host.</p></li>
<li><p>There were major problems in PulseAudio's latency-matching code
 that <a href="http://cgit.freedesktop.org/pulseaudio/pulseaudio/log/?id=11dbe30bfae09235307115f413fb6172df04a895..72b90ea8ac53e23862284991a2ce355de250f585">weren't resolved until this past January</a>; so you want PulseAudio 0.9.23 or later,
 but that didn't actually exist yet when Debian 6.0 was released.
 I just grabbed <a href="http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/rtp/module-rtp-recv.c?id=72b90ea8ac53e23862284991a2ce355de250f585"><code>src/modules/rtp/module-rtp-recv.c</code> from git</a>
 and <a href="http://www.debian.org/doc/manuals/apt-howto/ch-sourcehandling.en.html">spliced it</a>
 into the version of PulseAudio that Debian already had
 (there were a couple of minor wrinkles, there, that I needed to
  smooth out--nothing hard, though). Figuring out that this module
 was just buggy and needed to be updated was probably the biggest
 problem that I ran into.</p></li>
<li><p>The <a href="http://en.wikipedia.org/wiki/ARM">ARM</a>-based plug-computers
 that I'm using have no
 <a href="http://en.wikipedia.org/wiki/Floating-point_unit">floating-point units</a>,
 which means that PulseAudio needs a little bit of
 <a href="http://lists.freedesktop.org/archives/pulseaudio-bugs/2011-July/004739.html">additional configuration</a>
 before it will work entirely right on them and produce sound reliably
 through the USB audio-adaptor.</p></li>
<li><p>If your RTP-transmitter machine has multiple network interfaces,
 make sure that you're <a href="http://net-tools.berlios.de/man/route.8.html#lbAF">routing the multicast packets out over the
 correct one</a>--I
 did run into that problem!</p></li>
<li><p>If you're using DHCP, the system may hiccough when the hosts
 go through DHCP cycles, so you'll want to find a way
 of setting your network up such that your audio-system
 doesn't decide to renew its DHCP leases in the middle of a party.</p></li>
</ul>

<h2>Addenda</h2>

<p>I initially installed <a href="http://ptpd.sourceforge.net/">PTPd</a> for
super-accurate clock-sync between hosts, but ntpd should actually
provide sufficient precision. You can use <a href="http://en.wikipedia.org/wiki/Precision_Time_Protocol">PTP</a>
to ensure that all of the nodes on a LAN are kept in <em>very</em> tight sync,
even if their collective idea of `what time is it?' isn't actually
<a href="http://en.wikipedia.org/wiki/Accuracy_and_precision"><em>accurate</em></a>.
If your LAN is connected to the Internet, then it's probably sufficient
to just use <a href="http://en.wikipedia.org/wiki/Network_Time_Protocol">NTP</a>--which
will allow your clocks to also be <em>accurate</em> in addition to being
reasonably <em>precise</em>.</p>

<p>I also installed <a href="http://packages.debian.org/search?keywords=rtkit">rtkit</a>,
which PulseAudio can use to get realtime scheduling; in Debian, I had to
get this from <a href="http://www.debian.org/releases/wheezy">Wheezy/testing</a>,
but it <a href="http://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html#s-default-version">installed fine</a> on 6.0/Squeeze.</p>

<p>Under GNOME on my normal PCs, PulseAudio starts automatically;
on the plug-computers, I had to find another way to make PulseAudio run
automatically, and the most sensible thing was to hook into Debian's
`ifupdown' system by adding `up' and `down' options to the definition
of the plug's ethernet interface in <code>/etc/network/interfaces</code>, such that
the complete definition of <code>eth0</code> looks like this:</p>

<blockquote><pre><code># The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
        up su pulse --login --shell /bin/sh \
                    --command 'pulseaudio --exit-idle-time=-1 --daemonize'
        down killall pulseaudio</code></pre></blockquote>

<p>The day after I got everything working, the hard disk in one of my
`speaker-wire emulator' nodes died....</p>

]]></description>
</item>

<item>
  <title>What have you tried?</title>
  <link>http://www.hackerposse.com/~rozzin/weblog/what-have-you-tried.html</link>
  <description><![CDATA[
<p>If you've regularly googled for technical stuff as part of your job
as a professional hacker over the past decade, you may have noticed
the (ever increasing, it seems) number of dumb questions on developer
forums--questions where people not only don't RTFM, but aren't even
<em>trying</em> to solve it themselves. A friend of mine found himself
wading through this when he came across Matt Gemmell's article,
`<a href="http://mattgemmell.com/2008/12/08/what-have-you-tried">What Have You Tried?</a>'.</p>

<p>It made both of us smile, but I wish it hadn't--I wish it wasn't so <em>right</em>....</p>

<p>I've been periodically trying to reconnect with the Python programming
community, over the past few years; I go back to the newsgroup/mailing-list...
and, every time, find that a greater and greater share of the traffic
is people just wanting someone else to do their homework for them.</p>

<p>Some of them, at least, are quite bluntly honest about it--writing things
like, "I don't want to learn how to program or how to write Python,
I just want to solve this problem". Some of them aren't. Neither group
is really the type I want to hang with, though.</p>

<p>So I find myself drifting further <em>away</em> from the Python community,
and thinking that maybe it's just not even a world I want to be part of
anymore--I seem to remember a time when most of the people there seemed
<em>bright</em> and <em>help-ful</em>, but now they're all so <em>dull</em> and <em>help-less</em>,
and most of the ones who have any <em>intent</em> seem to be set on just making
rude noises. And I wonder if maybe it's just that <em>I've</em> changed
since that time--if maybe I used to be more like the current crowd.</p>

<p>But I'll bet that the crowd has actually changed, too--and that it's
largely just the sort of change that comes as a side-effect of popularity.</p>

<p>Back in 2004, Paul Graham wrote
<a href="http://www.paulgraham.com/pypar.html">`The Python Paradox'</a>,
which starts out:</p>

<blockquote>
  <p>In a recent talk I said something that upset a lot of people: that
  you could get smarter programmers to work on a Python project than
  you could to work on a Java project.</p>
  
  <p>I didn't mean by this that Java programmers are dumb. I meant that
  Python programmers are smart. It's a lot of work to learn a new
  programming language. And people don't learn Python because it
  will get them a job; they learn it because they genuinely like to
  program and aren't satisfied with the languages they already know.</p>
  
  <p>Which makes them exactly the kind of programmers companies should
  want to hire. Hence what, for lack of a better name, I'll call the
  Python paradox: if a company chooses to write its software in a
  comparatively esoteric language, they'll be able to hire better
  programmers, because they'll attract only those who cared enough
  to learn it.</p>
</blockquote>

<p>Seven years later, <em>Python</em> programmers <em>are</em> dumb. What happened?
Well, now Python <em>is</em> something that <em>can</em> get you a job--it's actually
popular. And so is programming in general--I guess college-bound kids
finally got wind of how much some of us get paid, in this field
(or something--though I guess they somehow missed the parts about
things like 80-hour work-weeks).</p>

<p>I guess it just makes those of us who can actually
<a href="http://weblogs.asp.net/alex_papadimoulis/archive/2005/05/25/408925.aspx">think</a>
and <a href="http://www.codinghorror.com/blog/2006/07/separating-programming-sheep-from-non-programming-goats.html">learn</a>
and <a href="http://www.jwz.org/blog/2009/09/that-duct-tape-silliness/"><em>do stuff</em></a>
look better, though....</p>

]]></description>
</item>

<item>
  <title>Linux has won--without needing anyone to notice.</title>
  <link>http://www.hackerposse.com/~rozzin/weblog/linux-has-won-silently.html</link>
  <description><![CDATA[
<p>Someone in my local LUG remarked:</p>

<blockquote>
  <p>So, while I've been slaving away in the world of corporate IT,
  it appears Linux has quietly won the OS war. I just didn't notice.
  Linux may already be out-shipping Microsoft Windows.</p>
</blockquote>

<p>... noting that it's actually quite difficult, if not impossible, to
buy a TV that's not running Linux internally anymore.</p>

<p>Another member further remarked on the general prevalence of Linux
in the embedded market--wondering, quasi-ironically, if maybe
even his <em>microwave oven</em> might be Linux-based without him knowing.
It's actually not beyond the realm of believability--Electrolux
<em>does</em> actually have [a <em>fridge</em> that's Linux-based]
(http://www.enlightenment.org/?p=news/show&amp;l=en&amp;news_id=26).</p>

<p>Several years ago, I was at the movie-theatre down in Lowell, MA,
with a friend who had a thing for photo-booths, when I discovered
that the photo-booth there was running Red Hat Linux.</p>

<p>`Embedded Linux' was already pretty pervasive, even at that point--
having worked its way into a lot of types of devices that people
don't even expect to be `digital' inside, let alone be `computers':
photo-booths, A/V amplifiers and other stereo equipment, batteries,
telephones (well before Android), the telephone <em>network</em>....</p>

<p>Now it's also refrigerators, televisions, toys for small children, e-Books,
<a href="http://www.handlewithlinux.com/fastest-linux-on-the-road-electric-superbike">motorcycles</a>,
<a href="http://misadigital.com/">guitars</a>, personal audio-players, video games....</p>

<p>As Mark Weiser wrote in <a href="http://www.ubiq.com/hypertext/weiser/SciAmDraft3.html">`The computer for the 21st Century'</a>:</p>

<blockquote>
  <p>The most profound technologies are those that disappear.
  They weave themselves into the fabric of everyday life
  until they are indistinguishable from it.</p>
</blockquote>

<p>They're the things that happen <em>without anyone noticing that they
happened</em>--changes that become visible only in retrospective.</p>

<p>And it's by design, actually.</p>

<p>Part of what's going on here is that more and more `mundane' objects
are advancing technologically and becoming `smart'; and, when they do,
they use Linux--because Linux is the thing that's making that advance
possible in the first place. Develop your own thing from scratch?
Pay to license something more obscure, and get a smaller talent-pool?
Linux is a commodity. You're not supposed to notice when it gets used,
just like you're not supposed to notice when 5-volt circuits
(with connectors made by... what manufacturer?) get used.</p>

<p>At least, that's my perspective from the inside--that's why
<em>my</em> groups have been shipping Linux for the past decade.</p>

<p>The amazing thing is that Linux-uptake just seems to <em>keep accelerating</em>....</p>

]]></description>
</item>

<item>
  <title>Completely-unmaintained packages that YOU USE...</title>
  <link>http://www.hackerposse.com/~rozzin/weblog/unmaintained-packages-you-use.html</link>
  <description><![CDATA[
<p>On <a href="http://www.ubuntu.com/">Ubuntu</a>, you can get a list of packages
that are installed on your system but <em>completely unmaintained</em>
by running this command:</p>

<blockquote>
  <p><code>dpkg --get-selections  | grep '\Winstall' | cut -f1 |
  xargs apt-cache show |
  egrep '^Filename: pool/(universe|multiverse)/.*' |
  sed -re 's:.*/([^_]+)_(.*)_.*:\1:' | less -N</code></p>
</blockquote>

<p>Packages in this list have not had time allocated to them for
<a href="http://en.wikipedia.org/wiki/System_integration">integration</a>
or QA prior to release, and they
<a href="http://www.ubuntu.com/community/ubuntustory/components">do not receive regular security-updates or bug-fixes following
initial release</a>.</p>

<p>As one moves further off-centre from Ubuntu's primary target-audience,
the number of items in that list increases, and which items they are
becomes more unsettling.</p>

<p>For example: I prefer to use the official GNOME web-browser,
<a href="http://projects.gnome.org/epiphany/">Epiphany</a>--for reasons nicely
summarised on
<a href="http://blog.ibeentoubuntu.com/2009_11_01_archive.html">Daniel Bo's weblog</a>.
Ubuntu shipped <a href="http://changelogs.ubuntu.com/changelogs/pool/universe/e/epiphany-browser/epiphany-browser_2.28.0-4ubuntu1/changelog">no updates for Epiphany</a>
during the lifetime of Ubuntu 9.10 (Karmic Koala), despite there having been
<a href="http://packages.debian.org/changelogs/pool/main/e/epiphany-browser/epiphany-browser_2.30.2-1/changelog">several provided by Ubuntu's upstream community</a>--with
the first update making its way into Debian just 2 weeks after the
initial (random?) snapshot was made for Karmic. That's <em>no updates</em> for
the GNOME web-browser available through Ubuntu until the next release,
6 months later. If you stick with Ubuntu's Long Term Service (LTS)
releases, then you can expect to go <em>2 years</em> with no updates for this
or any other package in the `universe' or `multiverse' sections of
Ubuntu.</p>

<p>Having my web-browser, or anything else that faces the network, go
without security-updates should be unsettling enough; but there are
other items in my list that are even more unsettling: packages like
<code>gnutls-bin</code>, which is supposed to be a security tool. And there are
enough other `minorly-unsettling' items in my list that the sheer
number of them all together is itself unsettling.</p>

<p>A friend was surprised to find that the "OTR" plugin for Pidgin,
which he used to keep his IM conversations secure,
<a href="http://packages.ubuntu.com/search?keywords=pidgin-otr">is in <code>universe</code></a>--
which, again, means that he cannot expect security updates for it.
So much for his secure conversations.</p>

<p>How many items are in <em>your</em> list, and what are they?</p>

]]></description>
</item>

<item>
  <title>Love Bug(fix): libvisualid 0.2.1</title>
  <link>http://www.hackerposse.com/~rozzin/weblog/VisualIDs/libvisualid-0.2.1.html</link>
  <description><![CDATA[
<p>It's <a href="http://wikipedia.org/wiki/Valentine%27s_day">Valentine's Day</a>
and <a href="http://www.rozzin.com/VisualIDs"><code>libvisualid</code> 0.2.1 is out</a>,
to fix some bugs that managed to escape with
<a href="VisualIDs/libvisualid-0.2">version 0.2.0</a>;
changes include:</p>

<ul>
<li>Automatic complexity-limiting is actually enabled.</li>
<li>A divide-by-zero bug affecting the rendering of line-glyphs with
 exactly one `rib' sub-glyph has been fixed.</li>
<li>Under-reporting of the complexity added to Line-glyphs by multiple
 `ribs' has been fixed.</li>
<li>Two issues in the best-common-substring logic used to associate
 file-names with pre-existing VisualID-glyphs for other, related
 files have been resolved: memory-leaks have been fixed, and
 strings that were treated as circular are now treated correctly.</li>
<li>The VisualID Explorer now renders glyphs with a fixed 1:1
 aspect-ratio, scaled without distortion to fit the available
 drawing-area.</li>
</ul>

]]></description>
</item>

</channel>
</rss>
