Mobile Digital Audio Workstation

Upgrading my TabletPC to be a Linux digital audio workstation.
Hardware
General Approach
First Distro: Fedora 9
Second Distro: Fedora 8
Third Distro: Ubuntu 8.04
Final Distro: Fedora 8 (again)
Upgrading to a Low-Latency Kernel.
Getting the Tablet Working
Getting JACK Applications Working
Getting MP3s Working
Getting Xine Working
Getting Flash Working
Rosegarden
Hydrogen
FluidSynth
USB Audio Devices
Recording through the Interface
Integrating external MIDI
More Respect for JACK
For Follow Up...
Comments

 

Hardware

[28 May 2008]

You can see my previous entry (Installing FC5, top right of this page) about how I got Fedora Core 5 working on my other laptop.

Since then, I'd upgraded my laptop. I'd done more programming with the tablet, and wanted a beefier CPU, more memory, and a larger screen. I settled on a Toshiba Tecra M4 . User reviews on that site aren't particularly kind. I agree with reviewers who complain about heat and noise. The fan is very loud! And the machine gets very hot if I do something CPU-intensive.

However, it is a very fast machine, and the large screen is wonderful. It was a good purchase (I got it used from a seller on eBay ).

I'd gotten vanilla Fedora 5 and 7 installations working, but now I wanted to make more custom (aggressive?) changes to turn the Tecra M4 into a low-latency Linux digital audio workstation.

 

General Approach

What is a Digital Audio Workstation? For me, this is a machine that:

  • Can record high-quality audio in digital form (at least 2 digital inputs, if not 8 or more),
  • Can record incoming MIDI streams,
  • Can support general music composition (single application to work with MIDI and digital audio),
  • Can support local MIDI-triggered drum machines,
  • Has good local MIDI-triggered soft synths,
  • Can produce high-quality mixdowns,
  • Can drive external MIDI devices, and
  • Can output high-quality audio.

