Earth Operations Central

ALSA, SoundBlaster Live! Platinum 5.1, and External MIDI Devices

Recently, I bought a Yamaha PSR-280 Portable Keyboard with MIDI capability. It's a nice little 61-key set, with all sorts of features such as a tutorial program built right in, but mostly it has very nice speakers and voices including the General MIDI voices as well as some voices which are apparently proprietary to Yamaha. In any case, it plays very nicely and sounds great!

But how can I get it to talk to my Linux box?

First off, I was running with an Ensonic ES1371 soundcard with support compiled directly into the kernel and while that was perfectly good for playing MP3s through XMMS, I was never able to get the joystick port to talk to external MIDI devices.

Clearly I needed a new soundcard! But what would be a good one?

Looking through the Linux SOUND-HOWTO files once again, and through assorted documentation and across probably dozens of webpages, I came to the conclusion that possibly the best-supported soundcards for Linux were the Creative SoundBlaster cards. I whipped out the ol' debit card, logged onto the Creative SoundBlaster website and placed an order. A week or so later, the packages came through UPS and I cheerfully unpaked it and installed it in the Linux box.

The Creative SoundBlaster Platinum Live! 5.1 (with Live! Drive) is a multi-part sound card. It requires an available full-width (5-1/4 inch) drive bay for the Live! Drive, which is a panel containing a lot of connectors and knobs. The card attached to the Live! Drive is the same size as your average IDE harddrive. It connects to the rest of the soundcard, which is mounted in the usual place. See the enclosed installation instructions for details! Getting the hardware into place isn't too difficult -- if you've ever installed a harddrive it requires about the same level of skill.

Of course, once you've got the hardware installed, getting your Linux box to deal with it isn't all that easy. The large number of CDs that come with the hardware reportedly provide wonderful Windows-9x-based software but if you're running Linux, only the SoundFont CD will be of much use to you. If you don't need to control external MIDI, try looking at the excellent and helpful Creative Opensource site -- they have been kind enough to open up some of their code base and API to the OpenSource and GPL community.

But you say you want to control external MIDI, as I do?

There's nothing for it then but to get the ALSA drivers.

I used the ALSA (Advanced Linux Sound Architecture) drivers and utilities that will be built from alsa-driver-0.5.9d.tar.gz, alsa-lib-0.5.9.tar.gz and alsa-utils-0.5.9b.tar.gz -- built in that order. It is essential to rebuild your kernel first!

When you rebuild your kernel, rebuild it with no sound options compiled in, but be sure to enable sound support only as a module. I had no success with the ALSA drivers building with the soundcard support built in directly.

I won't cover any of the detail of building the kernel, that is covered adequately in many other places, notably in the README file that comes with the kernel sources.

Once you have built, installed, and rebooted to the new kernel, be sure that you have loaded the sound module (try `insmod sound` and `insmod soundcore`) before building the ALSA drivers. Check your configure options when you build the drivers. Try:

./configure --with-moddir="/path/to/where/you/want/them" \ --with-isapnp=auto --with-sequencer=yes --with-oss=yes --with-cards=emu10k1

(May I suggest that the ALSA drivers might be best installed in /lib/modules/current/alsa-sound -- perhaps you should create that directory? Also, /lib/modules/current ought to be a symbolic link to the subdirectory for your new kernel version. I have only actually tested this for kernel 2.2.17)

This should compile your ALSA drivers properly. You must have the sequencer support turned on and I'd suggest that you build only or the specific card you'll be using, and the Creative SoundBlaster Live! Platinum 5.1 with Live! Drive uses the EMU10K1 chip.

Do the `make ; make install` thing with the ALSA drivers, and also build the ALSA libs with a `./configure ; make ; make install` and then go on to build and install the ALSA utilities with `./configure ; make ; make install`.

Now reboot to the new kernel once again, which should among other things build up the new module dependencies. Now, purists will hate me for this, but one way to force the modules to all load without driving yourself mad by trying to load the modules one at a time is as follows:

cd /lib/modules/current/wherever-you-configured-ALSA-to-install insmod isapnp for i in `ls` do insmod $i done

This will cause at least one of the modules to load, and you will also get a screen full of error messages about unresolved symbols and that sort of thing. So do the part with the `for i in foo bar blah done` again, and again, probably about five or so times; and the last time you do it you probably won't see any error messages other than something to the effect of "a module named already exists". Then type `lsmod` and you'll get a big listing of all of the loaded modules. There should be quite a list. Now you're ready to try to get your ALSA drivers to talk to your software; if they're loaded, they're already talking to the kernel.

Now of course you're wondering what software to use!

But first, save yourself a headache and ponder the hardware issues.

