Uncategorized

Airplay with Raspberry Pi

I bought a Raspberry Pi this week. For those who don’t know this is a tiny ARM-based computer, the size of a credit card, which is supplied as a board without case, power supply or mass storage, for £30 (delivered). It’s been in the media and is being described as a universally affordable spiritual successor to the popular 1980s BBC Micro, as it has been designed with the purpose of teaching school kids how to program computers in mind.

It ships with 256Mb of RAM, an SD card slot, two USB ports, an ethernet port and an HDMI port. It’s powered via micro-USB and so will work with any micro-USB cable (and therefore many phone chargers). You then have to add a SD card for mass storage, onto which the operating system is installed. You then also need to connect it to an HDMI display and plug in a USB keyboard. You can easily spend as much as the original purchase price again on accessories, but that still doesn’t make it expensive.

Raspberry Pi running RISC OS 5

The primary intention of its manufacturers is for it to run a special Linux distribution called Raspbian, which is based on Debian, but it is by no means limited to this. In theory it can run anything that’s compiled for the ARM architecture, although in practise this is different. Already a group is working on a port of Android, an obvious choice, since this operating system is designed for ARM-based smartphones and tablets. Someone has even made a RISC OS 5 distribution available (RISC OS 5 is the older fork of RISC OS which was open-sourced, RISC OS 6 remains a commercial product and is not available in the same way). This gave me a few hours of delightful nostalgia as I lived and breathed RISC OS for 5 years back in the early 1990s. I’m hoping I’m going to be able to use it to recover some of my old files and convert them to PDF.

But this isn’t the real reason why I’ve bought my Raspberry Pi. Nor have I bought it, as many will, just to dick about with it. Unlike some others I don’t have any grand delusions that it will replace either my desktop computer or my home server, because it’s frankly not up to either task. Its low cost and the fact that you can run it off a USB port means that it’s actually rather slow, but that’s fine, it’s not designed as nor was it ever meant to be a fast computer. But it is small, cheap and perfect for what I want to use it for.

Alternative Airplay device

Airplay is the system through which Apple devices can play music through remote speakers connected to devices on the local network. These can be Apple TVs or an Airport Express. The Apple TV represents great value at £99, but the Airport Express is less so at £80, which is an increase on the previous price since they brought out the new model. Most people already have a wireless network and so £80 just to connect your stereo to your network is a little steep if you don’t need the wireless features of an Airport Express.

Here’s how the budget stacks up: Raspberry Pi is £29.95 delivered from Farnell. On top of that you’ll need an SD card (£3.38 delivered from Play.com), a case (various options on eBay, I found one for £4.23 delivered), and if you don’t have a spare already then a micro-USB charge (£2.40 delivered from Play.com). This all comes to £40.00 delivered, exactly half the cost of an Airport Express.

You will also need an audio cable and an ethernet cable but I’m not including these in the budget since neither is not included with an Airport Express. What I would point out, however, is that the Raspberry Pi solution is not a wireless solution without the addition of a USB wireless dongle, themselves no more than a fiver from eBay.

Instructions

  1. Install Raspbian. You can do this using one of the pre-built images if you want, but if you’re capable I recommend that you install it using the network installer so you can control what goes on and it uses as little space as possible (you will however find this method much slower). You’ll need at least a 2Gb SD card for either method. I tried to shoehorn an install on a 1Gb card by removing the swap partition, but it didn’t boot. You need only the default options if using the network installer, no extras required.
  2. I recommend that you update the firmware and the operating system (using aptitude) at this point. There have been some recent improvements to the firmware which bring performance increases and better wireless support.
  3. Log in as root and run the following commands:

aptitude update
aptitude upgrade
aptitude install sudo ntp build-essential pkg-config alsa-utils git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils wireless-tools wpasupplicant unzip wget
mkdir /root/build
cd /root/build
git clone https://github.com/albertz/shairport.git shairport
cd shairport
make
make install
cp shairport.init.sample /etc/init.d/shairport
cd /etc/init.d
chmod a+x shairport
update-rc.d shairport defaults

  1. Add these lines to /etc/rc.local. The second line forces the audio through the 3.5mm jack rather than the HDMI port. If for some reason you require the latter then omit the second line.
modprobe snd_bcm2835
amixer cset numid=3 1
  1. Change this line in /etc/init.d/shairport, starting DAEMON_ARGS, so that it reads the following (you can change “Raspberry-Pi” to a string of your choice):
