Oct 2017 | software

IrRegular Beat Generator

A Python command-line application which generates midi drumbeats in exotic time signatures. You choose a BPM, time signature and the density of drumhits and it generates a beat!

The application allows you to input various parameters like BPM, time signature and the drumkit used to preview the generated drumbeat. These drumbeats can then be exported as midi files to be used in your favorite DAW!

The algorithm which generates the beat works like this:

Before generation

Before the algorithm can begin, it first has to now certain things.

  • Which drumkit is used to preview the beats (this does not affect beat generation)
  • How many triggers long is the beat?
  • How many of those triggers fit in one quarter note?
  • At what BPM will the beat be generated?

Finding the 'important beats'

The algorithm will first decide which hits are important to ensure the beat actually feels like a beat. It does this by choosing one of tree options from the correct row. The result of that is then shuffled.

4 2,2 - -
5 3,2 - -
6 3,3 2,2,2 -
7 3,2,2 3,3,1 -
8 3,3,2 4,4 4,2,2
9 3,3,3 3,2,2,2 4,3,2
10 3,3,2,2 4,4,2 4,3,3
11 3,3,3,2 3,2,2,2,2 4,3,2,2
12 3,3,3,3 4,4,4 4,3,3,2

Let's say the algorithm chooses [3,2,2] because we chose 7 triggers per measure. This will result in an rhythm consisting of the following triggers:

1 2 3 4 5 6 7
x - - x - x -

Now if we shuffle the results the following variations can be made:

1 2 3 4 5 6 7 triggers
x - - x - x - 3 2 2
x - x - - x - 2 3 2
x - x - x - - 2 2 3

Assigning the 'important beats'

Now that we've selected the important beats they are distributed over the kick and snare drum sequences using the following chances:

Chance Assigned to
40% Kick
40% Snare
20% Both kick and snare

Fine tuning the results

Before generating the hihats it goes through a few more actions:

  • Add a kick at the first beat.
  • Remove any snares from the first beat.
  • Check if there are any snares at all
    • Insert a snare at the last important beat if no snares are found
  • Insert a random kick after each kick that was not preceded by another kick.

Generate the hihats

The algorithm will now generate the hihats by either:

  • randomly adding a hihat or kick after each trigger without kick or snare
  • adding a hihat after each trigger with a snare


Now that generation is done the beat will start playing using the built-in drumkits. The user has options to regenerate, write to midi or change generation parameters.

The source code can be found on GitHub