Subject: More questions about /dev/music behaviour
To: <tech-kern@netbsd.org>
From: Gavan Fantom <gavan@coolfactor.org>
List: tech-kern
Date: 01/31/2001 11:41:34
In sequencer.c, lines 732-735 (in version 1.15):

        if (cmd == MIDI_NOTE_ON && parm == 0) {
                cmd = MIDI_NOTE_OFF;
                parm = MIDI_HALF_VEL;
        }

What is the reason that we want to do this? Does OSS do this?

Wouldn't it make more sense to do this further down the line when we know
whether the previous MIDI command sent was a Note On on the same channel?
It seems a bit odd to me that we should be removing any chance of an
optimisation that the application intended and is in widespread use in
MIDI hardware.



MIDI background:

MIDI is a serial interface, running at 31.25kbps. Commands typically
consist of a "status" byte, followed by 0-2 "data" bytes (this number
being fixed for a given status byte). A status byte always has the top bit
set, and a data byte always has the top bit clear. If the same status byte
is to be sent twice, the status byte may be omitted the second time. So,
the data stream could look like:

  status data data (implicit status, not sent) data data (implicit status)
  data data .........

This is called "Running Status".

For commands such as Note On and Note Off, the status byte contains the
command in the top few bits, and the channel number in the lower 4 bits,
so that consecutive Note On commands on the same channel (or consecutive
Note Off commands, for that matter) would have the same status byte.

The first data byte for a Note On command is the note to turn on. 60
represents middle C, and each unit increase represents a semitone. The
second data byte is the Note On Velocity, which represents (in terms of a
keyboard) how fast the key was moving. The vast majority of synthesizers
use this to determine the volume at which to play the note, and many of
the better ones also change the timbre in subtle ways based on this
parameter.

The same parameters are given for the Note Off command, although most
sythesizers ignore the Velocity and most keyboards don't measure it.

It is common practise to transmit Note Off commands as a Note On with zero
velocity. Many keyboards do it, and I've yet to see a synthesizer that
doesn't understand this.

-- 
Gillette - the best a man can forget