[By "local" I mean the component is running virtually on the laptop. So "local MIDI-triggered soft synths" are synthesizers running on the laptop, driven by the local sequencer's MIDI output.]

Basically, you can record, sequence, and then mix it all down to produce completed tracks of at least demo quality.

And a mobile DAW has to do all that in laptop form. As an added bonus, I was using a TabletPC, so I'd have the option of integrating pen support if I wanted.

Based on a bunch of searches, and some good resources such as the Linux Audio and Music blog I was able to figure out what to do.

This is the general hardware approach for constructing audio workstations:

  1. Get a beefy computer for general use. At least a 2GHz processor (preferably multi-core) and 2GB of RAM.
  2. Don't use the laptop's installed soundcard. Instead, get a firewire-based interface for audio i/o.
  3. Don't use the laptop's hard drive for storing audio tracks. Instead, get a firewire- or USB2.0-based external hard drive with at least 9200 RPM.

For purposes of testing, I wasn't ready to splurge on high-end firewire gear. So I decided to start with a simple USB2.0-based audio interface, and keep using the laptop's internal hard drive. If latency became an issue, I could upgrade to better external devices.

For Linux in particular, this is what I came up with on the software side:

  1. Use a low-latency kernel, like the one supplied by Planet CCRMA .
  2. Use JACK (Jack Audio Connection Kit) for audio. This includes ALSA support for digital i/o through Linux USB audio .
  3. Use Rosegarden for composition.
  4. Use Hydrogen as a local drum machine.

That gets you everything except for local soft synths and a way to produce high-quality mixdowns.

I really have no idea how mixdowns or soft synths work in Linux. I believe you can use a JACK listener to create mixdowns, and I've seen references to multiple soft synth devices.

But most of the purpose of this exercise was to get proficient in Linux soft synths.

 

First Distro: Fedora 9

The first step was to install a Linux distribution to use as a base. I wanted a reasonably up-to-date distribution. I've had good luck with Fedora , so I thought I'd try an upgrade to Fedora 9, the most recent version.

I installed Fedora 9 from the install DVD. I disabled most of the install packages to keep it small. I've found I need to add a bunch of packages post-install using yum anyway, so I prefer to keep the initial install fast.

Pretty quickly, I had Fedora up and running on the Tablet. The installer did a great job recognizing the screen, mouse, etc. No tweaking was required there.

Of course, the tablet was not recognized or configured, but that's par for the course for Linux. But I wasn't going to worry about that yet.

The next thing was to get a shell up. The Fedora 9 KDE application panel is very poor (why do open source window manager developers insist on copying Windows instead of just making something simple and usable?). Also, it is apparently not possible any longer to create links to programs in your taskbar? KDE only seems to support a few hardcoded "widgets", which I found useless. Why can't I just have a quick link to a shell?

In general, Fedora 9 (at least the version I tried) was very raw. Also check out the Slashdot Fedora 9 announcement . It looks like most of my complaints about KDE were really due to the beta nature of KDE 4.

Anyway, I found Konsole buried in the menus, and fired it up.

Next: get the network working. The Tablet has an ethernet port, but who uses those anymore? I wanted to get the wireless card working. It detected my home wireless network just fine, but when I attemped to connect using iwconfig I got this error:

"ipw2200: Failed to send SYSTEM_CONFIG: Already sending a command."

A Google search recommended that I disable hardware cryptography for the device. However, that suggestion referenced a directory (/etc/modules.d) that doesn't seem to exist in Fedora 9. I spent a fair amount of time searching on the web and on my local Fedora 9 install, but was unable to determine how to tweak the ipw2200 modprobe options.

So Fedora 9 was already shaping up to be painful. I'll try a later release of Fedora 9, or just wait until 10, when KDE 4 is further along.

I decided to step back a version, and try Fedora 8.

 

Second Distro: Fedora 8

[29 May 2008]

I burned a Fedora 8 install DVD, and set it to work. At first, this fared even worse than Fedora 9. Whether using graphical or text mode for install, the boot would get about 30 seconds along and then hang saying "running /sbin/loader". At that point the machine would become unresponsive.

I tried doing some Internet searches to discover what might be happening. The pre-burn checksum looked okay, and I wasn't really willing to burn another DVD on the off chance I'd happend to burn a bad disc.

Searches turned up possible problems with acpi. Most results (such as this one ) recommended turning off acpi as part of the install options. And then users noted that they had problems getting wireless to work.

I was about to give up entirely, but while I was searching, the laptop suddenly started responding. Apparently the /sbin/loader hang isn't permanent, it just locks up the machine for a minute or two. Based on other reading it seems to be a later-fixed kernel issue.

So I started the Fedora 8 install. As my Plan C, I also burned an install disk for Ubuntu while I was waiting.

After a while, I had the Tablet rebooting with Fedora 8. The install did something strange where the Tablet BIOS acted up on reboots, which worries me.

However, I was overjoyed by two things:

  1. The task bar allowed me to add application icons again, and
  2. Fedora 8 had auto-detected my wireless card and already had it up and running with DHCP.

I felt 10 times better already!

However, xrandr still didn't work. I've been waiting for Rotation support since Fedora Core 1! It apparently takes a long time for these features to show up.

At this point, Fedora 8 was looking promising, but I had already been running on Fedora 7, so moving to 8 wasn't a big step forward.

So it was on to the third attempt...

 

Third Distro: Ubuntu 8.04

I'd heard great things about Ubuntu from a coworker, so this seemed like a good time to try it out. I have gotten used to Fedora, and have an efficient setup, but I was willing to see if Ubuntu would work for me.

The setup was painless and straightforward! I felt a bit uncomfortable without getting a chance to control the install, but it completed quickly and Ubuntu wins big points for keeping everything on a single install CD (and I don't think they cheated by using the network since the machine was unplugged and I don't think it figured out my wireless card).

Also, Ubuntu booted noticeably quicker than Fedora (any release) on the Tablet.

The tablet (stylus) wasn't recognized, nor did xrandr work. (For me, xrandr doesn't work unless it supports rotation). But that's par for the course with current Linux distros.

Hooking up to my wireless network was a breeze. There was an icon on the task bar that was very intuitive.

However, I must have mis-typed when installing because I couldn't log in as root from the terminal (!). That's the first time I've ever done that. I wasn't keen to go fix the root password.

And in any case, I had already decided to switch back to Fedora 8. Why? Because for my digital audio workstation I'd probably want to use the low-latency kernel from PlanetCCRMA , and that only had documented support for Fedora 8.

