Blog

Raspberry Pi Whole Home Audio: Playing Music

Itā€™s very rare that I tweet teasers to my blog post, but
last weekend I was so excited to be making progress on my Raspberry Pi Whole
Home Audio
project that I told the world Iā€™d be publishing this one on
Thursday.

Here we are on Friday morning. Thereā€™s doubtless a lesson in
here for me about making promises I canā€™t keep, but Iā€™m hoping youā€™ll forgive
me when you read about what Iā€™ve done.

If youā€™ve been following my #RPiWHA Project
hashtag on this blog then youā€™ll know that when we left off last time I had
three Raspberry Pis networked together with synchronized clocks, and one of
them had access to the internet and the music library I keep on my home server.
Thatā€™s important, but not especially exciting. Today weā€™re going to move in a
more exciting direction, though.

Today weā€™re going to put Pis #2 and #3 aside, but weā€™re
going to get Pi #1 playing music!

Specifying and Testing the Piā€™s Audio Output

The Raspberry Pi has two options for audio output. It has a
3.5mm analog output, and digital output through its HDMI port. It decides which
output to use automatically ā€“ if you have a HDMI monitor plugged in then the Pi
will detect this and assume you want to use HDMI for audio too.

Thatā€™s not the situation for me (my Pi is ā€œheadlessā€ and
doesnā€™t have a display connected at all), and audio comes out of the 3.5mm
output automatically ā€“ which is what I want. If you need to specify, you can
run:

sudo amixer cset numid=3 1

The digit 1 at the
end means the Pi should use the analog audio output. Putting 0 there instead would mean auto-detect
(the default) and putting 2 would
mean digital output over HDMI.

Plug in some headphones or speakers and run:

aplay /usr/share/sounds/alsa/Front_Center.wav

You should hear a voice saying ā€œfront centre.ā€

Install Mopidy

Weā€™re going to install music playing software called mopidy.
It provides a web-based interface so you can control your music, or there are
controller apps available in your app-marketplace of choice. Mopidyā€™s website
takes you through the
install process in detail
, but Iā€™m going to summarize the commands here:

wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/mopidy.list
sudo apt-get update
sudo apt-get install mopidy python-setuptools

Done! We now have a basic install of mopidy, and the especially
astute amongst you will have noticed that weā€™ve also installed a package called
python-setuptools. Mopidy is written
in the python programming language, and the latter package is going to help us
with installing and setting up some mopidy extensions in an automated way. The
first thing weā€™re going to do is install something called pip, which is a tool for installing python packages:

sudo easy_install pip

Now that we have that, weā€™re going to in turn use pip to
install some mopidy extensions:

sudo pip install Mopidy-MusicBox-Webclient
sudo pip install Mopidy-WebSettings

With those commands weā€™ve added a web-based interface to our
player so we can control it from a browser on another computer or mobile
device.

Setting Up Mopidy

Weā€™re almost ready to start mopidy and try things out, but
there is a little bit of initial setup to be done first. Edit the file ~/.config/mopidy/mopidy.conf. In the http section, change the following line
so that the web interface becomes accessible to any device on your network:

hostname = ::

In the local
section, tell mopidy where it should find your music library. In my case:

media_dir = /mnt/music

Save the file and exit. The next step is to tell mopidy to
scan your music folder:

mopidy local scan

If, like me, you have a large music collection stored on a
network share, be prepared for this to take a very long time. I started it
running before I went to bed, and it eventually completed the process about 45
minutes after I got up the following morning.

When itā€™s done though, weā€™re ready! Run mopidy:

mopidy

Itā€™ll take a little while to fully start up, but when you
see the line

INFO     HTTP server running at [::]:6680

that means weā€™re good to go. Open the browser on your
computer or mobile device and point it to
http://192.168.1.71:6680/musicbox_webclient (replace 192.168.1.71 with the IP
address of your Pi as appropriate). Go to Browse, Local Media, and select a
song!

If all is well the music will be playing through the
headphones or speakers attached to the Pi, and weā€™re all done until the next
installment ā€“ rerouting the audio from Pi #1 and streaming it, synchronized, to
Pis #2 and #3 instead.

Enjoy!

Blog

Permission to Lead

At the office I so rarely visit I have a quote that Iā€™ve
printed and pinned to the wall. It comes from Rear Admiral Grace Hopper, who was a
U.S. Naval officer and an early computer programmer (she developed the first
compiler for turning source code into object code).

