MIDI pattern generator in Java. Generates rhythmic patterns based on the Euclidean algorithm.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Euclidean Pattern Generator v1.2

Code: This is a Java project made in Eclipse on Mac OS X. An Eclipse .launch file is included for easy setup. I used (Pure MVC)[www.puremvc.org] as the framework that holds it all together.


This application generates rhythmic loops; polyrhythms known as Euclidean rhythms. The rhythms can be sent as MIDI or OSC data to connected sound generators that will let you actually hear the rhythms. It's important to note that this application itself doesn't produce sound. Only MIDI and OSC data.

About Euclidean rhythms

Euclidean rhythms are polyrhythms generated by a mathematical formula. What this formula does is actually quite simple: It spreads a number of pulses as evenly as possible over a length of time, where time is divided in quantisized steps.

Sometimes this is very straightforward. 4 hits divided over 16 steps gives a basic house kick pattern (x...x...x...x...)

Other combinations produce world music rhythms; 3 hits divided over 8 steps creates a Cuban Tresillo (x..x..x.), 5 over 8 a Cuban Cinquillo (x.xx.xx.). And there's so many combinations possible many rhythms will never have been used before.

The algorithm was originally written by Eric Björklund of Los Alamos National Laboratory for a nuclear process where pulses of energy had to be distributed evenly over time. Later, Godfried Toussaint of McGill University in Montreal discovered that these patterns are the same as rhythms used in traditional music all over the world.

New in v1.2

Individual patterns can be muted and unmuted by external MIDI Note In and Note Out messages, so that a song arrangement can be created in an external MIDI sequencer or DAW and played back with the Euclidean Pattern Generator.


New in v1.1

The main new feature in this version is OSC (Open Sound Protocol) support. The OSC functionality was written by Michael L. Heuer, who kindly offered to collaborate.

OSC support added by Michael Heuer. Step duration (quantization) from 4 beats to 1/32 beat. Tempo maximum increased to 300 BPM. Pattern length up to 64 steps. Patterns can be named. 'All Notes Off' to kill hanging notes. New patterns start at velocity 10 (handy in live situations). Preferences automatically save last window location and size, OSC and MIDI port settings, last used project open or save directory.

Creating a pattern

In the main empty area of the application double click on the background. This creates a new default pattern.

A default pattern is 16 steps in length and has 4 played notes. On screen that's represented as the ring of 16 circles of which 4 are filled.

Drag the pattern's center circle to move it around the screen.

If there's more patterns on screen a click on the center selects that pattern for editing.

Pattern settings

Once a pattern is created or selected, it's settings are shown in the Settings panel on the right. The selected pattern displays a double centre circle.

Euclidean rhythm settings

Length: the length of the pattern in number of steps. The actual duration also depends on the step length (quantization) setting. Notes: The number of played notes. Length and Notes are the basic pattern settings. Each time one of them changes the algorithm is recalculated. Rotation: rotates the pattern. As you'll note when you play with the Length and Notes sliders, a basic pattern always starts with a note on the first step. To overcome this limitation you can rotate the pattern. The small zero at the top moves along with the pattern to indicate the original start point and a little flag appears on top as extra indication the pattern is rotated.

MIDI / OSC settings

This application generates MIDI notes and OSC messages. To hear actual sounds you'll have to connect it to some soft- or hardware that receives MIDI or OSC and translates it to audio. Channel: one of the sixteen channels a MIDI port has. The pattern will send it's data to the channel selected here. Pitch: one of the 128 note numbers in MIDI. For melodic sounds it's mostly used to transfer its pitch (in the note scale), for percussive sounds each note number is often a different percussion instrument sound. Velocity: a number from 0 to 127 that usually indicates the volume at which the note should be played. OSC Address: Text input to specify an address for the selected pattern so the receiving OSC application or machine can identify the pattern.

Other settings

Note length: the amount of time until the note is stopped. This is for now a number between 0 and 96, where 96 is one full measure (or 4 beats). The internal sequencer resolution of the application is 24 PPQN and this is the resolution that is used for the Note length slider. Step length: The quantization of the pattern. 1/16 is default, where each step lasts 1/16 of a 4/4 measure or ¼ beat. Step length goes from 1 (4 beats) to 1/32 (1/8 beat). Mute / Solo: Mutes or solos the pattern. Pattern name: When there's a lot of patterns things can get confusing, so here's an option to type a name for the pattern that appears underneath the pattern as well. Delete pattern: Click to delete the pattern. Note: no confirmation, no undo!

Playing a pattern

Click the Play button and you'll see the pattern play: The pointer rotates to indicate the position and steps jump out to indicate they're triggered.

If you just started the application it's likely however that you won't hear any sound. You first need to have a destination where the MIDI or OSC data can be sent to.


Send MIDI: To send MIDI the Send MIDI box must be checked. Once checked a MIDI Out port can be selected. MIDI Out Port: Use the MIDI Out combobox next to the Play and Tempo controls to select the appropriate MIDI port. Which one you choose depends on how you connected your software (probably through an internal MIDI port like MIDI Yoke on Windows or the IAC Bus on OSX) or hardware (likely with a USB to MIDI interface).

Tip: To quickly try out some patterns choose the Java Sound Synthesizer. This is a complete bank of (fairly low quality) General MIDI (GM) sounds, so you can immediately hear sounds without having to connect anything. Channel 10 has different percussion sounds on each key (MIDI pitch).


Send OSC: To send OSC the Send OSC box must be checked. Once checked an OSC port number can be selected. OSC Port: An application or machine that receives OSC messages has a receiving server that listens to messages on a certain port. In this input field you can specify the port number to which the OSC messages are sent.

Tempo in BPM

Use the slider or text input to change the playback speed. This is measured in Beats Per Minute (BPM).

All Notes Off

When editing patterns while they play, you will occasionally experience 'hanging notes'. This happens when a Note On message is sent to start a note, but no corresponding Note Off message is sent later to stop the note. Especially when you use a sustained sound, you will hear it continue indefinetely. Even when you stop playback.

This button sends an 'All Notes Off' MIDI message (CC #123) to all MIDI channels. Most applications and machines that receive MIDI will respond correctly and stop all playing notes.


You can save your patterns with their position and settings as a project file, which is in fact regular XML text file. A project includes the tempo in BPM as well.

To manage projects use the File menu. You'll find the familiar New, Open, Save and Save As options with their standard keyboard shortcuts.

Preferences Several settings are automatically stored and recalled the next time you open the application. Window size and position. MIDI enabled and MIDI Out port. OSC enabled and OSC port number. Last used project open or save directory.