Chord module? And some drum programming examples.

[email protected] (The Danimal) Wed, 17 Oct 2001 15:29:05 -0400
Newsgroups perl.midi
Organization Danimal Planet
Message-ID <[email protected]>
Dear all,

1. MIDI-Perl is great.

2. Has anyone written a module/filter/subroutine/etc. that
can accept a list of chord symbols (in some suitable "standard"
notation), timing info, etc., and render them into a MIDI track?
It would be nice to have Perl code that works to some degree 
like PG Music's Band-In-A-Box product. However, it would take a
lot of Perl code to do everything that Band-In-A-Box can do.

3. I've written some code that lets me specify drum arrangements
for a song in (what to me seems like) a somewhat logical way.
Books on drum programming (such as _Drum Programming_ by Ray Badness)
represent drum tracks as patterns of (usually) 1, 2, or 4 measures,
using either musical staff notation or a grid notation. Grid notation
is easy to translate into ASCII and is therefore convenient for using
with MIDI-Perl. Drum arrangements for a typical rock/pop/blues/etc.
song contain a lot of repetition, so they are convenient to represent 
with a chart that assigns drum patterns (by number) to measures.

If anyone is interested, here is some sample code:

a. http://www.mfm.com/~dmocsny/songs/perl/badness_drums.pl
   A script which programs all the drum patterns from Ray Badness'
   book (see the program comments for a complete citation). 
   The script generates two .MID files. The first file
   plays each pattern twice, with a measure of rest between each
   pattern. The second file is the sample song from the book (drums
   only). I hope this does not violate the book's copyright.

b. http://www.mfm.com/~dmocsny/songs/perl/renderdrums.pm
   A module which takes the arrangement chart from a script
   such as badness_drums.pl and renders it into MIDI. The
   module also contains code that can rearrange drum patterns
   from the DrumTrax library (a commercial product you would need
   to buy if you want to use that capability). 

c. http://www.mfm.com/~dmocsny/songs/perl/petegunn2.pl
   This script generates the petegunndrumtrack2.mid file
   (see below). This is a drum track I composed for my
   cover of Emerson, Lake, and Palmer's cover of 
   The Theme From Peter Gunn (you can hear the ELP version 
   on their 1974 live album). I have an MP3 file of my 
   version with programmed drums and live-played keyboard 
   here:   
   http://www.mfm.com/~dmocsny/mp3/Petegu41.mp3  
   I originally put together the drum track in a sequencer
   program. Later, after I discovered MIDI-Perl, I tried
   re-implementing the drum track in Perl code. To have any hope 
   of running petegunn2.pl as is, however, you would have to buy 
   the DrumTrax library, since I use drum fill measures from it. 
   Alternatively, you could edit the arrangement list in petegunn2.pl 
   to use your own hand-scored fill measures (for example, by 
   copying some from badness_drums.pl).

To run these scripts on your computer, you will have to
edit the file paths they contain (especially because I have
been running them under Windoze). I haven't edited these
scripts with portability in mind, and I haven't documented them
beyond the comments I put in them. Also, I haven't cleaned 
up relic code, mistakes in the comments, etc.

d. http://www.mfm.com/~dmocsny/songs/perl/midifiles.zip
   A zipfile containing some MIDI files I generated with
   the above scripts. Sorry, my Web server's mime.types file
   doesn't support MIDI yet, so I had to put the MIDI files
   in a .zip so you can download them.

% unzip -l midifiles.zip
Archive:  midifiles.zip
 Length    Date    Time    Name
 ------    ----    ----    ----
  15983  10-09-101  13:29   petegunndrumtrack.mid
  15976  10-14-101  18:21   petegunndrumtrack2.mid
  17896  10-14-101  18:21   ray_badness_drum_patterns.mid
  13773  10-14-101  18:21   ray_badness_sample_song.mid
 ------                    -------
  63628                    4 files

I welcome any comments/ridicule/flames/advice/dismissive sighs/etc. 
I don't pretend to have coded to any sort of state-of-the-art or
best practice. I'm just stumbling my way to the first things
that work. I don't whether I'm doing anything the "right" way, 
the "best" way, or the way anybody else would do it. I had some 
problems with MIDI-Perl but I found all the information I needed 
by carefully rereading Sean's manuals and by reading messages on 
this newsgroup. However, I can't say I fully understood everything 
I ended up needing to do.

4. Sean, are you going to write a book on MIDI-Perl?

-- Daniel Mocsny