Creating Rhythms - cover image

Creating Rhythms


Below are the C programs that accompany the book, Creating Rhythms. You can download each as you need it, or all of them bundled into a zip file.

This software is free and distributed under the terms of the GNU General Public License. It is written in ANSI C and should compile with any C compiler. If you have questions or comments contact: Stefan (stefan at exstrom dot com) or Richard (richard at exstrom dot com).

Converting Binary Rhythms to MIDI

Here is a quick way to make a midi file, given rhythms in binary notation.

Let's say you want to hear the following two instrument binary rhythm set:

1111010110010000   Low Bongo
1000011110101100   High Bongo

Our procedure is to first convert the binary rhythm set to abc notation, then convert the resulting abc file to MIDI. To go from the binary rhythm set to abc notation we use our program bdrum.c which reads a binary rhythm definition file and sends the equivalent abc notation to standard output. In our example above, the input binary rhythm definition file would look like the following:

480 16 2
61 1111010110010000
60 1000011110101100

where 480 is the tempo (notes/minute), 16 is the number of notes per rhythm, 2 is the number of rhythms, 61 is the MIDI percussion instrument number for low bongo, and 60 is high bongo. So if our binary rhythm definition file is called b1.bdf then we run bdrum as follows:

./bdrum b1.bdf 4

where the number 4 specifies that the rhythm set is repeated 4 times. The result is an abc notation file that can be converted to MIDI with the program abc2midi (part of the abcMIDI package). The resulting MIDI file can be played by a program like TiMidity. You can listen to the above example here. All this can be done in one command line as follows:

./bdrum b1.bdf 4 >;abc2midi -o b1.mid;timidity -in b1.mid

Note the above command line works in the bash shell. In Linux and Mac OS X it should work with no problem (bash is the default shell in most Linux distros and OS X). On windows, you can get the bash shell by installing MinGW or Cygwin.

Send comments to: Richard Hollos (richard[AT]exstrom DOT com)
Copyright 2019 by Exstrom Laboratories LLC