So I bid goodbye to a very smart-looking Ubuntu and went back to Fedora 8.

 

Final Distro: Fedora 8 (again)

So it was back to Fedora 8. I was still kind of freaked out by the weird impact on my BIOS after the previous install.

"weird impact on my BIOS": by this I mean I'd get a scary "TIMER INTERRUPT ERROR" on the screen any time I did a restart. If I tried accessing the BIOS when this happened, the laptop would hang. This is well ahead of the kernel startup, so I attributed it to the BIOS.

However, hard reboots didn't display the error, nor did they lock if I accessed the BIOS. So I don't think it was part of the persisted BIOS?

Anyway, it scared me. I figured it was related to the /sbin/loader lockups, so I did more research on installation options.

You can perform various Google searches to find hints. I finally chose a single additional install option:

  nohz=off

based on the Fedora wiki . As usual, I installed in text mode.

I was happy to see the install skip past the /sbin/loader line very quickly!

I like the default KDE setup! It is very clean, with a lot of space for the desktop, and a slim taskbar where I can configure my application launch buttons.

However, the "TIMER INTERRUPT ERROR" returned on reboot. So something else in the Fedora 8 install was having a dangerous effect on my BIOS.

Reading around about the problem (like this Google search ) indicated that it was fixed. So rather than mess with more kernel options I decided to run "yum upgrade". This should update the kernel.

And in any case, I was planning on moving to the PlanetCCRMA kernel.

The upgrade finished (an hour later) so I was ready for the next step.

 

Upgrading to a Low-Latency Kernel.

As much as I love Linux, I have a technical day job and don't need to come home and mess with kernels. However, the Planet CCRMA software package has been very stable for me over the years, so I decided to try it on my laptop. Nowadays it is very easy in any case: just another yum install!

I basically followed the instructions at the Planet CCRMA site: Fedora 8 - Planet CCRMA Installation Instructions .

I'd already installed Fedora 8 and performed a "yum upgrade" (above) so the next step was to import the Planet CCRMA GPG key and repository, and then run "yum install planetccrma-core".

The scary part, of course, is when you see "kernel-rt" install, since that after all is the realtime kernel. The PlanetCCRMA website recommends that after the install you "cross your fingers and reboot the machine." Yikes.

One happy note: on reboot I noted that the "TIMER INTERRUPT ERROR" was gone.

GRUB showed that I had a new planetccrma kernel, and happily booted it. I didn't notice any issues at all as Fedora 8 booted, and I logged into KDE just fine.

As far as I could tell, the realtime kernel was working on my laptop perfectly.

 

Getting the Tablet Working

[1 June 2008]

[You can skip this section if you aren't using a Tablet]

Great, I now had a working Fedora 8 installation, running on a low-latency kernel. But it is a very nice Tablet PC! So I wanted to get the stylus working.

Previously (see my FC5 install on another tablet ), I'd had to download and (sometimes) build the wacom drivers.

However, it looks like Fedora 8 includes the wacom drivers, at least according to this source (thinkwiki) . So all I had to do, theoretically, was just update my xorg.conf file so X11 would pick up the stylus.

I had to make two changes. First, I had to define the new input devices in the config file:

Section "InputDevice"
   Driver "wacom"
   Identifier "stylus"
   Option "Device" "/dev/ttyS0" # SERIAL ONLY
   Option "Type" "stylus"
   Option "ForceDevice" "ISDV4" # Tablet PC ONLY
EndSection


Section "InputDevice"
   Driver "wacom"
   Identifier "eraser"
   Option "Device" "/dev/ttyS0" # SERIAL ONLY
   Option "Type" "eraser"
   Option "ForceDevice" "ISDV4" # Tablet PC ONLY
EndSection


Section "InputDevice"
   Driver "wacom"
   Identifier "cursor"
   Option "Device" "/dev/ttyS0" # SERIAL ONLY
   Option "Type" "cursor"
   Option "ForceDevice" "ISDV4" # Tablet PC ONLY
EndSection

Second, I had to tell the server object about the new inputs. I added three new lines to the "ServerLayout" section:

   InputDevice "stylus" "SendCoreEvents"
   InputDevice "eraser" "SendCoreEvents"
   InputDevice "cursor" "SendCoreEvents"

Again, this is all from the thinkwiki page . However, my tablet was using serial port /dev/ttyS0, not S1. You can check the dmesg log to verify which port the tablet is using.

With those changes, KDE was now accepting pen events.

 

Getting JACK Applications Working

The next step: get JACK running.

As part of installing Planet CCRMA (above) you get access to the planetccrma repository (you can see it in the /etc/yum.repos.d directory).

You'll also want QJackCtl , a handy UI widget that lets you control the JACK setup.

You can install (or update) JACK and qjackctl using yum, like this:

   # yum install jack-audio-connection-kit qjackctl

(remember--you have to run yum as root or with root permissions).

Annoyingly, installing qjackctl required installing QT4 , which is a sizeable download. But I use the QT libraries a lot during development, so I figured now was as good a time as any to download.

Once it all installed, I disabled the KDE sound system. I think it supports JACK but I didn't want to take any chances. [Later, I re-enabled the KDE sound system. I think my fear of the KDE sound system was from previous installs years ago. The Fedora 8 KDE sounds system supports JACK, and I haven't had any problems with it.]