If your software cannot see the external MIDI device, you may -- as I did -- drive yourself half mad wondering what is going on, and you will be forced to write all sorts of letters to various software authors and possibly to hardware vendors, driving the recipients also to the brink of madness and distracting them from important work.

First, you should have run the "snddevices" script in the alsa-drivers build directory. If you didn't, go back and do it now. Also, you may find it necessary to create any of the following devices that weren't created: Here's a list for you.

lrwxrwxrwx 1 root root 10 Dec 1 10:13 /dev/midi -> /dev/midi0 crw-rw-rw- 1 root root 14, 2 Dec 1 10:13 /dev/midi0 lrwxrwxrwx 1 root root 10 Dec 2 16:38 /dev/midi00 -> /dev/midi0 lrwxrwxrwx 1 root root 10 Dec 2 17:02 /dev/midi01 -> /dev/midi1 lrwxrwxrwx 1 root root 10 Dec 2 17:02 /dev/midi02 -> /dev/midi2 lrwxrwxrwx 1 root root 10 Dec 2 17:03 /dev/midi03 -> /dev/midi3 crw-rw-rw- 1 root root 14, 18 Dec 1 10:13 /dev/midi1 crw-rw-rw- 1 root root 14, 34 Dec 1 10:13 /dev/midi2 crw-rw-rw- 1 root root 14, 50 Dec 1 10:13 /dev/midi3

Let me tell you what happened to me: I did all of the above, and using a commercially-available cable which has a joystick port on one end and which splits into two cables, one MIDI-out and one MIDI-in, and using Steve Ratcliffe's excellent little program "pmidi", I couldn't get a sound out of the external synth while trying to play a "known to work" MIDI file.

But the Live!Drive has a MIDI-in and a MIDI-out port, as well as the joystick port on the soundcard on the back of the machine. Hooking the external synth MIDI-in to the Live!Drive MIDI-out and the external synth MIDI-out to the Live!Drive MIDI-in, I was able to get the external synth to play a MIDI file! I used:

pmidi -p 64:0 midi.mid

However, try as I might, I could not get the external synth, which was advertised by Yamaha as forwarding MIDI data through the MIDI-out port by default, to register MIDI output with any of the MIDI programs I was using.

The ALSA packages come with a handy little tool called "aconnect" -- and if you try `aconnect -i` it should list all input ports for the soundcard. If you try `aconnect -o` it should list all output ports. But how to read the ports? I sent a piece of mail, shamelessly begging for clues and pointers, to Steve Ratcliffe, the author of "pmidi" and other MIDI software, and he had this to say, in part:

OK, well here is a few things to try, just to see if anything is going on
at all.

The first thing to try is to see if you can read from the midi device
files.  Make sure there are no sequencer applications running and call
'aconnect -x' to remove any connections.  Then try

        dd if=/dev/snd/midiC0D0 bs=1

The device may have a difference name on different versions of ALSA, but
you are looking for something like midi0.  These are also in
/proc/asound/dev if the /dev/snd link is not set up.

You should see a stream of random looking characters as you press keys
on your Yamaha.  Also the number on the EMU10K1 line in /proc/interrupts
should be increasing.

Well, none of this was happening. He also included a little program called mr.c to try, should any of the above actually work. But it wasn't working.

After a few days of moping gloomily and writing assorted letters to Yamaha querying whether or not the PSR-280 actually did send MIDI by default, I woke up with the idea of seeing if any of this would work with the split-cable attached to the joystick port on the sound card in the back of the machine. It didn't play anything, still. But as long as I had it attached, I figured I might as well see if the above-mentioned `dd if=/dev/snd/midiC0D0 bs=1` would actually work. Lo and behold, it did! I compiled the little mr.c program and ran it, and got output in the "MDML" markup language, which did appear to be appropriate to the keys I as pressing on the Yamaha synth.

So, I conclude, and perhaps you'll have the same luck, that you must send MIDI-out from the synth into the SoundBlaster Live! Platinum 5.1 via the joystick port in the back of the machine, and you must send MIDI-in to the synth from the MIDI-out port on the Live! Drive front panel.

And now to test it, I used the excellent Jazz++ MIDI handler, and recorded a track, and played it back! Woohoo! It works! Thanks Steve Ratcliffe and all of the other fine folks writing the ALSA drivers and software that uses it, not to mention the Creative folks, for making the SoundBlaster Live! 5.1 Platinum with Live!Drive.


Go to the Business MetaIndex Page.
Visit the Computing MetaIndex Page.
Visit the Sciences MetaIndex Page.
Visit the Earth Operations Central District Office. Try a Glimpse HTTP Search (searches HTML content).
Go back to the main EarthOps Homepage.