DAEMON_ARGS="-w $PIDFILE -a Raspberry-Pi"

Reboot, and you should now see a new entry in your Airplay menu on your device. At this point my SD card was using 783Mb on its root partition. I’ve made an image of this with a view to making it available for download, but even compressed it came out at 658Mb and I pay for my bandwidth by the Gb, so I won’t be uploading it, not when the instructions are so easy.

I would note that if you are geeky enough to achieve this then think twice before building them for your friends in order to save them a few quid. If you build and supply it you will have to support it, and you won’t have the option of sending them to the Apple Store should it go wrong. I speak as a reluctant Apple help desk for many of my friends and family; certainly I will not be making any of these little rods for my own back for anyone who can’t do it themselves :)

Portable wireless boombox

Despite this little triumph I actually don’t require an Airplay device at the moment. I have two already and no requirement for a third, so while this is useful it’s not especially useful for me as a home device at this time. What I want to do is take this project further and build a portable wireless boombox.

This would be a self-contained system which doesn’t depend on anything other than a 12 volt power source (so, car battery, boat, caravan, solar panels, mains adaptor or a collection of D-cell batteries). It would provide its own wireless network to which users can connect their Airplay devices and then use wirelessly. It would contain a small power amplifier and a pair of speakers. I’ve found a power amplifier that even has a USB port from which I can power the Raspberry Pi, saving me having to worry about a step-down from 12 volts to 5 volts.

Not intended for connection to an existing wireless infrastructure this would mean that it could be used anywhere, as long as there’s a 12 volt power source. Great for camping, barbecues, boats, festivals or simply down at the bottom of the garden. I’ve identified the parts that I will need (and indeed ordered most of them), but my biggest challenge still remains and that is what sort of box to build to house them and how to manufacture it. I’ve a feeling that my prototype won’t be particularly pretty, if entirely functional.

I’ll keep you posted on this project as I make progress.

Uncategorized

MIDI connection between digital piano and Macbook Pro

Carrie always was fond of the piano stool.

Right, I’ve torn my hair out over this for long enough now and so I’m pleading for help. I must be missing something very basic and elementary, but I cannot for the life of me find what it is.

First some back-story, which you will need to know if you don’t follow me on Twitter. I have recently inherited my late mother’s Technics digital piano (model PX9), as my Dad is moving house and there is no room for it at his new place. I’ve had my eye on it for some years now and my current home does have room for it, so he brought it up last week for me. Given that I cannot actually play the piano, I wish to connect it to my laptop using its MIDI ports.

My reasons for this are simple: All I want to do is:

  1. Download music from the Internet as MIDI files.
  2. Connect my laptop (Macbook Pro, Mac OS X 10.6.6) to the piano using a USB MIDI interface.
  3. Play the MIDI files on the digital piano from the laptop.

So far, I have achieved the first two goals, but I am having serious trouble with the third. Please note that I do not wish to compose music, create MIDI files or use the digital piano as a MIDI keyboard, all I want to do is have the laptop play the piano.

I have tried using the following software to achieve this:

  • iTunes – will play MIDI files, but not via MIDI, only using the computer’s speakers.
  • GarageBand – will play MIDI files on the laptop and will use the piano as a MIDI keyboard. I see MIDI signals being recognised, but it will not use the piano as a MIDI output and I cannot find any settings or options to that effect. Various Google searches suggest that GarageBand does not support MIDI output, despite supporting MIDI input.
  • Reason – this baffled the hell out of me, I couldn’t even load my MIDI file into it, much less find any MIDI output options.
  • Logic Express 9 – again, this is a complicated piece of professional software and I still could not find any MIDI output options. This surprised me given that this is supposed to be Apple’s professional composition software (in contrast to GarageBand which is aimed at amateurs), so I may well have missed them somewhere.

My question to those who know about this sort of thing is simple: How do I achieve what I want to do? What software do I need and which settings do I need to set? Surely it cannot be that difficult? I would imagine that it would be a case of having an option somewhere that changes the output audio device from the local sound card to a MIDI device. I know it’s possible because, back in the day, I had a similar interface for my Acorn Archimedes, and I distinctly remember achieving this with some considerable ease using basic bundled software.

I have confirmed that my USB MIDI interface is working correctly and that it is connected to the digital piano correctly. I think the fact that GarageBand recognises input signals from the piano confirms this. I would welcome help and advice from anyone who can help me.

