Subject: [linux-audio-dev] hardcoding device filenames, was Re: some basic sound questions
From: David Slomin (dgslomin_AT_princeton.edu)
Date: pe marras 13 1998 - 03:18:51 EST
On Fri, 13 Nov 1998, Paul Winkler wrote:
> Nearly all audio developers seem
> to hard-code /dev/dsp into the app. Boo! People, please don't do this!!
> OSS-Linux provides multiple /dev/dsp's, and I believe 2.1 kernels do
> this as well. It won't matter if we have no applications that can use
I've been running up against this problem as well with MIDI. Yes, there are
admittedly few MIDI applications out their for Linux (by this I mean ones that
access external MIDI devices rather than the on-board synth), but I have yet to
find a single player, sequencer, etc. that will let me specify an alternative
to /dev/midi. For that matter, the screwy command line based playmidi is the
only player I can get to output to my external synth at all.
The reason I care about this, besides the fact that I really do have two
MIDI cards in my machine (generic SoundBlaster and an old but great MPU-401),
is that I've been working on a set of small MIDI filter apps for Linux.
Anyone who's read my NetMIDI proposal will recognise these as some of the
things I wanted to write which I thought needed a new system like NetMIDI
or the ALSA Sequencer Core to implement. It turns out, I can acheive the
same effect using generic OSS/free sending MIDI messages through standard
Unix pipes instead of over sockets (the basis of NetMIDI). Unlike NetMIDI,
this requires zero infrastructure, and is not vaporware... I already have it
working very nicely.
I currently have a filter which does transposing and one which does automatic
chording by adding fixed intervals, and am working on one which adds echo
and another which simulates sustenuto when triggered by the sustain pedal.
In case the description is a bit fuzzy (Unix pipes and MIDI, huh?), maybe an
example will help clarify the situation.
div_AT_meerkat> mkfifo fifo
div_AT_meerkat> rw /dev/midi fifo - | transpose - fifo 12
The fifo (named pipe... look it up; nobody ever uses them, but they're cool
and a standard part of Linux) is needed because our pipe chain effectively
goes in a circle: rw outputs to transpose which outputs to rw.
rw is a utility I wrote which opens a file for both reading and writing (here,
/dev/midi), and attaches each to a separate file or stream (here, the fifo for
reading, and stdout for writing). This is necessary because OSS only allows
/dev/midi to be opened once, even if one process only wants it for reading and
another only for writing.
transpose is the midi filter which reads midi messages from the first specified
file or stream (here, stdin), changes the pitches by a specified interval
(here, 12 chromatic steps, one octave up) and writes them to the second file or
stream (here, the fifo).
Of course, you can put multiple filters in a row, and by creative use of
the conventional tee program, put branches in your MIDI flowgraph. I'm
also planning to write a simple converger utility (necessarily MIDI specific)
that combines two or more branches back together. In my testing so far,
latency has not been a problem (and this, of course is the most important
advantage over NetMIDI).
Back to the original point of the message. I'd love to use a conventional MIDI
file player and tell it to write to one of my fifos instead of /dev/midi.
That way I could transpose any MIDI file on the fly or perform any of these
other operations. Hopefully, other programmers of future MIDI apps for Linux
-- yes, all three of you! :-) -- will keep this in mind.
Oh yes, I'll put up a web page and download package for these things when
I've cleaned them up a bit more, or sooner if anybody on the list asks me.
Using the same techniques as these MIDI filters, I'm also writing a fun toy
that lets you use a MIDI keyboard as a chording text keyboard that works with
X windows. I'll put this up on the page then too, packaged separately.
-- ("`-''-/").___..--''"`-._ David G. Slomin `6_ 6 ) `-. ( ).`-.__.`) mailto:dgslomin_AT_alumni.princeton.edu (_Y_.)' ._ ) `._ `. ``-..-' http://www.cs.princeton.edu/~dgslomin _..`--'_..-_/ /--'_.' ,' (il),-'' (li),' ((!.-'
This archive was generated by hypermail 2b28 : ma maalis 13 2000 - 12:05:16 EST