Author Archives: Chris

Music to my ears

It all started when I realised I could connect my netbook to my hifi to play music, and then sit back on the sofa and control the netbook from my laptop using VNC. Wonderful! I’m lazy by nature and changing the CD is such a drag. I found I listened to so much more music this way, and really enjoyed it. So I began looking for a more elegant, and more importantly, better sounding solution. This is what I came up with…

Overview

This is going to be a very techy article, so if that’s not your thing, turn away now.

I’m using an Asus EeePC 701 that I picked up on ebay for £71 to play the music. It basically has Ubuntu installed, but tweaked to be as minimal as possible. Music is on the file server upstairs, mostly as FLAC files. The EeePC runs Music Player Daemon (MPD), a music server that can be remotely controlled across the network by a variety of clients. A very minimal GUI is loaded at startup with the Gnome Music Player Client (GMPC). Starting everything is as simple as pressing the power button—no logging in or starting things up. Also on the EeePC is Remuco, which allows remote control from my Nokia phone.

Rather than relying on the ropey internal sound card, the digital signal is taken from the USB port to a Cambridge Audio DacMagic upsampling DAC, and on to my existing Cambridge Audio Azur 340A amp.

The EeePC

EeePC with Gnome Music PlayerI chose the Asus EeePC 701 for a number of reasons. I have an EeePC 901 and I’ve been very pleased with it, so I trusted the pedigree. It has a solid state hard drive, so there is no clattering drive noise to interfere with listening. It’s small and fits easily on the shelf next to the hifi. And second hand ones come up regularly on ebay at a reasonable price.

It might have been a bit of mistake to be honest. I hit a couple of problems. One is that it seems to run hotter than the 901, so the fan comes in more, but to be fair it’s not really noticeable. More of an issue has been the wireless chipset – the Realtek RTL8187SE. Support for this under linux seems incomplete, and though it works fine with NetworkManager once a user is logged in, I couldn’t persuade it to come up at boot time. Consequently, I ended up investing in a Zyxel G-202 USB wireless adapter instead. I did manage to kludge the internal thing to work using NetworkManager, but that meant the network wasn’t started until late in the boot process, which delayed various other things. Switching to the well supported Zyxel adapter shaved 20s off the boot time, taking it down from 65s to 45s.

The DAC Magic

Cambridge Audio DAC MagicThe Cambridge Audio DAC Magic is a lovely piece of kit. It’s an upsampling DAC with more acronyms in it’s specification than you can shake a stick at. Even I’m not geeky enough to understand what half of them mean. But it sounds great, and what else matters? Well, the fact that it does what I need matters actually, which is to take USB input from a PC. And the fact that it seems to be fairly easy to set up a linux based machine to recognise it as a sound card.

Getting started

My starting point was to install Ubuntu Netbook Remix on the EeePC. A slimmer distro might have made sense, but I figured UNR has been tweaked for various netbooks and I might save a fair bit of messing about with hardware drivers if I started with it.

Having installed UNR I created a second user named ‘music’, as an ordinary desktop user. This will be the user who will automatically log in to the EeePC. I’ll keep my own account for administration.

I then used Synaptic Package manager to install mpd, gmpc, gmpc-plugins and remuco-mpd—the basis of the music system. I needed a couple of other packages too. nfs-common enables me to access the music stored on the fileserver upstairs; and mingetty will help me to automate some login tasks.

The aim was to have a system that can be turned on with nothing more than a touch of a button, and that boots fairly quickly, bringing up as little of the GUI as possible. Various suggestions were made to me about session files and using gdm, but I found it actually quite difficult to use gdm and not get a lot of extra desktop guff. So I gave up.

Instead, I disabled gdm altogether by moving its upstart file:

# mv /etc/init/gdm.conf /etc/init/gdm.conf.disabled

Now the machine will boot to a console login prompt. The next job is to get it to login. This is where mingetty comes in. Open /etc/init/tty1.conf and edit the ‘exec’ line to read

exec /sbin/mingetty --autologin music --noclear tty1

Now you should have a machine that will automatically login the user ‘music’. You can still login as another user by hitting Alt+F2 to bring up an alternative console (tty2). You can then start the full desktop GUI by typing

# startx

Bringing up the network

The simple way is to configure your wireless network in NetworkManager and then check the “Available to all users” box. NetworkManager won’t start a wireless network until a user logs in it seems, but a console login will do the trick. The trouble with this approach is it delays the start of the network, and I found that in order for things to work I had to be sure the network was up and the remote directory with all the music in mounted before starting MPD. So I looked for a way to start the network earlier.