In a couple of my recent
posts
Iā€™ve made mention of a cultural evolution thatā€™s underway in my workplace. Itā€™s
not a revolution ā€“ itā€™s us collectively choosing to be much more deliberate
about using the values we already hold to better deliver benefit to our
customers. As a part of that weā€™ve defined ten core values, or mantras, or
whatever you want to call them. I donā€™t know whether or not my employer would
want me to reveal them in a public forum like this. Probably not yet, at least,
given that the evolution is in its infancy: weā€™re still in the process of socialising
them internally and defining what they mean to each of us individually, to our
workgroups and teams, and so on. In lieu of the ones from my organization, hereā€™s
an example of a similar-in-spirit core value from
another company
(Zappos.com):

  • Do more with less

Today one of my colleagues and I were talking about our ten
and poking some gentle fun at them. We were coming up with a handful of jokey
possible additions:

  • Try turning it off and back on
  • ā€œThatā€™s what she saidā€

Anyway, I said that ā€œitā€™s easier to ask forgiveness than it
is to get permissionā€ should be added to our list. I was joking. But should I
have been?

I like Grace Hopperā€™s quote so much because, on the face of
it, itā€™s about rebelliousness and lack of respect for authority. Thatā€™s
typically someoneā€™s immediate takeaway when they first read it, and those are
qualities I like to pretend I have. Except I donā€™t, really ā€“ I pretty much do
what Iā€™m told.

Itā€™s been a good while since I printed that and first pinned
it to the wall of my cube, though. Iā€™ve gained some seniority in that time, and
as I was thinking about this today it occurred to me that nobody really tells
me what to do anymore. My leaders set direction, provide clarity around whatā€™s
important (and why) where necessary, provide guidance where I need it, and then
they trust me to do whatever it is that I do.

Dig just very slightly beyond the surface of Graceā€™s quote,
and this is, Iā€™m sure, exactly what she was talking about. Grace was, after
all, a senior military officer: I highly doubt she was advocating for a lack of
respect for authority. What sheā€™s talking about is ownership, and
accountability. Sheā€™s saying that if you donā€™t have the necessary autonomy to
demonstrate those qualities then thatā€™s a problem so serious that you should be
taking immediate action. If thereā€™s red tape or dumb business rules that are a
barrier to doing what you know to be the right thing then you absolutely need
to be finding a way through it, and sooner rather than later. I think thatā€™s
something worthy of inclusion in any organizationā€™s core values.

Thinking about all this also got me thinking back to how the
quote became words that I choose to live by in the first place. A couple of years
ago I worked at my companyā€™s call centre, on a team responsible for operations
and process improvement initiatives. I used to provide coaching to a handful of
junior teammates. From time to time we would identify an opportunity for
improvement in one of the ancillary, supporting business processes, but being a
process on the edge of the core business weā€™d sometimes struggle to find
someone from the key leadership to identify as owning the process and provide
sponsorship for improvement. Iā€™d always provide the same wisdom: ā€œIf thereā€™s
one thing Iā€™ve noticed about where we work,ā€ Iā€™d say, ā€œitā€™s that if you act
like youā€™re in charge of something then youā€™ll very quickly find that you are.ā€

I think at the time I thought I was joking about that too,
and that little running joke is what led me to first put Graceā€™s quote up on
the wall. Even if I did think it was a bit of a joke though I did endeavour to embody
those words, and with the benefit of reflection it now seems as though Iā€™ve advanced
my career since then in part off the back of simply acting like Iā€™m in charge
of stuff. Interesting.

Really though, this shouldnā€™t be surprising. My vocabulary
has become more sophisticated in that time too: I now see more clearly that ā€œacting
like Iā€™m in charge of stuffā€ is just a slightly tongue-in-cheek synonym for our
theme of ownership and accountability.

Once upon a time I used to wonder to myself why merely
acting like I was in charge of stuff so often proved to be such a powerful tool
in my toolbox. When you frame it in those more sophisticated terms the answer
is clear. The reason it worked so well at my workplace is because we have a
culture that recognizes, values and rewards leadership attributes like these no matter the level of the employee they come from.
The question I should have been asking is why wasnā€™t it like that at previous
companies Iā€™ve worked for?

Thankfully, the answer to that one doesnā€™t matter to me
anymore.

Shrapnel

Late Night Links – Sunday February 8th, 2015

It’s late night links time again, folks!

And that’s it! We’re all done for another week. See you next time, folks.

Blog

Social Networking at the Office

In mid-January Facebook hit the headlines with (and receivedĀ decidedly mixed reviews on) the announcement of their ā€œFacebook at Workā€ offering,
which is essentially a walled-garden version of Facebook with access restricted
to those in your company. Aside from that important distinction the list of
features seems pretty much on a par with the larger Facebook we all know.

