[PD] midifile object

Frank Barknecht fbar at footils.org
Wed Jul 8 21:51:10 CEST 2009


Hallo,
Andres Ferrari hat gesagt: // Andres Ferrari wrote:

> the martin peach's object midifile has 3 outlets,
> 
> the first outlet output a list with 3 numbers:
> 
> xxx,note,velocity
> 
> what is xxx ???

[midifile] is pretty funky as is the [seq] object in Cyclone/Max: "xxx" is the
midi command byte that specifies how to interpret the rest of the list and the
channel. So your "note" and "velocity" need not be note and velocity, they
could also be cc-messages or pitchwheel data or whatever.

You can read up the midi spec somewhere on the web, but here's a quick
rundown: 

If "xxx" is between 128 and 143, the message is a noteon message. Substract
128 from "xxx" and you get the channel. Example: 

"140 80 100" would be a noteon message on channel 140-128=12 with pitch 80 and
velocity 100.

noteoff messages start at 144, CC messages use a midi command byte between 176
and 191, so a message "177 ..." would be a CC message on channel 1 (= 177-176)

This format is used both in [midifile] and in [seq], but seq gives the list as
a number sequence which is tricky to parse (except with [midiparse])


The rj library for the Pd vanilla as used in RjDj includes a [c_seqplay] object
that converts the textfiles which [seq] writes when opening a midi file and
saving it with a *.txt suffix to a [qlist] capable format and plays back these
files while tagging them according to the midi commands. So e.g. the message
"140 80 100" from above would be converted to "12 noteon 80 100" and send to
the outlet of c_seqplay. 

Here's what c_seqplay deals with:

144 + channel = note on;
128 + channel = note off;
176 + channel = cc;
192 + channel = pgm change;
224 + channel = pitch wheel;
160 + channel = polypressure;

All in all [c_seqplay] is a nice vanilla way to play back midi sequences,
provided you have access to a Pd with [seq] to convert the files to textfile in
advance.

If you want, you can grab the respective code from here:
http://trac.rjdj.me/browser/trunk/rjlib/rj


Ciao
-- 
Frank




More information about the Pd-list mailing list