George's Unit Cube of CyberSpace

The MIDI Axis

Contents:

An Introduction to MIDI

This is a technical overview of the MIDI protocol, which (I hope) serves as a handy reference to midi messages and their meaning.

See: http://crystal.apana.org.au/ghansper/midi_introduction/preface.html An Introduction to MIDI


Linux MIDI driver for IBM-PC serial ports

What is it?

This is a low-level driver for the Linux sound driver. This driver enables a serial-port to be used like a MIDI device.

Such a driver is useful to you if you have any one of:

Multiple MIDI devices supported!

The driver allows multiple serial devices to be defined as midi-ports, which makes this a practical solution for supporting multiple simultaneous MIDI inputs and outputs.

Run out of IRQ's? - No Problem!

The driver is written specifically for 16450 and 16550A UARTs, and operates best when interrupt-driven. But interrupts are a scant resource on today's PC, so this driver supports interrupt sharing and polling.

The driver is capable of sharing interrupts between it's own devices and with other device-drivers. For this to work, both drivers must support interrupt sharing. Due to hardware limitations, interrupt sharing usually only works between PCI devices, or where the devices are physically on the same card. Interrupt-sharing works, provided your hardware supports it.

If no IRQ's are available, a polled-mode is also supported. This works surprisingly well for 16550A devices for both MIDI-out and MIDI-in.
For 16450 devices, polled-mode gives passable performance on MIDI-out, but MIDI-in suffers from continual overruns.

In short, if you've run out of IRQ's to use - get a serial card with a 16550A or two, and you'll never look back.

Auto-probing

The driver will auto-probe both the IRQ and the required UART divisor. All you need to know is the IO Base Address of your hardware.

Installation has never been simpler.

Download the driver and patches

The driver, plus a few necessary patches for Linux 2.4.x, 2.2.x and 2.0.x kernels are available from:

http://crystal.apana.org.au/ghansper/midi/uart16550_midi.4b.tar.gz
(25348 bytes)

Pre-compiled binary kernel module

It is strongly recommended that you download the source package, and recompile this driver from the source code, along with your current kernel. If, for some reason, you cannot do this, you can try using the pre-compiled module below.

uart16550_midi_241.o.gz pre-compiled module for Linux kernel 2.4.1 (4951 bytes)

To use the pre-compiled module (example only):

gunzip uart16550_midi_241.o.gz
cp uart16550_midi_241.o /lib/modules/2.4.1/kernel/drivers/sound/uart16550_midi.o
insmod soundcore
insmod sound
insmod uart16550_midi io1=0x2f8

This is intended as a fall-back solution only. Updates for this binary module will not be provided for newer versions of the Linux 2.4.x kernel.

Note that loading binary modules from the internet into your kernel is a security risk.

Old and obsolete versions of this driver

If you are using an older kernel (1.x.x), you might be interested in the older versions of this driver. See:

http://crystal.apana.org.au/ghansper/midi/obsolete_uart16550_midi.html

Licensing

This driver is distributed under the Artistic License (ie the same as Perl).

Want more information?

Check out the (html) installation and usage instructions at http://crystal.apana.org.au/ghansper/midi/uart16550_midi.html

sndstat.c - a replacement for /dev/sndstat

Linux kernels up to 2.2.x included a virtual device /dev/sndstat which gave some information about what sound and MIDI devices were detected and configured. This information was also available from /proc/sound in 2.2.x kernel

/dev/sndstat and /proc/sound were removed from 2.4.x kernels, largely because many of the newer sound-card device-drivers did not support it. Even so /dev/sndstat interface was (and is) useful if you have a sound-card which does support it.

Much of the information available from /dev/sndstat is also available through ioctl() calls. The program sndstat.c reproduces the /dev/sndstat information, as best as it can. Here is an example of output from sndstat -v

OSS/Free version 3.8.2

Config options: Unknown

Installed drivers:

Card config:

Audio devices:
0: Audio Device /dev/audio  signed-8/16bit unsigned-8/16bit little-endian
1: Audio Device /dev/audio1 u-Law signed-16bit unsigned-8bit little-endian Dolby

Detected 1 Synth device

Synth devices:
0: AWE32-0.4.4 (RAM8192k)
0: EMU8K

Detected 4 OSS MIDI devices

MIDI devices:
0: uart16550_midi 0x03e8
1: MIDI device /dev/midi01
2: Sound Blaster 16
3: AWE Midi Emu

Timers:
No information available

Mixer devices:
0: ESS Solo1
1: Sound Blaster

Note that the headings:

Config options:
Installed drivers: 
Card config: 
Timers:

Are purely cosmetic. There are no ioctl() calls corresponding to this information.

Notice MIDI device 1 does not contain a description. This is because this is a PCI device which does not support the necessary ioctl(). In this case, sndstat just confirms that there is a device at /dev/midi01

sndstat.c is included in uart16550_midi.4b.tar.gz. For those who just want sndstat.c, here it is as a stand-alone download.

sndstat.c.gz (2748 bytes) - source code
sndstat.gz (3793 bytes) - pre-compiled binary for linux 2.4.1 / Red Hat 6.2

To build sndstat from sndstat.c, use:

gcc -o sndstat sndstat.c

Midi-in-a-D-Shell Hardware project


v_midi driver for OSS/Free

The v_midi driver which is bundled with the Linux 2.2.x and 2.4.x kernels makes the uart16550_midi driver (above) superfluous.

The v_midi driver produces MIDI output, suitable for feeding to a sythesiser or sound-module, but instead of this coming out of some hardware device, it comes out at a /dev/midinn device-file.

If the above sentence doesn't make sense to you, try the following example:

The midi output is sent to your synthesiser through /dev/ttyS1 and you should hear the midi-file being played.

If you look at the output from sndstat you will see in particular:

Midi devices:
0: Loopback MIDI Port 1
1: Loopback MIDI Port 2

The playmidi command "plays" the midi device 0 (ie as specified by -D 0). Device 0 is a v_midi device. The midi-data appears in real-time at the other v_midi device, device 1 /dev/midi01

The cat command reads from /dev/midi01 and writes everything to /dev/ttyS1

In this fashion, you can send your real-time midi output to any device you choose, such as a serial-port (as in this example), a parallel port, a special program, or even an rsh command to another computer on your network. Let your imagination run wild!


KEYS XView Widget

This is an OpenLook XView widget for setting maximum/minimum key values for a (musical) keyboard.

[ snapshot of KEYS widget ]
Furthur details are on my XView-page: The XView Axis


References

Specification

Linux / Unix Specific

General MIDI-related web pages.


[ ] Return to index page.
Your comments are most welcome.
Last Modified: $Date: 2001/09/29 11:12:46 $
George Hansper George_Hansper@apana.org.au