💾 Archived View for thrig.me › music › midi captured on 2024-03-21 at 15:29:31. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-02-05)
-=-=-=-=-=-=-
MIDI reference information gleaned from elsewhere. Not all MIDI devices nor SoundFont files honor the conventions that follow: drum placements might be mixed up or different, and some SoundFont do not put the drums on channel 9/bank 128/program 0, or may have weird or incomplete instrument lists. However the following are probably a good starting point.
a very small MIDI writer library for Common LISP
The drum channel is usually 9 (counting from 0; musicians tend to count from 1 so under that scheme the drums are on 10, but in the protocol it's 9). A conventional drumtrack might involve a bass drum, high-hat, and hand clap, which may involve MIDI pitch 36, 44, and 39. However 44 was pretty inaudible on the SoundFonts I tried, so I switched that to 42. The velocities of the various parts may need better balancing. YMMV.
With the Perl MIDI module installed, MIDI files can be inspected by using the "dump tracks" option.
#!/usr/bin/env perl use MIDI; my $file = shift; die "Usage: dump.pl midi-file\n" unless defined $file; MIDI::Opus->new( { from_file => $file } ) ->dump( { dump_tracks => 1 } );
With a MIDI cable (or probably USB these days) one can throw numbers at a synth. The MIDI protocol is pretty simple (it was designed for not too complicated devices back in the 1980s) though I have no idea how complicated the modern MIDI 2.0 or whatever has become.
An important script may be to shut the synthesizer up, in the (likely) event code you wrote had an error. This script is for OpenBSD, but other operating systems that offer a MIDI device you can print bytes to should be pretty similar.