Linux Audio Workstation

Log of my attempt to put together a Linux Audio Workstation
[ Back to the regular presentation of this content: Linux Audio Workstation ]

Table of Contents

     The Goal
     Abandoning Fedora Core 4
     How a Linux Audio Workstation should Work
     Lost in the Distro Wilderness
     Back to Fedora Core 4
     16 May
     20 May
     21 May
     30 May - Success!

 

The Goal

[Monday, May 15, 2006]

I am attempting to put together a Linux Audio Workstation. For years I was running Windows98, because that's the only OS that my old copy of Cubase supported. But I decided to enter the 21st century. Also, I've seen hints that there are better audio tools available on Linux now than there were just a few years ago. Linux has supported direct-to-disk recording for a while, and JACK is supposed to be a great realtime synthesis architecture.

However, my LAW project is not going very well.

About 3 weeks ago I carefully saved some precious data, then wiped my machine clean. I tried installing a couple of different Linux distributions, but ultimately settled on Fedora Core 4.

 

Abandoning Fedora Core 4

There are a lot of things I liked about FC4. Pretty much all of the distros I tried supported both Gnome and KDE, but I found FC4 had the cleanest install.

Also, I was very impressed by yum , which makes it very easy to automatically update software in a reasonably reliable way.

However, there were a few problems with FC4 and audio. For one thing, Jack wasn't well supported out-of-the-box. I really wanted to use Rosegarden as my Cubase replacement, but it had a tendency to lock up my system every time I shut it down (!). I couldn't get my MIDI interface to work (serial connection), and I couldn't find any way to debug the problem. Even just playing mp3 files was iffy--the playback would stutter when I refreshed pages in Firefox (!). CPU wasn't anything close to maxed out, but somehow xmms couldn't handle any other process interrupting it, no matter how briefly. To be fair to xmms, this was a symptom of problems with low-level audio code, not xmms itself.

After futzing around and attempting to debug for a few weeks, I decided enough was enough. I figured I'd try out some other distros to see if any supported audio any better.

 

How a Linux Audio Workstation should Work

Audio signals are continuous streams coming out of the computer, either audio or midi streams (or in my case, both).

You sometimes see people referring to the need for a realtime kernel, so that audio drivers can always pre-empt other processes. The idea is that giving audio processes high priority will help keep outgoing audio streams continuous. That's bogus.

Audio hardware handles the streaming for you. If a process on the machine wants to output audio, it sends out chunks of data to the audio hardware via the drivers. So the audio hardware buffers up outgoing data, and streams it continuously. It doesn't matter if processes on the machine get swapped in and out, and only get to talk to the hardware occasionally. When they do talk to the hardware, audio processes hand over enough data that the hardware can keep busy until the process is able to communicate again with more data.

Windows98 isn't a realtime operating system, and it did just fine. Winamp never stuttered when I was surfing with Firefox, and Cubase was able to stream audio and midi even when I had other processes going.

So a LAW should be able to keep outgoing audio and midi buffered, and applications should be written to keep those buffers full. You should never hear stuttering.

 

Lost in the Distro Wilderness

I posted for help on a few Linux forums. No one was able to help debug (or even send pointers to help debug) my midi problems, but everyone had distro suggestions.

Two Linux distributions in particular were pretty cool. These are projects where audio communities have attempted to put together very targeted releases, aimed at multimedia consumers.

One was Dynebolic , which had a great Live CD (that is, you could boot the distribution without having to install it). I have some funky graphics hardware, but Dynebolic did an okay job detecting my gear.

However, Dynebolic didn't do so well with my audio hardware, and midi still didn't work. It is a great concept, but I'm a Linux power user, and I needed more common linux tools instead of the stripped-down distro. I may come back to this distro later to see how they're doing.

The second distribution recommended was Demudi , based on the popular Debian distro. This was closer to the experience I wanted, and I recommend Demudi to other people looking for a good multimedia-focused Linux setup. The installation went fairly well, although I'm not a huge fan of Debian installs overall. I find their package chooser very non-intuitive, and more than once I've accidentally exited and found that Debian happily installed a core system without X or any development tools.

In fact, my chief complaint with Debian was that its streamlined install left out most development tools. The install went fine, and my hardware was properly detected. I was up and running with a functional Gnome environment in no time. But I was shocked to discover that cvs was not installed. Even worse, it was very difficult to install. Instead of yum, Debian uses a similar package manager called apt (Advanced Packaging Tool) . However, I couldn't find a way to get cvs installed via apt. I think it is either a package on its own, or part of a larger devel package, but "apt-get install cvs" would fail, and I couldn't find any development packages that contained cvs. I spent a lot of time tracking down apt repositories, but couldn't find one that supported cvs. Weird.

Another problem with Demudi is that it uses Gnome. Gnome isn't wildly different from KDE, but I couldn't find Konsole for Gnome. I use terminals a lot on Linux, and I've found Konsole to increase my productivity significantly. Once you use it, you can't go back to a lesser console.

There was one high point to Demudi (for me): it prominently featured qJackctl , which I hadn't played with before. Using Jack through Demudi started giving me a greater appreciation for how Jack could be used.

However, midi was still broken. I enjoyed the Demudi distro, but it hadn't gotten me any farther than where I was with FC4.

 

Back to Fedora Core 4

So I decided to return to FC4. I lost a day or two before I realized that my FC4 installation disk had gotten scratched (!). The first few installs failed (the machine would refuse to boot afterwards), and I mistakenly attributed it to a hard disk problem.