As I mentioned, this proved problematic with the built in wireless card, and I had to resort to a USB wireless adapter. Having used ifconfig to establish that this was seen as wlan2, I edited /etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth1
#iface eth1 inet dhcp
auto wlan2
iface wlan2 inet dhcp
wireless-essid <yourssid>
wireless-key <yourhexkey>
wireless-mode managed
wireless-channel <yourchannel>

and bingo! The network comes up early in the boot process. Of course, this assumes WEP security on the wireless network. If you need WPA or something else you’ll have to search further…

The network share

Connecting to the network share should be as simple as putting the appropriate entry in /etc/fstab. Unfortunately, it wasn’t.

The problem seems to be that /etc/fstab is processed before the wireless network has finished coming up. It turned out to be fairly critical that things are done in the right order, and that one thing finishes before the next starts. Otherwise odd things happen.

  • Start the network
  • Mount the network share
  • Start MPD
  • Start remuco-mpd

So the entry in /etc/fstab is flagged ‘noauto’ and ‘user’. It is not mounted automatically at boot, but by a script (we’ll come to that) that runs once the network is up. In my case my fileserver is at 192.168.37.8 and it exports /home/shared via nfs. I’m going to mount this at /network/shared on the EeePC, so I have this in /etc/fstab

192.168.37.8:/home/shared    /network/shared  nfs   noauto,defaults,user,ro,bg   0  0

Setting up MPD

Configuration of MPD is done mainly by editing /etc/mpd.conf. The distribution includes sensible defaults for most things, and plenty of comments. You’ll need to set music_directory to the directory beneath which all your music is stored. Also check the value of bind_to_address. Do not set this to ‘localhost’ if you want to able to control the system remotely. I simply commented this line out, as the default is to bind to all available addresses.

Configuring MPD to output to the Cambridge Audio DAC magic proved to be a doddle. On plugging in the USB cable, the DAC magic was recognised by ALSA and assigned as card 1 (the onboard card gets slot 0). You can check which card has which slot with

aplay -l

All it takes to get MPD to output to the DAC Magic is this in the audio output section of /etc/mpd.conf:

audio_output {
 type        "alsa"
 name        "DAC Magic"
 device        "hw:1,0"
 mixer_device    "default"    # optional
 mixer_control    "PCM"        # optional
 mixer_index    "0"        # optional
}

The next thing to do is to disable MPD. I know, that sounds weird. It’s back to this problem of the order that things are done. By default MPD is configured to start automatically at boot time. The problem is, it gets rather unhappy if it is started when music_directory isn’t there yet. So we’ll stop it from starting at boot, and start it later from a script.

sudo update-rc.d mpd disable

Starting things up

Now it’s time to consider how to start everything up in the right order. This is the ugliest bit of the whole set up. Because my music is on a fileserver upstairs in the office I need the network to be up before I can really do much else. Fortunately, Ubuntu provides a way to run scripts in response to the network coming up—simply place a script in /etc/network/if-up.d

This is the script I used. It is quite specific to my set up, so you’ll need to go through and change stuff. Basically, it runs only when the wireless network comes up and then uses a series of while loops to wait until things are ready before moving to the next stage.

#!/bin/sh

# if the interface coming up isn't our wireless card,
# bail out (otherwise the script runs when the loopback
# interface comes up, which isn't useful!
if [ "$IFACE" != "wlan2" ];
then
 exit 0
fi

# wait until we're sure the network is up
NET=$( ( ifconfig | grep 192.168.37 ) 2>/dev/null )
echo -n "Waiting for network ."
while [ "x$NET" = "x" ];
do
 sleep 1
 echo -n "."
 NET=$( ( ifconfig | grep 192.168.37 ) 2>/dev/null )
done

echo ""

# check if the music directory is available yet. If not mount
# the network share
if  [ ! -d /network/shared/HiFiMusic ]
then
 echo "Mounting /network/shared"
 mount /network/shared
fi

# Wait for the music directory to appear
echo -n "Waiting for music directory to be available ."
while [ ! -d /network/shared/HiFiMusic ];
do
 sleep 1
 echo -n  "."
done
echo ""

# start MPD
/etc/init.d/mpd start

The Graphical User Interface

