Drums++ (Drum Beat Programming)

Posted: August 2003


Drums++ is a programming language I designed for sequencing music through drum machines. It uses simple C ideas, for example // and /* */ comments and { } to seperate sections. I tried to make it as simple as possible so even a non-programmer could use it. See the docs section for more info on the language. Drums++ can both directly control your MIDI device or it can create .mid files which can be played through programs such as Microsoft Media Player.

So you might wonder why I chose to do drum sequencing this way? Well, about 10 years ago I used to write drum sequences for my music using a program on my Amiga 500 called Dynamic Drums. Dynamic Drums is probably not a very powerful drum sequencing program, but it was so easy to use. I could write an entire song on that in about 10 minutes. The problem was the samples were very cheesy.

So anyway, a few years ago my friend sold me his old Dr. Rhythm drum machine, which had much better sounds, but it was so hard to write a song. I tried downloading some MIDI programs for Linux, but they were too complicated for an idiot like me. So I decided to write my own MIDI sequencing program strictly for drums :). I figured a GUI would take me longer to write than a parser for a new programming language, so this is why I chose to make Drums++. Eventually I plan to write a GUI in either Java or GTK/C.

Drums++ is based on the features of Dynamic Drums, the only difference is you don't click on a grid for where you want your beats, you type them in a text file. Eventually I might add new features to the language if they are requested.

Some examples where I used it for my music:

Mandelbrot Cluster
Playstation 2 Java
Nintendo 64 Java


drumsplusplus-0.96.tar.gz (source code, September 24, 2009) (Windows Binary, July 12, 2012)


Please note: Some of the .midi files here were made with old versions of Drums++ and may not work on all players. Newer versions of Drums++ make better .midi files

Date Drums++ File .midi file Author Notes
2003/08/31 features.dpp features.mid Michael A. Kohn This shows off some of the language features
2005/01/23 channels.dpp channels.mid Michael A. Kohn This shows off some of the language features
2003/09/03 test_include.dpp
test_include.mid Michael A. Kohn A stupid song demonstrating includes and many other instruments
2003/08/31 simple.dpp simple.mid Michael A. Kohn A very simple .dpp file to show how simple the language is


These commands will build a program called 'playdpp' which you will use to play your .dpp files or transform your .dpp files into MIDI files that can be played on any MIDI player.


Right now there are 3 command line options. If you type playdpp at the command prompt it will give you all it's options. Running playdpp will play your .dpp file to your MIDI sequencing device. Using the -o option, you can tell it to create a .midi file (which can be played through kmidi or Windows Media Player. The -i option will print on the screen which pattern/section is currently being outputed.

An example would be:

playdpp -o simple.mid simple.dpp

This will read in simple.dpp and create a .mid file called simple.mid based on it.

The Drums++ (.dpp) Language

The playdpp program reads files with the .dpp extension. This program will read in your Drums++ files and either play them through your MIDI sequencer (aka. into your drum machine/midi keyboard) or create .midi/.mid files which you can play through your computer. I created a simple.dpp file so you can see how a complete file looks like. I also created a .midi file of this .dpp (using the newest feature of playdpp).. err at least I think they are the same. Anyway, if you want to hear it click here. It probably sounds a lot better coming out of a real drum machine tho.

The first part of a .dpp file is the song settings. You must tell playdpp the beats per minute, default volume, drift (which I will explain later), and time signature. These must be set BEFORE the pattern sections that it affects. If you'd like a pattern to have different settings, you can redefine these before those sections.

set bpm=230; // set beats per minute to 230
set defaultvolume=127; // defaultvolume is between 0 and 255
set drift=5; // drift can make drum hits randomly a little louder or softer
set time_signature=4/4; // time signature sets the time signature
set midi_channel=9; // sets the default midi channel to 9 (which is the drum kit) if you do not set this setting, it will automatically use channel 9. Channels can be between 0 and 15 where each channel represents a different set of instruments. If you use something other than the percussion instruments, you can play a full scale of notes by replacing a drumkit instrument with a number representing a frequency where 60 is middle C and everthing below or above that a 1/2 step below or above (for example 61 would then be C#, 62 D, etc).

