Just ordered a Wolfson Audio Card for Raspberry Pi via RaspberryStore. I asked them about this audio interface at their stand during the NLLGG meeting where I did a presentation about doing real-time audio with the RPi and they told me they would ship it as soon as it would become available. They kept their word so I’m hoping to mount this buddy on my RPi this very week. Hopefully it will be an improvement and allow me to achieve low latencies with a more stable RPi so that I can use it in more critical environments (think live on stage). It has a mic in so I can probably set up the RPi with the Wolfson card quite easily as a guitar pedal. Just a pot after the line output, stick it in a Hammond case, put guitarix on it and rock on.
linux
LAC2014: submission accepted!
My submission for the Linux Sound Night at LAC2014 with The Infinite Repeat has been accepted. The Call for Papers page mentions the term “danceable” so I’m going to focus on that. Making danceable music is quite a challenge for me but it should definitely be doable to produce a solid set, especially now that I’m the proud owner of a Korg Volca Keys. I’m definitely going to integrate it in my current setup as the Volca reacts great on MIDI sent from my workstation. It has some fat sounds that just scream dance floor.
I’m really looking forward to this year’s LAC. It seems falkTX and avlinux are going too, it’d be great to meet these guys in real life!
LV2 gaining momentum
The number of new LV2 plugins being released is steadily growing. The last couple of months at least the following LV2 plugins have been released:
- Bitrot (a set of LV2 and LADSPA plugins for glitch effects)
- beatslash-lv2 (a set of plugins for live beat repeating and beat slicing)
- deteriorate-lv2 (a set of plugins to deteriorate the sound quality of live inputs)
- midimsg-lv2 (a set of plugins to transform midi output into usable values to control other plugins)
- QmidiArp (LV2 plugins of the three QMidiArp modules)
- x42-plugins (collection of LV2 plugins: tuner, oscillator, x-fader, audio-level meters, midi filters etc.)
- BLOP-LV2 (port of the LADSPA BLOP plugins)
Haven’t tried them all of them yet but the ones I did try (the QmidiArp modules as plugins and some of the x42 plugins) proved to be very promising. Besides new plugins being released work continues on a great number of plugins, the LV2 framework itself and on tools facilitating in the creation or building of LV2 plugins. Especially falkTX is in the vanguard with his current work on getting his Carla plugin host to work as a LV2 plugin. This would open up a lot of possibilities like using it in hosts that don’t support all plugin frameworks (think Ardour and DSSI support). In the meanwhile the guitarix team continues to add great LV2 plugins to their ever growing collection and Dave Robillard, the main author of LV2, doesn’t sit still either with releasing updated versions of the building blocks that form the LV2 framework.
Bitwig Studio to be released
The 26th of March Bitwig Studio will be released. From the Bitwig Studio site:
Bitwig Studio is a multi-platform music-creation system for production, remixing and performance with a focus on flexible editing tools and a super-fast workflow.
It’s being developed by folks who have worked on Ableton Live and it will also be available for Linux. It’s a cross-platform DAW which means that for the GUI a platform agnostic framework has been used. In the case of Bitwig Studio the chosen framework is most probably Java which raised some eyebrows within the Linux Audio community. The price of the upcoming product met some scepticism too as it ends up higher than initially announced. Add to this that there’s barely any support for plugins (except native Linux VST) and you’ll understand that this upcoming release has fueled a discussion or two.
I haven’t seen anything yet of Bitwig Studio so I can’t judge the quality, workflow or usability of the product. I’ve registered for a beta testing account two years ago and didn’t hear anything from the Bitwig folks until recently so to be honest I completely lost interest in the product in the meanwhile.
Really, the people from Tracktion do it a lot better in that regard I think, it’s cheaper, they communicate more and it’s based on a cross-platform toolkit that has more credibility (Juce). But you never know, maybe I’ll get blown away when I get my hands on Bitwig Studio. You’ll be the first to hear.
Resolved JACK issues on notebook
Finally got around troubleshooting the issues I was facing with JACK on my notebook, a BTO that is actually a Clevo W170ER. Somehow I couldn’t go lower than -p128 with USB audio interfaces. When I thought I had tried every option, even disabling hyperthreading, I noticed two unidentified entries in my lsusb output:
Bus 001 Device 003: ID 8087:07da Intel Corp.
Bus 002 Device 003: ID 5986:0401 Acer, Inc
The first entry is a Bluetooth adapter and the second entry is a webcam. Both devices are unnecessary when making music so I thought, why not unbind them. First I had to figure out their respective bus ID’s:
$ tree /sys/bus/usb/drivers/usb
/sys/bus/usb/drivers/usb
??? 1-1 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1
??? 1-1.3 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3
??? 2-1 -> ../../../../devices/pci0000:00/0000:00:1d.0/usb2/2-1
??? 2-1.6 -> ../../../../devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.6
??? bind
??? uevent
??? unbind
??? usb1 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1
??? usb2 -> ../../../../devices/pci0000:00/0000:00:1d.0/usb2
??? usb3 -> ../../../../devices/pci0000:00/0000:00:14.0/usb3
??? usb4 -> ../../../../devices/pci0000:00/0000:00:14.0/usb4
Since the Bluetooth adapter sits on bus 1 and the webcam on bus two their respective ID’s should be 1-1 and 2-1. So I echoed the ID’s to the unbind file in the same directory:
$ echo -n "1-1" | sudo tee /sys/bus/usb/drivers/usb/unbind
$ echo -n "2-1" | sudo tee /sys/bus/usb/drivers/usb/unbind
Good riddance:
$ lsusb
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Then I started JACK again with -p64 using an USB audio interface connected to bus 3 (so no rate matching hub in between) and no more xruns, not even with a generic kernel and using WiFi and all. Next hurdle is the onboard sound. Below -p128 I get bursts of massive xruns and so far I didn’t manage to pinpoint the culprit.
Edit #1: I’ve found out that the Bluetooth adapter is the main bottleneck. Also, by echoing the aformentioned ID’s (1-1 and 2-1) you disable the whole USB bus apparently. To disable just the USB device echo the last ID in the respective path names, so for the Bluetooth adapter that’s 1-1.3 and for the webcam 2-1.6. This way you can still use the USB bus on which these devices are residing. In my case disabling the whole bus is not an option, this would mean I’d have to connect all my USB interfaces to bus 3 (bus 4 doesn’t have any external inputs) which could result in these devices getting in each other’s way with regard to bandwidth. After echoing the ID’s the output of the tree command looks like this:
$ tree /sys/bus/usb/drivers/usb
/sys/bus/usb/drivers/usb
??? 1-1 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1
??? 2-1 -> ../../../../devices/pci0000:00/0000:00:1d.0/usb2/2-1
??? bind
??? uevent
??? unbind
??? usb1 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1
??? usb2 -> ../../../../devices/pci0000:00/0000:00:1d.0/usb2
??? usb3 -> ../../../../devices/pci0000:00/0000:00:14.0/usb3
??? usb4 -> ../../../../devices/pci0000:00/0000:00:14.0/usb4
The lsusb command still shows the devices though.
Edit #2: unbinding drivers like described above won’t persist across reboots. If you’d like to make the unbinding persistent you could add the unbind command to /etc/rc.local or create a script that runs at login. There are other options of course like blacklisting the Bluetooth drivers.
A month on a Mac
During the second job interview with my new employer I was asked if I’d like to use a Mac or a Windows PC with the assurance I’d get a Linux workstation after my probation time. Just put me behind a Mac then, that’s closer to Linux than Windows and from what I recalled it comes with a native terminal that does SSH. And what do I need more?
So there I am in front of a big, glossy screen and a tiny keyboard that lacks some familiar keys. My findings so far? Kind of neutral. I’ve got my terminal and I can run SSH from the CLI so I’m happy. There are some quirks that annoy me though (in no particular order):
- No Compose key and I had to jump through quite some hoops to map a key as a Compose key.
- No easy way to map a keyboard shortcut for opening a terminal. I had to resort to something called ‘Automator’ to get it working. And it still doesn’t work the way I want too. When there are no windows open pressing the shortcut doesn’t do anything. When there are open windows it works but why does it open two terminals when pressing the shortcut for the first time? Not a real big deal as I need multiple terminals anyway (I just can’t get used to tabbed terminals).
- I prefer non-glare monitors to glossy ones.
- No Home, End, PageDown and PageUp keys. Not a real big deal either, in fact, it’s a real good incentive to start getting accustomed to Vi(m) shortcuts since I kind of live inside Vim these days. I even bought this, great stuff.
- Can’t get used to the default window management settings. For instance when you minimize a window and Alt+Tab to it the window doesn’t open. So I’m not minimizing any windows anymore since this is really annoying. Haven’t looked into changing this behaviour though, it’s probably something relatively simple.
- Annoying pop-ups from updates and programs that are downloaded from the internet (“blabla” is an application downloaded from the Internet. Are you sure you want to open it?). Especially the latter ones are annoying. Disabling the pop-ups has to be done from a terminal. Wow, so much for a “user-friendly” OS.
- Clicking the close button of an application doesn’t quit it. Cmd+Q does. This is something I won’t get used to either. Actually I don’t want to get used to the Cmd button at all.
- I prefer a panel with a window list on it. I don’t know how other folks do it but this Alt+Tab stuff is counter-efficient in my case.
Are there things I particularly like about Mac OS X or the Mac itself? Actually no, can’t think of anything. Yeah, the keyboard feel is really nice but that pro gets nulled out because of the missing keys, ~ being placed next to the left Shift key and the Fn keys being mapped to the F1/F12 keys. Add to this the meaningless keys with all kinds of arrows on them and this key with a crossed square. No idea what they do. On a software level MacPorts is nice, it allowed me to install some of my favorite tools that I found were missing. Other than that I can’t wait to have my own workstation with Linux on it. The plan is that I get a Dell XPS 15 with a dual monitor setup. Something to look forward to.
And yes, I have to deal with quite some Windows servers now. I’m not going to dedicate a blogpost to my findings on that OS. Just one word. Meh.
Using a Raspberry Pi as a piano
Recently I posted about my successful attempt to get LinuxSampler running on the Raspberry Pi. I’ve taken this a bit further and produced a script that turns the Raspberry Pi into a fully fledged piano. Don’t expect miracles, the sample library I used is good quality so the RPi might choke on it every now and then with regard to disk IO. But it’s usable if you don’t play too many notes at once or make extensive use of a sustain pedal. I’ve tested the script with a Class 4 SD though so a faster SD card could improve stability.
Edit: finally got around buying a better SD card and the difference is huge! I bought a SanDisk Extreme Class 10 SD card and with this SD card I can run LinuxSampler at lower latencies and I can play more notes at once.
Before you can run the script on your Raspberry Pi you will need to tweak your Raspbian installation so you can do low latency audio. How to achieve this is all described in the Raspberry Pi wiki article I’ve put up on wiki.linuxaudio.org. After you’ve set up your RPi you will need to install JACK and LinuxSampler with sudo apt-get install jackd1 linuxsampler. Next step is to get the Salamander Grand Piano sample pack on your RPi:
cd
mkdir LinuxSampler
cd LinuxSampler
wget -c http://download.linuxaudio.org/lau/SalamanderGrandPianoV2
/SalamanderGrandPianoV2_44.1khz16bit.tar.bz2
wget -c http://dl.dropbox.com/u/16547648/sgp44.1khz_V2toV3.tar.bz2
tar jxvf SalamanderGrandPianoV2/SalamanderGrandPianoV2_44.1khz16bit.tar.bz2
tar jxvf sgp44.1khz_V2toV3.tar.bz2 -C SalamanderGrandPianoV2_44.1khz16bit
--strip-components=1
Please note that decompressing the tarballs on the RPi could take some time. Now that you’ve set up the Salamander Grand Piano sample library you can download the script and the LinuxSampler config file:
cd
mkdir bin
wget -c https://raw.github.com/AutoStatic/scripts/rpi/piano -O /home/pi/bin/piano
chmod +x bin/piano
wget -c https://raw.github.com/AutoStatic/configs/rpi/home/pi/LinuxSampler
/SalamanderGrandPianoV3.lscp -O /home/pi/LinuxSampler/SalamanderGrandPianoV3.lscp
Almost there. We’ve installed the necessary software and downloaded the sample library, LinuxSampler config and piano script. Now we need to dot the i’s and cross the t’s because the script assumes some defaults that might be different in your setup. Let’s dissect the script:
#!/bin/bash
if ! pidof jackd &> /dev/null
then
sudo killall ifplugd &> /dev/null
sudo killall dhclient-bin &> /dev/null
sudo service ntp stop &> /dev/null
sudo service triggerhappy stop &> /dev/null
sudo service ifplugd stop &> /dev/null
sudo service dbus stop &> /dev/null
sudo killall console-kit-daemon &> /dev/null
sudo killall polkitd &> /dev/null
killall gvfsd &> /dev/null
killall dbus-daemon &> /dev/null
killall dbus-launch &> /dev/null
sudo mount -o remount,size=128M /dev/shm &> /dev/null
echo -n performance
| sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor &> /dev/null
if ip addr | grep wlan &> /dev/null
then
echo -n "1-1.1:1.0" | sudo tee /sys/bus/usb/drivers/smsc95xx/unbind &> /dev/null
fi
jackd -P84 -p128 -t2000 -d alsa -dhw:UA25 -p512 -n2 -r44100 -s -P -Xseq
&> /dev/null &
fi
This is the first section of the script. An if clause that checks if JACK is already running and if that’s not the case the system gets set up for low latency use, a simple check is done if there is an active WiFi adapter and if so the ethernet interface is disabled and then on the last line JACK is invoked. Notice the ALSA name used, hw:UA25, this could be different on your RPi, you can check with aplay -l.
jack_wait -w &> /dev/null
jack_wait is a simple app that does nothing else but checking if JACK is active, the -w option means to wait for JACK to become active.
if ! pidof linuxsampler &> /dev/null
then
linuxsampler --instruments-db-location $HOME/LinuxSampler/instruments.db
&> /dev/null &
sleep 5
netcat -q 3 localhost 8888
< $HOME/LinuxSampler/SalamanderGrandPianoV3.lscp &> /dev/null &
fi
This stanza checks if LinuxSampler is running, if not LinuxSampler is started and 5 seconds later the config file is pushed to the LinuxSampler backend with the help of netcat.
while [ "$STATUS" != "100" ]
do
STATUS=$(echo "GET CHANNEL INFO 0" | netcat -q 3 localhost 8888
| grep INSTRUMENT_STATUS | cut -d " " -f 2 | tr -d 'rn')
done
A simple while loop that checks the load status of LinuxSampler. When the load status has reached 100% the script will move on.
jack_connect LinuxSampler:0 system:playback_1 &> /dev/null
jack_connect LinuxSampler:1 system:playback_2 &> /dev/null
#jack_connect alsa_pcm:MPK-mini/midi_capture_1 LinuxSampler:midi_in_0 &> /dev/null
jack_connect alsa_pcm:USB-Keystation-61es/midi_capture_1 LinuxSampler:midi_in_0
&> /dev/null
This part sets up the necessary JACK connections. The portnames of the MIDI devices can be different on your system, you can look them up with jack_lsp which will list all available JACK ports.
jack_midiseq Sequencer 176400 0 69 20000 22050 57 20000 44100 64 20000 66150 67 20000 &
sleep 4
jack_connect Sequencer:out LinuxSampler:midi_in_0
sleep 3.5
jack_disconnect Sequencer:out LinuxSampler:midi_in_0
killall jack_midiseq
This is the notification part of the script that will play four notes. It’s based on jack_midiseq, another JACK example tool that does nothing more but looping a sequence of notes. It’s an undocumented utility so I’ll explain how it is invoked:
jack_midiseq
<command> <JACK port name> <loop length> <start value> <MIDI note value> <length value>
Example:
jack_midiseq Sequencer 176400 0 69 20000 22050 57 20000 44100 64 20000 66150 67 20000
JACK port name: Sequencer
Loop length: 4 seconds at 44.1 KHz (176400/44100)
Start value of first note: 0
MIDI note value of first note: 69 (A4)
Length value: 20000 samples, so that's almost half a second
Start value of second note: 22050 (so half a second after the first note)
MIDI note value of second note: 57 (A3)
Length value: 20000 samples
Start value of third note: 44100 (so a second after the first note)
MIDI note value of second note: 64 (E4)
Length value: 20000 samples
Start value of third note: 66150 (so one second and a half after the first note)
MIDI note value of second note: 67 (G4)
Length value: 20000 samples
Now the script is finished, the last line calls exit with a status value of 0 which means the script was run successfully.
exit 0
After making the script executable with chmod +x ~/bin/piano and running it you can start playing piano with your Raspberry Pi! Again, bear in mind that the RPi is not made for this specific purpose so it could happen that audio starts to stutter every now and then, especially when you play busy parts or play more than 4 notes at once.
Using a Raspberry Pi as a piano: quick demo
Raspberry Jam Review
Last Thursday the first Dutch Raspberry Jam took place at the Ordina HQ in Nieuwegein. I offered to do a presentation slash demonstration about realtime audio and the the Raspberry Pi so I promised myself to be there at least an hour before the scheduled starting time of my demo. That way I could also join Gert van Loo‘s presentation. When I arrived at 19:15 there was no Gert van Loo though so that should’ve triggered some alarms. Also I didn’t look out for members of the organization as soon as I came in. Instead I chose to dot the i’s and cross the t’s with regards to my demo.
Wrong decision.
About half an hour later the event was closed.
WTF?
I approached the person who closed the event and introduced myself. He replied that they thought I wasn’t coming anymore. Apparently they misinterpreted my e-mail I sent earlier that day that I didn’t manage to produce something workable for the laser show guy. They took it for a cancellation. But immediately the event got kind of reopened and I set up my stuff. We had some audio issues but in the end everything went quite well actually. I showed off what is possible with a Raspberry Pi and realtime audio with the use of some of my favorite software. Guitarix featured of course. I grabbed my guitar, fired up guitarix on the RPi and played some stuff. Hooked up my MIDI foot controller and showed how to select different presets. I also demonstrated the use of the RPi as a piano with the help of LinuxSampler and the awesome Salamander Grand Piano samplepack and did some drumming by using drumkv1. Before the realtime audio demo I presented an overview of the Linux audio ecosystem and talked about the alternatives of how to get sound in and out of your Raspberry Pi. These alternatives are not bound to the onboard sound and USB, since recently it is also possible to hook up an external audio codec to the I2S bus of the Raspberry Pi. I got one in myself this week, a MikroElektronika Audio Codec PROTO board based on the WM8731 codec, so more on that soon. It’d be awesome if I can get that codec to work reliably at lower latencies.
So it all turned out well, I had a great time doing my presentation and judging by the interest shown by some attendants who came up to me after the presentation I hope I got some more people enthusiastic about doing realtime audio with the Raspberry Pi and Linux. So thanks Ordina for offering this opportunity and thanks everyone who stuck around!
Exit BeagleBone Black, hello Cubieboard2!
Put up my BeagleBone Black for sale. It was gathering dust, somehow this board doesn’t appeal to me. Biggest drawback is that it seems to be very picky with power adapters. If you don’t use a linear power adapter USB devices might not work properly. And that was exactly the issue I was facing, I just couldn’t get my USB audio interfaces to work on the BBB. So I lost interest because well, that’s what I bought the device for, to get sound out of it with the help of an USB audio interface. Add to this that there is no realtime kernel or RT patchset available for the BBB and that the BBB is quite a complex little device (it’s actually a REAL dev board). It would’ve cost me too much time to completely fathom it. No bad feelings though, the BBB is a very nice product and it sure has the slickest looks of all ARM SoC dev boards around.
Also I got a Cubieboard2 in recently. And that board has absorbed me for the last week and a half. It’s quite easy to set up (not as easy as the RPi though), has a lot of IO (yes, it has audio in and out!) and it blows both the RPi and BBB away when it comes to performance with its dual core A20 Allwinner SoC that can easily be overclocked to 1.2 GHz. Alas, no realtime kernel or RT patchset either but hey, I managed to get a RT kernel running on a Rockchip RK3066 based device so I could at least give it a try. And it worked out well. I’m now running a 3.4.61-rt77 kernel on it with a custom Debian Wheezy installation. This time I used git to keep track of the modifications I made so it was a lot easier to create a usable diff. I also patched the driver for the onboard audio codec because the hardcoded defaults were just unusable for realtime audio. Minimum number of periods was 4 and minimum buffer size was 1024. Don’t ask me why. So I’ve changed these to 2 and 16 respectively and managed to get JACK running at a respectable -p64 -n2 -r44100. Fired up some JACK clients and this little monster keeps up very well. USB audio interfaces are no problem either, I can run my Edirol UA25 in Advanced mode with -p64 -n3 -r48000 without any hitch. This is probably because the Cubieboard2 doesn’t use a Synopsys DesignWare OTG controller with out-of-tree dwc_otg drivers like the RPi but a better supported USB controller. At the moment the Cubieboard2 is the nicest ARM dev board I have laid my hands on so far.
Cubieboard2
First Dutch Raspberry Jam
The first Dutch Raspberry Jam will take place on Thursday September 26 at the Ordina HQ in Nieuwegein. I’ve offered to do a presentation about doing real-time audio with the Raspberry Pi which has been accepted. Internet visibility of this event is minimal at the moment though, let’s hope it caches on.
So expect a presentation/demo about using your Raspberry Pi as a sequencer, synthesizer, sampler or virtual guitar amp. I will show how to configure, tweak and tune your RPi for real-time, low-latency audio and what the possibilities of such a set-up are. I’ll probably do a live demo too of some tracks generated by one or more RPi’s