For the shiny user interface I installed GMPC – the Gnome Music Player Controller. For the purpose of starting a single program, maximised, the windows manager distributed wit Ubuntu Netbook Remix (metacity) is not ideal. So I used Matchbox, a windows manager designed for embedded devices. Start by installing it:

sudo apt-get install matchbox-window-manager

Next we create an .xinitrc script for our music user. Create /home/music/.xinitrc and add:

#!/usr/bin/env bash
/usr/bin/matchbox-window-manager -use_titlebar no &
/usr/bin/gmpc

Now we should be in the position where running ‘startx’ as the music user will not launch the whole Ubuntu desktop, but just GMPC, maximised and with no title bar.

The loose ends

All that is left to do now is to get the GUI to start automatically, and to start remuco.  Remuco is another fussy program—it won’t start if MPD is not already running. These final points are covered by editing music’s .bashrc file, /home/music/.bashrc. We add to the end of this file a while loop to ensure that MPD is running, a call to remuco-mpd and finally, run startx:

echo -n "Waiting for MPD to start *"
while [ ! -f /var/run/mpd/pid 2>/dev/null ];
do
 sleep 1
 echo -n "*"
done

echo ""
sleep 2
/usr/bin/remuco-mpd &
startx

OK, that should be it. Restart the EeePC and it should load everything and start the GUI music player.

Remote control from another PC

The beauty of MPD is that it can be controlled from other PCs on the network. There is a wide range of client software available. I’ve found GMPC, combined with some of the big selection of plugins, suits my needs best. Ario is another good client, as is Minion, an add on for Firefox. The MPD website has a whole list of clients.

Remote control from a phone

Controlling with a Nokia E63 and RemucoThis bit’s great! Using Remuco the music player can even be controlled from a mobile phone. Remuco is a little different to other MPD clients. It doesn’t use MPD’s interface directly, but relies on a helper application, remuco-mpd, being installed on the server (the EeePC in this case). But it works well, and is really useful as my phone is always on and to hand, whereas, believe it or not, I do occasionally turn my laptop off.

The music

There’s not much point in having a quality DAC and amp and feeding poor quality music files to it. Much of my CD collection I ripped out a few years for the purpose of playing it on an in-car CD player that played MP3s. It was done in a hurry just before a journey to the Hebrides. Tinny speakers and a noisy old diesel car meant it didn’t really matter if the quality was less than perfect, so I used bitrates of between 128 and 160kbps.

On my new set up this was really noticeable, so I set about re-ripping the whole lot. For the majority I used FLAC, a lossless compression format. Towards the end I got a bit nervous about how much disk space this was using, so some of the stuff I listen to less frequently was ripped to variable bit rate MP3 using lame’s ‘extreme’ preset setting, which produces files with an average bit rate in the 200-250kpbs range. All of this was done with Sound Juicer. For the ‘extreme’ setting I had to create a new preset, using this GStreamer pipeline:

audio/x-raw-int,rate=44100,channels=2 ! lame name=enc preset=extreme ! xingmux ! id3v2mux

So how does it sound?

Great! I’ve done some entirely subjective listening tests comparing FLAC files played over this system with the original CDs played on a Cambridge Audio Azur 340C CD player. If anything, the FLAC sounds better—a touch clearer, brighter and more defined. This isn’t surprising—the 340C is quite old now and the DAC in the DAC Magic is superior to that in the 340C. Since FLAC is lossless, the input hitting the DAC Magic should be a bit perfect copy of the CD.

I’m certainly very pleased with it, and it sure beats having to change the CD every 45minutes!

The Doggy Paddle

I’ve had a cracking day today. I did the Doggy Paddle—a 19 mile kayak trip from Leamington Spa to Stratford upon Avon. It’s a gorgeous journey through Warwickshire countryside, with some of the finest views you can get of Warwick Castle and Charlcotte Park. And it’s a trip you can only do on one day each year.

Sophie kayaks past Warwick CastleLike so many of the rivers of England, much of this stretch of the Avon is privately owned. There’s no right to kayak along it. Unlike Scotland, in England we’re denied the right to enjoy our countryside and our heritage by quietly floating along the river. My journey today was made possible because the local canoe club negotiate with land owners to allow this annual fund raising event to take place.