Incidentally I think it’s amazing that an up to date laptop is able to connect and talk to a 24 year old piece of equipment using nothing more than a smart cable that cost £2.50 from Amazon.

Uncategorized

Salford IT and AV installation job complete

Rack installed in the basement with 3x 24 port patch panels. It eventually contain a switch, router, server and amplifier for the garden speaker system.

I spent last weekend in Manchester finally completing the first phase of the IT and AV installation job in Salford that I have been working on on-and-off since February. The last time I was there was in June when the project was at second fix stage. Since then the builders have made great progress and the owner of the house has moved back in, requiring me to finish my work in order that he can start to buy toys to plug into the system.

All that remained was the installation of a few final CAT6 face plates that I couldn’t install before (chiefly because the walls on which they were to be installed didn’t yet exist back in June), the installation of the equipment rack in the plant room in the basement, and a complete test of all installed cables with a network cable test for the structured cabling and a multimeter for the home cinema cabling. Astonishingly, I’d made it to 35 years of age without buying a multimeter, which is something of an embarrassment for a geek, so presented with a genuine need for one I went out and bought one. A decent multimeter is only about ten quid. Regarding the structured cabling, out of 67 CAT6 cable runs, only three of them failed the initial test, which is a a good percentage for first test. They were quickly repaired and now all runs work perfectly.

These photos show the highlights of the work, since I’m obviously not going to post a picture of every single socket I installed. Apologies for the quality, they were taken with my iPhone (so, no flash) in artificial light during the evening.

Sockets in the "media room" behind where the home cinema equipment will be. The home cinema connections have their other ends at the appropriate places around the room. The hole in the plasterboard wasn't my fault and will be repaired by the builders!

The next stage is to consult on what my friend/client wants to buy to plug in to this impressive piece of infrastructure. Being a G.P., he doesn’t have much of a clue regarding electronics, hence asking for my help, but does know that he wants a pretty kick-arse system and so is willing to spend a bit on it. However, since his house is still essentially a building site, regardless of whether or not he’s living in it, I expect it’s going to be a fair few months before we get to go shopping.

It was an enjoyable weekend away from home back in Manchester. I’ve not been there since Manchester Pride and I used the opportunity to catch up with H and see Saw 3D, which I enjoyed but was a bit “more of the same”. I also don’t think it’ll be the last one, there’s still loose ends. Given my recent pattern of visits it’ll probably be another couple of months before I make it back.

Uncategorized

Salford IT and AV installation job progress

I’ve been working on the next stage of the IT and AV installation job I’m doing at a friend’s house in Eccles this week. It’s second fix now which means the plastering, tiling and (most of) the painting and decorating has been done, so the job this week was to attach 69 CAT6 sockets to the CAT6 runs pulled through the house and solder all the home cinema faceplates on the speaker cables that we ran through the walls (all 10 of them). Fiddly jobs in places, but no major snags or hiccups, so far at least. When we come to test each and every cable will of course tell us whether we don’t just believe that we’ve done a good job!

All but two of the speaker cables terminate on this one plate, which all has to be soldered.

The next and final stage before equipment install (i.e. the final infrastructure installation stage will take place in a few weeks once the builders have finished the basement, where all the cables terminate and the equipment rack will be situated. Although I have all the bits we need to finish this I can’t do it because the basement to the house is not yet secure. Once the walls are finished and the external doors to the basement are fitted I can move the equipment in and finish it. Then it’ll be the big test.

There are also 12 runs of CAT6 that I’ve not yet been able to do anything with simply because the walls on which they will sit haven’t yet been built, so I’ve just run the cables to the ceiling or floor at the point at which they will eventually be and left sufficient length coiled up ready. Part of that was lifting up huge slabs of concrete out of the floor in the new kitchen which, with hindsight, would have been better done wearing a pair of gloves.

Once it’s all done my “client” can then think about home cinema and computer networking equipment. Right now he just wants to concentrate on getting the builders finished and out so that he can move back in again. I hope he doesn’t think that he “over-egged” the installation. Certainly, a 69 run CAT6 structured cabling system is definitely on the upper end of what you would normally put into a house, even of that size, and he may not even be able to buy a Dolby 9.1 home cinema system for a while. The point is that the infrastructure will make the house very future-proofed, which is what he wanted.