One side effect of that is that I installed some other distros I had, including SUSE . I had forgotten that SUSE also had a great setup. Clean install, and I really like their environments for runlevel 3 and 5. Runlevel 5 is just X-Windows (KDE for me), but they had a good layout. Runlevel 3 was wild, they had somehow gotten a graphical feel for the simple console interface.

I was considering sticking with SUSE, but their package management system is yast (Yet Another Setup Tool) , which I can't stand. I'm sure it does a serviceable job, but I find the UI a little constraining, and I never found a clean way to drive updates from the command line.

Once I discovered my FC4 install disk was corrupt, I quickly burned another and reinstalled. By this time I was a pro with installs, and managed to get a few things working better than the first pass.

Finally having the machine boot into FC4 and firing up KDE was surprisingly satisfying.

So now I am back where I started, although a little bit wiser and with more appreciation for Jack.

Next steps: get Jack working correctly, and then midi.

 

16 May

Quick update: I noticed that with my latest FC4 update, xmms plays much more sensibly. For instance, the stuttering has disappeared.

XMMS is happy again! XMMS is happy again!

I don't know why it's working now. I tweaked my yum repositories a bit, perhaps I picked up a better version of some critical package?

A few people have asked the very sensible question: why stick with Linux, if it apparently has so many problems with audio? Why not switch to a better supported OS like Windows or MacIntosh?

Fair questions. For now, I'm trying Linux because I'm most comfortable with it, and (most importantly) all of my home-built composition tools are Linux-based.

But I'll switch to Windows or try out a Mac if I don't get this working reasonably quickly.

At the moment I'm attempting to get the Planet CCRMA audio suite working.

 

20 May

I've been able to get most audio applications working with Jack. Again, Jack looks pretty stable and very useful.

I was able to get Hydrogen working. Like Jack, I had heard a lot of hype about that, and it was justified.

MIDI is still busted. I went out and bought a soundcard with a game port, so I could try that driver instead of the serial port. No love.

I have found several other people who have been completely blocked by MIDI support on Linux. My favorite post was this one , which was scary reading because I appear to be having the exact same problems. I'm not going to give up yet, though.

I certainly agree with one observation: the Linux MIDI how-to is not terribly helpful for beginners (even beginners with Linux + MIDI experience!).

I finally found some helpful debugging tools on the Gentoo Linux site .

Basically, you should

1) Use lspci to query PCI devices, and verify your cards are detected properly.

2) Verify your card has been initialized by ALSA. Do this by typing "cat /proc/asound/cards". You should see your cards listed.

3) Get the next level of detail on ALSA configuration. Type "cat /proc/asound/oss/sndstat". You should see a listing of drivers, cards, and audio devices (real and virtual).

This was my breakthrough for the day. Midi devices showed up clearly as "NOT ENABLED IN CONFIG."

I also don't have any midi devices listed in the devices under /dev. However, it is very difficult to tell if I should have any devices listed there. Some sites claim it is needed, while other sites seem to indicate that's an older midi configuration that isn't needed anymore. I'm not sure.

At the moment I've got some questions posted to a forum at LinuxQuestions.org , however it is mostly just me talking to myself.

 

21 May

Another tip: disable the KDE Sound System! Occasionally it would take control of the soundcard, and that would break any other application that was trying to use it (for instance, XMMS). [ To disable the KDE sound system: go to the Control Center on the start menu, click "Sound & Multimedia", then "Sound System". You'll see a big checkbox to enable/disable the KDE sound system. ]

Hopefully, KDE and Gnome are moving to Jack. All applications should share the audio resources.

 

30 May - Success!

After a long hiatus (weekends, and some simulations of galaxy formation which I'll post later) I returned to debugging my MIDI setup.

I did some more digging, and found two interesting sites.

The first was this one (midi-organ-net??) which indicated that I'd have to manually edit my kernel module file (/etc/modprobe.conf) and add a line to enable the game port. In my case, this was the line: "options snd-ymfpci mpu_port=0x330".

I correlated that with the documentation for the Yamaha driver at ALSA (go to SoundCards -> select your manufacturer -> find card, click Details link) and found that indeed, I'd have to add a line to enable the game port.

So I did, and rebooted. I ran "pmidi -l" and hooray!, my midi port was listed. I tried playing a midi file using "pmidi -p " and sure enough, midi events streamed out to my external synthesizer.

Unfortunately, the kernel crashed at this point :(

After some experimentation, I found that the realtime kernel from Planet CCRMA worked fine. All my other kernels would crash. The stack trace was always inside the mpu401 driver. So there is something funky with the midi port driver in non-realtime kernels.

But I didn't need to debug that any further (at least, not for now). I fired up Rosegarden and did some real multitracking! Streaming MIDI while recording/playing audio using JACK . I was able to stream midi events out to multiple external devices, and record digital audio.

So now I'm back to full Cubase functionality, only using Linux. This means I can use all of my custom audio tools locally on the same machine as my sequencer. Previously I'd had to copy files back and forth from my linux box to my Win98 machine.

I owe it to the community to write up some better MIDI documentation, which I will do as I learn more. But for now I am going to play with my audio workstation!

In the meantime, here is the shortlist of what I did:

1) Install Fedora Core 4

2) Install Planet CCRMA (using apt-get) (get Rosegarden, Jack, QJackCtl, Hydrogen, others)

3) Use the Planet CCRMA realtime kernel

4) Enable MIDI for game port by adding line to /etc/modprobe.conf

Step 4 may or may not be required for you, depending on your soundcard.