Then I started up JACK. I found I had to run qjackctl as root, or it couldn't start jackd (?). After I rebooted, however, I was able to run qjackctl from my regular user account.

If you check the qjackctl logs when JACK starts, you'll see it is using the -R option (realtime).

 

Getting MP3s Working

Nothing is more embarrassing for a Linux user than not being able to play the most basic open-source media formats such as mp3 and mpeg. Yet that's exactly what happens out-of-the-box. I know there are various licensing reasons for this, but it is one of the most frustrating parts of installing a Linux distro. Anyone with a basic commercial operating system can just play their mp3s, visit web sites with Flash content, and have it all work. Somehow no one has figured out a way to make a distro do that.

First thing: get mp3 support working!

I linked to some of my mp3s on a remote server, and then attempted to play them by double-clicking them in Konqueror. This started up Amarok, which tried to guide me through a fairly heavyweight installation process, and then failed to play the mp3.

I usually use xmms , since it is pretty lightweight and skinnable. I installed using

   yum install xmms xmms-jack

So I'd have the JACK plugin. Of course, this still didn't play MP3's.

In theory, getting mp3's to work is as simple as running

   yum install xmms-mp3

with the correct repository. Getting the correct repository is the trick: you don't want to pick up something that is incompatible with the PlanetCCRMA repository.

Based on some searches, it appeared that the freshrpms repository should be compatible. It was recommended that I enable it, download what I need, and then disable it (!) so that my system wouldn't start pulling other packages from it.

So for now, get freshrpms available as a distro by typing:

   rpm --import http://freshrpms.net/RPM-GPG-KEY-freshrpms
   rpm -ivh http://ftp.freshrpms.net/pub/freshrpms/fedora/linux/8/freshrpms-release/freshrpms-release-1.1-1.fc.noarch.rpm

(see instructions here ).

Then go into the /etc/yum.repos.d/freshrpms.repo file and disable it by setting the "enabled=" line to be "enabled=0".

Now you can install the xmms-mp3 package and enable the freshrpms repository just for that install by running

   yum install xmms-mp3 --enablerepo=freshrpms

At this point, I rebooted. When the machine came up again, I was able to start qjackctl from a non-root user, and mp3 playback from xmms worked fine. Also, I was able to re-enable the KDE Sound System using JACK, and system sounds worked fine. Great!

 

Getting Xine Working

Next: getting video working. In this day and age of video cameraphones, your laptop isn't much use unless you can connect and have it play various formats like mpeg, wmv, 3gp, etc.

This was another install that required freshrpms. I installed by running (as root as always for yum):

   yum install xine --enablerepo=freshrpms

I found that wasn't enough to make xine JACK-enabled (no audio), and I also wanted plugin support for Firefox. Fortunately, that's as easy as getting two additional packages:

   yum install xine-lib-extras xine-plugin --enablerepo=freshrpms

Then I had to go into the xine setup, and set the audio driver to JACK. After that, playback of various audo + video formats worked fine.

 

Getting Flash Working

My preference is that all websites would be simple HTML with JavaScript. Alas, many websites require flash, to the point where you can't really surf without it.

Going to a flash-enabled site (like YouTube or Zillow ) is broken out-of-the-box.