With this product offering Facebook joins an enterprise
social network marketplace that already contains some big names: Microsoft,
IBM, Cisco and SAP amongst them.

I can see the benefits of these platforms in terms of
collaboration, messaging, and the like ā€“ but Iā€™m certainly glad that my
responsibilities donā€™t include the realization of those benefits for my
company. The scope of the behaviour change required to make the most of those
tools falls into the category of ā€œculture shiftā€ in my mind, and that stuff is simply
not where my expertise lies ā€“ itā€™s a task that goes way beyond technology and
business process folks like I.

image

Where I work, weā€™re now on our second enterprise social
network. Weirdly, the first one hasnā€™t actually gone away ā€“ everyone has simply
stopped talking about it (and we all stopped using it long ago). The
implementation of the first one ā€“ I feel ā€“ was probably driven by technology
folks. I say that because from a technical perspective it works great, but
nobody ever told me what it was for. Apparently Iā€™m not alone in my confusion,
because it never really saw any significant usage.

Things are looking a little better for the new one. For one,
itā€™s integrated into our enterprise learning environment. At first that seemed
weird to me, but now that I think about it that makes perfect sense: learning
and development in the modern enterprise is increasingly something you do at
your own pace (to a certain extent), in your own office with the door closed
and headphones on. Itā€™s crying out for something to bring back some of the
social aspects that are lost now that technology has begun to make
classroom-based training sessions a thing of the past, and I hope our training
teams pick up this ball and run with it. Additionally, thereā€™s a movement
underway to build on our corporate culture and do a better job of leveraging it
for the benefit of our customers. Open, social communication that transcends
our geography is an important part of that cultural evolution too. The time is
right, then, for a platform to make this happen.

Nevertheless, people were burned by the failure of our
previous platform to gain traction, and thereā€™s a healthy amount of skepticism
out there. Again, nobody has really told me what the new platform is for or
given me examples of how I could use it to my benefit.

A quick conversation with my boss about this last week
brought me to an important realization. Why am I waiting around for someone to
tell me what this platform is for? Iā€™ll decide what itā€™s for! Iā€™m even starting
to think the lack of guidance and instruction might be a deliberate choice made
in the interests of organic growth and buy-in fuelled by self-realization
(although, frankly, I still think itā€™s the wrong choice if thatā€™s the case).

I plan to encourage my team to shift some of our non-time
sensitive group communication out of Outlook and into the social space, and I
sincerely hope it catches on. I think that would be a good starting point for
us, and as I said at the top, I really do see the benefits of a platform like
this. Iā€™m putting my own skepticism firmly aside in the interests of trying to
steer my group toward the realization of those benefits that this platform
could represent. Weā€™ll see how it goes!

Hopefully I wonā€™t be around to see the
introduction of a third enterprise social network. I wonā€™t be so generous if I
am.

Blog

Browse Anonymously with a DIY Raspberry Pi VPN/TOR Router

So, after last week’s post about preparing my Raspberry Pis for my whole home audio project, I had three Pis that should have been set up properly, but weren’t working very well – and the culprit was the USB WiFi dongles I was using.

Happily a stumbled upon the article linked above, and it solved the issues I was having!

Surf the Internet securely with your very own portable WiFi VPN/TOR router. You can configure a Raspberry Pi with Linux and some extra software to connect to a VPN server of your choice.

I didn’t follow all the steps because they’re doing something different to me, but there is some commonality and, crucially, the article folks are using WiFi adapters with the same chipset that mine have. Step four shows you how to download and compile a version of hostapd that’s built especially for them and works well. I’ve updated my previous post with these steps.

Now that I have networking all set up I’ve taken a couple of extra steps:

  • I set up passwordless ssh between the three Pis. This isn’t required for my solution per se, it just makes things easier.
  • I used sshfs on pi #1 to connect it to my existing home server, and mount the folder that holds all my music.

I’m excited to move on to next steps! The prep work was necessary, but it didn’t make for an especially interesting blog post because it’s all a bit dry.

Keep following my #RPiWHA Hashtag! The next installment will be more interesting, I promise. We’re going to get some actual music playing!

Browse Anonymously with a DIY Raspberry Pi VPN/TOR Router

Shrapnel

Late Night Links – Sunday February 1st, 2015

Look at that, we’re already into February. Where does the time go, etc, etc? It’s business as usual here at late night links, of course, so let’s get on with it.

And we’re done for another week! Until next Sunday, then.