As our collection of MP3 CD's was wearing out I thought why not put a small embedded board with a big drive in our car? I dug up a Cubieboard2 that was gathering dust and started hacking. The goal:
- Small system based on Debian Jessie
- MPD to serve the audio files
- Remote control via WiFi
- Big drive
- Acceptable boot time
- Basic protection against file system corruption
Putting a bog standard Debian Jessie on the Cubieboard2 was quite straightforward with the help of the linux-sunxi.org wiki. The board booted with the standard kernel but unfortunately no sound. Luckily I had just received some ultra-cheap PCM2704 USB audio interfaces and these worked and sounded great too. WiFi worked out of the box but the rtl8192cu driver of the 3.16 kernel for the Realtek RTL8192CU chipset has the tendency to quickly go into suspension and as this driver doesn't have any power management options I ended up with a hacky for loop in /etc/rc.local that pings all IP's in the DHCP range. I quickly dropped this iffy set-up as it just didn't work out that well and ended up using a DKMS based solution that made it possible to control power management of the WiFi dongle. Next hurdle was hostapd that stopped working with this alternative driver. But with the help of the hostapd-rtl871xdrv GitHub repo I managed to cook up a fully working hostapd Debian package.
Next up was the hard drive. I first tried a USB drive but the Cubieboard2 just couldn't provide enough juice to power the drive properly together with the WiFi dongle. I also tried with my Raspberry Pi's but those had the same issues. So I had to resort to a SATA drive. Of course I bought a 3.5" drive first because those are cheaper. But you can't power a 3.5" drive with the SATA cable that comes with the Cubieboard2 and as I had a bit of a deadline I returned it for a 2.5" drive and that works like a charm. I installed MPD, copied my music collection to the hard drive, fired up MPD and was greeted with a segmentation fault. Apparently the Jessie MPD package has issues with the sticker database file so I installed MPD from the backports repo and that version runs without any complaints so far.
For some basic protection against corruption by sudden power loss I created separate partitions for /home and /var on the SD card that are mounted rw with a couple of options to reduce corruption (sync,commit=1,data=journal) and / is mounted ro, just like the big hard drive with the audio files. /tmp is being mounted as tmpfs in RAM. Boot time is about 15 seconds and I'm OK with that. To remotely shut down the CarPC via WiFi I use a JuiceSSH homescreen shortcut of a connection that runs a simple shutdown -h now snippet.
After I had mounted everything in our car the thing wouldn't boot though. Swapped the 1A USB car adapter for a 2.1A version and then the CarPC came up properly. Installed MPDroid on my Nexus 5 to control MPD via WiFi and so far, so good!
Sometimes the CarPC became unreachable via WiFi. The culprit was that the DHCP service (udhcpd) didn't always come up because it was sometimes started before hostapd. I fixed this by copying /var/run/systemd/generator.late/udhcpd.service to /etc/systemd/system/udhcpd-custom.service and adding hostapd.service to the After line and adding a Requires=hostapd.service line. I also added a [Install] stanza with the line WantedBy=multi-user.target. I then disabled udhcpd.service and enabled udhcpd-custom.service.
Hostapd didn't always start flawlessly either so I copied /var/run/systemd/generator.late/hostapd.service to /etc/systemd/system/hostapd-custom.service and added sys-subsystem-net-devices-wlan0.device to the After and Wants lines. Also added an [Install] stanza, disabled hostapd.service and enabled hostapd-custom.service.
When the Raspberry Pi 2 was released I certainly got curious. Would it be really better than it's little brother? As soon as it got available in The Netherlands I bought it and sure this thing flies compared to the Raspberry Pi 1. The four cores and 1GB of memory are certainly an improvement. The biggest improvement though is the shift from ARMv6 to ARMv7. Now you can really run basically anything on it and thus I soon parted from Raspbian and I'm now running plain Debian Jessie armhf on the RPi.
So is everything fine and dandy with the RPi2? Well, no. It still uses the poor USB implementation and audio output. And it was quite a challenge to prepare it for its intended use: a musical instrument. To my great surprise a new version of the Wolfson Audio Card was available too for the new Raspberry Pi board layout so as soon as people reported they got it to work with the RPi2 I ordered one too.
One of the first steps to make the device suitable for use as a musical device was to build a real-time kernel for it. Building the kernel itself was quite easy as the RT patchset of the kernel being used at the moment by the Raspberry Foundation (3.18) applied cleanly and it also booted without issues. But after a few minutes the RPi2 would lock up without logging anything. Fortunately there were people on the same boat as me and with the help of the info and patches provided by the Emlid community I managed to get my RPi2 stable with a RT kernel.
Next step was to get the right software running so I dusted off my RPi repositories and added a Jessie armhf repo. With the help of fundamental the latest version of ZynAddSubFX now runs like charm with very acceptable latencies, when using not all too elaborate instrument patches Zyn is happy with an internal latency of 64/48000=1.3ms. I haven't measured the total round-trip latency but it probably stays well below 10ms. LinuxSampler with the Salamander Grand Piano sample pack also performs a lot better than on the RPi1 and when using ALSA directly I barely get any underruns with a slightly higher buffer setting.
While packaging Tuna I ran into an issue for which I couldn't easily find a workaround on the ubiquitous search engine. Tuna depends on some unavailable Python applications so those had to be packaged too. After having successfully tested the packages locally with pbuilder I uploaded them to Launchpad and noticed that they failed to build. Apparently the Python installer setup.py wants to install in /usr/lib/python2.7/site-packages and while that worked fine locally with pbuilder, Launchpad had an issue with that:
Found files in /usr/lib/python2.7/site-packages (must be in dist-packages for python2.7).
dh_builddeb.pkgbinarymangler: dpkg-deb --build debian/python-schedutils .. returned exit code 1
make: *** [binary-arch] Error 1
dpkg-buildpackage: error: /usr/bin/fakeroot debian/rules binary-arch gave error exit status 2
Apparently the files had to be installed in /usr/lib/python2.7/dist-packages but how to instruct the installer to do so without having to resort to ugly hacks? As I couldn't find any useful answers on the web I asked falkTX on #kxstudio. He said the setup.py installer has a flag to install to dist-packages instead of site-packages, --install-layout deb. So I added that to the debian/rules file and gave it another spin:
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
python setup.py build
python setup.py install --skip-build --prefix /usr --root $(CURDIR) --install-layout deb
Now both pbuilder and Launchpad built the package without any issues.
For years I've used Focusrite Firewire interfaces, first the Saffire Pro 10 IO and after that its successor, the Saffire Pro 40. Both great devices but recently I decided to make the switch to USB. The reason was twofold:
- I was barely using more than 2 ins or outs simultaneously
- Firewire is being phased out and my notebooks don't have any Express Card slots either, only USB ports
- The Pro 40 isn't very portable
So when switching to USB I would need:
- Same or better quality preamps and AD/DA convertors
- At least 2 ins and outs
- Possibility to achieve similar latencies as with the Pro 40
- Works well with Linux
This narrowed down the choice significantly. I could go for a Focusrite Scarlett but from what I found on the net there were some issues with these devices. I've also looked at some Presonus devices but actually I had already set my mind on a different device: the RME Babyface.
So when I found a webshop that offered the Babyface at a reduced price (almost 15% off) I put my Focusrite up for sale and bought the Babyface. The Focusrite was sold within a week and the Babyface easily met my expectations:
- When in CC (Class Compliant) mode it works out of the box
- It's highly portable, the Babyface is actually specifically made for this purpose as it comes with a nice pouch
- It has 2 ins and outs and the great thing is that it's possible to extend the IO via ADAT
- The preamps and AD/DA converters are simply top notch, they're so good that I'm considering switching cans and studio monitors as this device is merciless, it simply doesn't work well with my current setup
- When connected to an USB3 port (XHCI) the Babyface can run with nominal latencies of 0.5ms (this is with 8 samples), i.e. it beats the other two OS's mentioned on the RME product page
I can live with not being able to control the device from within Linux, almost all settings can be done on the device itself. Upgrading the firmware can be done with a VM so that's covered too. The only real drawbacks are that it's an USB device so it's a bit more picky with regard to your system setup and it consumes a bit more CPU compared to Firewire. But all in all this is a great sounding device that works well with Linux when in CC mode and it fits my specific user case very well.
Finally got around finishing a new track. And it's just 65BPM so no four to the floor this time. I posted the demo a while ago, this is more or less a definitive version (definitive is a fluid term in my dictionary).
This song is about one of the most beautiful places I know on this
planet, Cala Del Aceite in the most southern part of Spain:
- Qtractor for recording and mixing
- seq24 for sequencing
- The necessary plugins:
- drumkv1 to hold the drum samples (drum samples are all from
- a lot of plugins that are part of Distrho or Carla: Noize Maker, Tal
- Reverb III, ZynAddSubFX-LV2, Nekobi
- MDA subsynth
- FluidSynth DSSI for the Rhodes
- linuxDSP plugins (EQ500, DYN500, MBC2B on the master bus)
- Calf Vintage Delay
- LADSPA comb filter, Fast Lookahead Limiter
The background vocals for the choruses are sung by my wife. The ocean
sample is from Freesound:
Cádiz is pretty close to Conil, hence the choice.
Making promises that I can't keep
It's pushing me, pushing me into a deep
State of sadness, state of doubt
A state of awareness I can't live without
Making mistakes, so hard to bear
It's driving me, driving me to a point where
I can't escape, I can't shy away
From the daemons I refuse to obey
All is forgiven, all is well...
Awaiting the day that I'll be relieved
From this burden, this burden that has grieved
So many loved ones, so many friends
All the people on which I depend
Stand up, act now, it's time for a change
Lingering won't help, help to rearrange
The current imbalance, the current state
Of things so rush now don't hesitate
All is forgiven, all is well...
Cala Del Aceite by The Infinite Repeat is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.