It was wonderful to be able to put all the bits of river together. Some of it I have kayaked before, much of the rest I have seen on walks, or on visits to the Castle or Charlcote Park. Some of it was new to me altogether—I discovered a bridge I didn’t know existed. Highlights of the day include seeing the 16th century Charlcotte House emerging from behind the trees, and shooting my first weir. And I didn’t fall in! Check out Sophie’s photos of the day.

So why is it called the Doggy Paddle? Because the event raises money for the Guide Dogs for the Blind Association. Guide Dogs are a charity I’m very happy to support because I have seen what a difference they can make to someone’s life. When he was about 8 (I’m sure my mum will phone and correct me about that) my brother was diagnosed with Retinitis pigmentosa, a degenerative eye disease that causes tunnel vision, night blindness and eventually blindness.

Now in his forties, he still has some sight but it is extremely limited. A few years ago he decided to apply for a guide dog. The GDBA eventually matched him with a beautiful black Labrador named Yarran. It’s hard to describe what a difference Yarran has made to my brother’s quality of life. Loosing your sight takes away basic freedoms which we all take for granted. Walking down the road becomes a daunting ordeal. A guide dog can never give someone their sight back, but it can restore some of those freedoms. It brings independence, it brings the ability to get around, to go to the pub on a Friday evening or go for a walk on Sunday afternoon. Guide dogs make a huge difference to people with limited sight in a very basic way.

Training and looking after a guide dog costs around £50,000 through its life. The GDBA is funded entirely by charitable donations so fund raising events like the Doggy Paddle are vital to them. If you’d like to help them continue to provide this amazing, life changing service I’m still collecting sponsorship for my day’s adventure—just click the button below…

Sponsor me on Virgin Money Giving

Postcodes freed

On 1 April the Ordnance Survey finally opened access to data relating to the location of Britain’s 1.7 million postcodes. It’s long been a gripe of many that these data were not publicly available, and various projects have attempted to collate openly available postcode data, such as Free The Postcode and http://www.npemap.org.uk/.

A while ago I wrote a PHP class for manipulating postcodes, and in particular for calculating the distance between two postcodes. I wrote it for use in a utility to help people find their nearest reputable tree surgeon by searching on their postcode, which is how it came to be named FindMyNearest. Until now I’ve relied on data gleaned from open sources, often incomplete and of unknown accuracy. I used data only down to postcode district level (eg SW1A, CV32) and stored that in a delimited text file. With the release of Code Point Open I now have the opportunity to use full postcodes of reliable provenance.

The problem was that there are about 1.7 million postcodes in Great Britain. It was fairly clear that code which used a text file for storage and slurped the entire contents into memory wasn’t going to cope well with this. So I went back to the drawing board.

I’ve rewritten FindMyNearest to provide a kind of data abstraction layer. It now supports ‘drivers’ for different types of data store. The text file option is still there, but I added the ability to use a MySQL server to store the data.

Then I came across UK Postcodes, a system based on Code Point Open put together by Pezholio. UK Postcodes provides a simple API for fetching a range of data about a postcode in XML, JSON, CSV or RDF formats. I figured it wouldn’t be too hard to add a driver that utilised this, so I did just that.

And I finally got round to working out how to use Git so I’ve just put FindMyNearest on Git-hub

Links

Mush!

Or rather, since the dogs we were working with only spoke Finnish, Menan!

Yes, we’ve been mushing again. This time I managed to avoid getting ill as soon as I got home, which means I don’t have the time for a repeat of the Gone Mushing blog which chronicled our trip two years ago. There are plenty of photos to browse through though, and such an adventure needs a few words at least.

Arctic winterI’m in love with the Arctic winter, its harsh beauty, its quiet, its challenge. And I doubt there can be a better way to experience the wildness of the North than by gliding across the snow hauled by a team of enthusiastic dogs. After that first trip in 2008 I knew I had to return.

This trip was very different, but every bit as magical. We couldn’t get in at the place we went to before, so ended up going to Finn-Jann. Unlike Harriniva, Finn-Jann is a tiny, family run kennels catering for only one or two groups at a time. It’s a very friendly place offering fantastic hospitality, and a great sauna and outside hot tub. We spent two nights out at wilderness cabins, but the rest of the time was based at Finn-Jann. One of the consequences of this (rather than the five nights out trip we did before) was that I felt I didn’t get to see such a change in the landscape as we covered ground.

There were advantages too, though. Our guide, Jussi, was able to adjust the dog teams as we became more confident. One day when we were only out for the afternoon an extra dog was added to each team—youngsters yet to learn the secret of going all day, but giving their all for a few hours. We really moved that day! We took teams of six dogs out on our final day too, but with the extra dog being a more experienced dog with the stamina for an all day run.

