The Raspberry Pi Should be Great for Music Recording. Should.

I hate writing this article because it is deeply unsatisfying to finish investigating the possibilities of something which, on the surface appears to exactly meet the requirements and then failing to come out with a working solution.

However, such problems are worth writing about if only because doing so might go some way to provoking someone into coming up with a solution.

Someone who is not me.

On the surface, the Raspberry Pi appears to be the ideal tool for doing music recording, primarily owing to its small size and lack of fans. However, it is let down by the mess of systems which underpin the audio system in Linux.

Now, having said that, I did actually some years ago have a Pi version 2 working reasonably well as a sound recorder. It had meant fiddling quite severely with some of the configuration files in order to turn the headphone jack into a line in, and then using USB headphones, but it was not bad. It would have been preferable to use a USB for the audio in but for reasons that will become clear this isn’t really an option.

That wasn’t actually bad as solutions go. The whole point of the Raspberry Pi is to be able to reverse engineer and hack away at the system as a means of educating oneself about how it fits together. The problem is that actually the operating system in newer versions is becoming more refined. Which has to be the most ironic problem of any operating system anywhere ever. But the upshot is that, like cars, it is becoming harder and harder with newer versions to take it a part. Which really rather self-defeats the point of the pi.

This wouldn’t be so bad but for the fact that the alternative solutions at the moment are are either dire or broken.

The native operating system, Rasbian, is broken insofar as one can no longer turn the headphone jack into a line in without taking the operating system apart even more drastically than was previously necessary. Previously, this had simply meant altering some more obscure configuration files. This time round it didn’t seem like after 8 hours of examining the problem I was anywhere near a sane solution.

The obvious alternative is to use USB audio inputs for the recording. However, the lack of robustness in ALSA for managing unfamiliar devices mean that even relatively common devices like my guitar effects pedal cause the Raspbian Audio system (ALSA, for the record) to crash when loading the volume controls. Sub-optimal to say the least.

Now, ALSA is not the only component in the space of the Linux audio environment. Also commonly available are Jack and Pulseaudio. The overlap between each of these technologies is vague at best. And herein lies a part of the problem. For a long-story short, Pulseaudio can help with providing more nuanced controls for some devices such as my effects pedals, but demands a fair slice of overhead for processing that information, and also requires the operating system to have suitable interfaces to make those primary recording devices. Jack has some of the tools to route audio from one socket to another and perform some other audio management tasks, some of which overlap with pautions of PulseAudio.

Pulseaudio proves to be quite the resource drain, sadly, just pushing the Raspberry Pi to a problem point. I wound up installing Ubuntu Mate (an alternative operating system for the Raspberry Pi) just to get it working smoothly. However, the overheads mean that the audio glitches when I record, as the bits of RAM where the audio is placed before writing to disk fill up before the processor is able to get around to emptying them onto the SD card which serves as the Hard Drive on the Raspberry Pi, so bits of audio get periodically lost to the ether.

If it seems at this point that I am grossly simplifying, that would be because I am. The whole under-the-hood is such a hideous mess that a detailed explanation of what is taking place becomes both obscenely complex and terminally dull. Having one well designed system for dealing with audio I/O, rather than a dijointed patchwork of software seems like an obvious step towards making this sort of thing work and work well. The Raspberry Pi has a lot of potential here, and it seems a shame that it is being wasted because of generally poor software design in the larger Linux sphere, and over-zealous optimisation of the default operating system.

Most disappointing for me is that I don not have the brain cycles at my disposal to arrange a solution to this problem; I didn’t come looking for (another) low-level, high difficulty programming project. I have enough of those, and they most often involve me devoting too many brain cycles to string handling (a problem for description another day). And so this article finishes in this most unsatisfying of places.