All 'set' commands end with ';'. Note the use of C style comments. If you have // on a line, everything after that is ignored. Also, anything between /* and */ is ignored. So something like this is totally valid:

set /* i'm a little teapot */ bpm = 230 ;

The next section is optional, but recommended. This is the 'defines' section. Here you can set names for your drum samples. This will make your code easier to read. For example, on my Dr. Rhythm, the kick drum is sample 36 and the snare is sample 38. So I would add lines like this:

define kickdrum 36
define snare 38

This way in my pattern sections instead of writing:

36: 1 3;

I could write instead:

kickdrum: 1 3;

Define lines do NOT have ; at the end.

The next section is the patterns section. All pattern sections start with the word 'pattern' and then the name of the pattern. A pattern can be either a word or number, or combination of words and numbers starting with a word. For example: fill1 is valid, but 1fill is not.

All patterns are written between { and } symbols. The text inbetween the { and } are written like this: <drum pad number>: <beats the drum is struck on>. So since I defined the snare drum as 38, if I want this pattern to play the snare on beats 2 and 4, I write it like this:

snare: 2 4;

If I wanted the kickdrum to be struck on beats 1, 1.5, and 3. I would add this:

kickdrum: 1 1.5 3;

If I wanted the volume of the kickdrum to louder than the default volume on beat 3, I can add a volume modifier (a : and a number between 0 and 255) like this:

kickdrum: 1 1.5 3:200;

Also, if I wanted the volume to be randomly different every time, I could put a % infront of the 200. This tells playdpp to pick a random number between 0 and what you set as the drift. Since I set the drift as 5, it will pick a random number between 0 and 5 and either add or subtract it from 200. It looks like this:

kickdrum: 1 1.5 3:%200;

Do not forget the ; at the end of each line. This lets the playdpp parser know when you are starting a new instrument. All together a pattern will look like this:

pattern test1
  bassdrum: 1 1.5 3;
  snare: 2 4:%200;
  highhat: 1:200 2 3;
  openhighhat: 4;

The sections take the same basic structure as the patterns do. After the word "section" you give it a section name, and then section data is placed between { and }. Section data consists of the word "play", the ':', and then the names of patterns you want to play separated by commas and ending in a semicolon. A section that plays fill2 twice and then pattern 1 once would look like this:

section b
  play: fill2, fill2, 1;

Finally, the song takes the same basic structure as section. The song name is optional. You may want to include it because when Drums++ is able to write out to .midi files, it will use this info. After the word play: you can tell Drums++ to play either single patterns separated by commas or sections separated by commas, or a combination. Here's an example of a song section:

song test_song
  play: test, test, test, a, 1, 1, 1, b, 1, 1, fill2;

Another useful feature of the Drums++ language is i the song and section parts, you can tell it to play a pattern or section a multiple number of times. For example:

song test_song
  play: 2 test, a, b, 2a;

This will tell Drums++ that within' the song "test_song", the pattern (or section) test will be played twice, then play section a, then b, then play pattern (or section) a twice.

More Advanced Stuff

At the start of each pattern section you are allowed to change some of the default settings such as bmp, time signature, and midi_channel. If you put a set at the top of the pattern, this setting will only be valid for this pattern. You can see an example of it in the channels.dpp example.

You will also notice in this example a line that looks like this:

60/2: 1 3;

This tells the drums++ parser to play a note 60 (middle C) on channel 2 (piano?) on beats 1 and 3. You can use this to make rhythm melodies with other instruments. Probably not the easiest thing to do with drums++, but it is possible and probably usefull in some ways.

Copyright 1997-2024 - Michael Kohn