I followed the instructions at Mauriat Miranda's website , which consisted of installing the macromedia repository (disabled as I did for freshrpms) and then using yum to install the plugin.

I restarted Firefox, and Flash-enabled websites were working as expected.

[But note that once I had JACK properly configured later, Flash stopped working very well.]

 

Rosegarden

Okay, I now have a functional laptop with a low-latency kernel. Now for some composition tools! Rosegarden is my composition studio of choice, mostly by habit although there isn't much else for Linux that has such good integrated MIDI + digital audio support.

Rosegarden is pretty easy to install once you have a Planet CCRMA setup. Just run:

   yum install rosegarden4

And you are set. Once it completed installing, I was able to run rosegarden from the command line just fine. I haven't tested it yet, however...

 

Hydrogen

Now for a good drum machine: Hydrogen . To install, just run:

   yum install hydrogen

It installed pretty quickly, and then I was able to run hydrogen from the command line.

To test Rosegarden and Hydrogen, I fired up hydrogen and then rosegarden, opened a MIDI file in Rosegarden, and played it. Hydrogen picked up the MIDI events and started playing them.

Likewise, I could shut down Rosegarden, and just compose drum tracks in Hydrogren. Pretty good!

 

FluidSynth

I also decided to try FluidSynth , just because a few other sites had recommended it.

Again, it is an easy install:

   yum install fluidsynth fluid-soundfont qsynth

Watch out! The soundfont package is huge (over 100 megs). But it downloaded for me reasonably quickly.

You want the qsynth front end--it gives a nice UI for the fluidsynth engine.

Then I was able to start Rosegardent and qsynth, open a MIDI track, and play it. The fluidsynth engine would pick up the MIDI events and play.

NOTE: first I had to open a soundfont. The yum install (above) puts these in /usr/share/soundfonts. Just open the control panel in qsynth, click on the Soundfonts tab, and open the soundfonts.

I couldn't get Rosegarden to drive both Hydrogen and FluidSynth at the same time. Once Hydrogen was involved, FluidSynth would stop responding, and I had to restart everything (without Hydrogen) for it to work. So clearly some hand-holding is needed when running multiple MIDI listeners.

However, I was pretty happy to get FluidSynth up and running so easily. This was a good proof of concept.

 

USB Audio Devices

The laptop is now working fine as a software-only device. What about adding a USB2.0 external interface to support high-quality audio i/o and MIDI?

A lot of people recommend only using FireWire, not USB, since without FireWire you will experience latency. But I figure I can play with FireWire later, and get USB2.0 devices working with my setup first.

What USB2.0 audio interface to get? I did some searches, and had the best luck at zzounds . I particularly liked the looks of the Tascam US-144 . In fact, I was all the way through their order process and was about to click "Confirm My Order" when I got cold feet. I decided to do a quick search and see if the US-144 would even work under Linux.

Sure enough, the US-144 does NOT work under linux! So I abandoned that purchase, and kept looking.

A few sites had recommended M-Audio for Linux support. So I looked at the M-Audio Fast Track Pro . It looked like a simple and reliable USB audio interface with some Linux support.

However, once I found the LiveJournal review , I was a little leery. It is incredibly cheesy that someone would compensate for noisy electronics by throwing in a noise gate!

But I saw a lot of references to people working successfully with this interface on various flavors of Linux, including Fedora 8. So I decided to buy one, if only so I could get some experience with an external interface, even if the quality wasn't great. I'm hoping that by the time I need a better interface there will be good Linux support for a range of FireWire devices.

In the end, I found the Fast Track Pro for sale cheaper on Amazon.com , so I bought it there.

Now I'm just waiting for the interface to show up!

[4 June 2008]

The interface showed up today! I plugged it in, and powered it up. A blue light came on.

Yay.

Next step: get it recognized by Alsa/Jack. That was partially working, since the QJackCtl setup window saw the Fast Track Pro available as hw:2.

Also, if I ran

   % aplay -l

I could see the Fast Track Pro listed as card 2, with both outputs available (channel 0 and 1).

I could see the Midi ports show up under the QJackCtl connection window. But I couldn't see any audio/PCM ports available.

ALSA was definitely happy with the device, since

   % aplay -D hw:2 test.wav