The sledding was altogether more challenging. The trails are used less anyway, which did mean that Jussi had to go ahead in a snow mobile to open them. And added to that the beginning of the week was remarkably mild and snowing heavily. The going on the soft snow was very hard, and there’s a nasty twist to heavy snow…

Last time, I wrote about Wobbly Wednesday, saying

In any long process there always seems to be a point in the middle where things go wrong. And for some reason it always seems to happen on a Wednesday

Well true to form, Wednesday did not go according to plan. We’d spent the night out at a lakeside wilderness cabin, and the day’s sledding began by heading out across the frozen lake. It wasn’t long before we hit a patch where there was a lot of water on top of the ice, between the ice and the snow. Quite reasonably really, huskies are not that keen on getting their feet wet. Dog sleddingThere was a bit of hesitation, a bit of progress, and then as my two lead dogs decided to turn round and run back into the team, complete chaos; a tangled mess of lines and a lot of very cold water. For a while I managed to keep my feet on top of snow, but inevitably as I and the young woman on work experience helping Jussi out thrashed around trying to bring some order to the chaos we both discovered that calf height water proof boots are no defence against knee deep freezing water. I had discovered something I have in common with huskies—I’m not keen on getting my feet wet either.

Even when we’d sorted the lines out and managed to get moving again, the going was really tough. The snow was very soft and several times crossing the lake Jussi’s snowmobile got stuck. The first few kilometres of that Wednesday took two hours; we were way behind schedule. It was a relief to get off the lake and change my soaking socks. Even more so to get to a kota for lunch and dry my boot liners by the fire.

In case you’re wondering what this has to do with heavy snow, the snow is the reason there was water on the lake. The weight of a fresh fall of snow pushes the ice down into the water below and the water comes up any way it can—often through holes made by fishermen.

All in all, although it was milder and the landscape perhaps not as wild, this year’s trip was certainly not short of challenge. I feel I built more of a relationship with my dogs and that we really did work together as a team and look after each other. Gliding through an Arctic forest on a sled is an experience that is hard to describe—you really should give it a try.

Links

Sloe gin

We bottled last autumn’s sloe gin today. I’m sitting with a glass now and it’s absolutely delicious. The recipe has kind of evolved as we’ve sampled it along the way and added extra bits here and there, but I think we’ve kept a note of all the additions. Here’s what I reckon went into it.

Sloe ginMost recipes for sloe gin involve adding a few sloes and a bit of sugar to half a bottle of gin. I can’t be doing with such tinkering. Our sloe gin was made in a 10l nappy bucket specially bought from Mothercare.

Ingredients

  • 3.5kg sloes
  • 7 × 700ml bottles of cheap gin
  • 1.5kg sugar

Method

Pick your sloes in October or November. Rinse them and cut a slit in each one. Add to a large bucket with lid.

Poor on 6 bottles of gin. Add the sugar. You may want to hold back some sugar and test as you go—adding more later is easy enough.

Agitate or stir daily for a couple of weeks, then weekly after that. At first not all the sugar will dissolve, but it will after a week or two.

Leave until about February. Then strain through muslin into another large container. Add the seventh bottle of gin to the sloes, rinse them well with it and strain into the rest.

Bottle and enjoy!

Avatar—more than just a spectacle?

Let’s start off by saying I really enjoyed Avatar—so much so that I trekked into Birmingham to see it a second time on the enormous screen at the Imax—as high as a five storey building. It’s the first time I’ve ever seen the same film twice at a cinema, so it clearly did something for me.

The landscape the film creates is extraordinary and stunning and the special effects just awesome. It was well worth the effort of going into Birmingham to see it on a really big screen. But beyond the beautiful computer generated imagery, is it a good film? Continue reading

Welcome…

…to my new blog. But why a new blog? I already have a blog about my garden, an old blog about my husky safari in Lapland, and an entire website about trees and I hardly ever get around to updating any of them. So what’s the point of another?

Well just occasionally a thought pops into my head that doesn’t fit into the other blogs. Perhaps something I need to make a note of, something that others might be interested too. Like yesterday I made marmalade to a recipe I’ve developed over the years and have written on several scraps of paper. And that, really, is what inspired yet another blog. So the first, well second after this, post will probably be a recipe for marmalade.