seemed to work fine. JACK refused to acknowledge it.

But then I realized that was just me being an idiot. Because I'd configured Jack to use the Fast Track Pro as the device, it was showing up in the Connections panel as "System". Once I realized that, I fired up XMMS, played an MP3, and heard music through the headphones I'd plugged into the Fast Track Pro. Awesome.

Summary of configuration: I had to go into the QJackCtl settings panel, and select the Fast Track Pro as the Interface.

Put another way: I didn't really have to do anything! It was pretty painless. Kudos to the many ALSA, OSS, and JACK developers out there. [Although see below: the actual configuration is a bit more complicated. But not too bad.]

Later I hooked it up to my studio mixer and got decent quality audio out through my monitors from the TRS output (1/4" jack).

Although this video didn't help much of my Linux troubleshooting, I did find it to be a good overview of the Fast Track Pro.

[Annoyingly, YouTube isn't working well after I've gotten JACK set up--problems with the Flash plugin?]

 

Recording through the Interface

Okay, now could I record audio?

Getting recording to work wasn't as straightforward as playback. I could see the system capture ports on the QJackCtl connections window, and they were properly hooking up to the Rosegarden recording ports. But when I tried to record in Rosegarden, no sound was registered.

Finally I found the problem. As this Ardor posting notes, the Fast Track Pro can act as separate devices. You need to configure it a bit (almost as if it was two different devices!) so you can record and playback smoothly.

It was this picture (from the Ardor post) that finally clued me in: I had to configure the Input and Output devices in jack separately.

For me, I ended up switching Interface back to "(default)", and then setting the Input Device to be "hw:0,1" and the Output Device to be "hw:0,0".

Then I was able to record and playback from within Rosegarden!

This was a bit complicated, but I grudgingly see the purpose: different interfaces and/or hardware configurations could result in funky input/output settings. JACK had to be generally configurable so that everyone's hardware would work.

But after all, the point was to learn more about Linux audio configuration. So far, so good! The main take-away is that you need to learn how to configure your audio devices for JACK and recording/playback may be configured slightly differently.

 

Integrating external MIDI

I was almost finished with the initial install! The remaining step: getting MIDI to work.

I have an external keyboard, so I hooked the MIDI in/out ports up to the Fast Track Pro. Within 30 seconds I was able to record MIDI tracks in Rosegarden, and play them back externally.

Just for fun, I also recorded a MIDI track from the keyboard, then had it play back through to Hydrogen, so my piano notes came out as random percussion hits.

Then I loaded a sample MIDI file into Rosegarden, and had it drive my external synth. Good.

Most impressively, I was able to fire up QSynth, then hook up my external keyboard's MIDI out to the fluidsynth engine's MIDI in (again, using the QJackCtl Connections window). I shut down the volume on my external synth, played the keyboard, and fluidsynth produced the output sounds in realtime. I didn't notice any latency (JACK claimed a latency of 2.7ms), and I was able to pretty seamlessly drive the virtual synth from an external keyboard. Wow.

One weirness: JACK didn't automatically hook up the MIDI in from the keyboard. So I had to manually do that in the QJackCtl connections window (ALSA tab).

 

More Respect for JACK

Playing with the recording and playback, and the MIDI connections, gave me a lot more respect for JACK. Having the ability to patch back and forth between different devices (real and virtual) was surprisingly easy.

I also started to see the power of patching voices in and out using JACK connections. For instance, I could do a bunch of composing using an external keyboard and quickly switch over to an internal device for playback just by swapping out a patch cord in the QJackCtl connection window. Impressive!

I went back to the JACK home page , and surfed through more of the documentation. This presentation is well worth perusing. I haven't yet listened to the audio track.

 

For Follow Up...

With a basic stable distro, I intend to check out the following synthesis programs:

  • SuperCollider , an open-source synthesis language.
  • cSounds , an open-source synthesis and digital processing language.
  • FluidSynth , which I have played with a bit but need to understand soundfonts better.

 

Comments

Loading comments...

Post a comment

WARNING: This is a very primitive comment posting. Stick to alphanumerics only! No quotes, brackets, etc.
Your name:
Website (optional): (example: www.my-website.com/path/to/homepage.html)
Comments:
(Click 'Preview' to see what your post will look like. It won't become visible yet.)