Workshops In Creative Coding Project: Drum Machine


The creative goal of this project initially was to create a software emulator of an Elektron Machinedrum.

The 16-step programmable interface is a legacy from earlier hardware drum machines, for a history of the development of the drum machine check out this Wikipedia article.

While I have not replicated the user interface of the Machinedrum, I did manage to find samples of the sounds from it, these are included in the zip file containing the application and source code, found here.

The technical goal of the project was to further my knowledge of Max and OpenFrameworks/C++.


Before you get started it would probably be a good idea to watch this demonstration video to get an idea of the general operation;

To get started open the “Start Machinedrum” application, this will launch both “MaxMachinedrum” and “OFMachinedrum”, make sure to wait until they are both open.

Here’s what the user interface looks like;

Now drag and drop a sound file from the “Drum Sound Samples” folder into one of the “Drop sample here” boxes in the “OFMachinedrum” window. The first 10 rows are quantised, rhythms are programmed into these rows by activating the cells by clicking on them (yellow/green cells are active, blue/red cells are inactive). A random sequence can be generated in one of these rows by clicking on one of the “Make random sequence” buttons.

The other 6 rows are for non-quantised sequences, to input a sequence in one of these rows drag and drop a sample into the appropriate ‘Drop sample here’ box and then tap out the sequence with one of the keys 1 to 6. Non-quantised drum triggers can also be set by clicking anywhere in one of the 6 non-quantised rows, and a single non-quantised trigger can be removed at any time by clicking on it.

To reset a row, click on the “Reset row” button to the left of the row. To remove a sample, click on the “Clear sample” button to the right of the row. If you drop a sample into a box which already has a sample in, the old sample will be replaced. The “Reset all rows” and “Clear all samples” buttons do exactly what they say on the tin.

If you’ve found a rhythm sequence that you like, you can save it in one of the 13 sequence banks at the bottom of the screen, click on the top (purple) half of the box to save the sequence, and the bottom half to retrieve it. The sequence banks can be cleared by clicking on the “Clear all saved sequences” button. Here is a demonstration of recalling multiple patterns;

(Note: There is but one mysterious problem with the drum machines functionality, this regards the retrieval of sequences. You can see this a bit towards the end of this video. Sometimes the retrieve sequence button needs to be hit multiple times for the sounds to be retrieved, other times it works fine. Sometimes the sounds will disappear if the retrieve button is hit again. This remains an unresolved issue.)

The ‘s’ key starts and stops the drum machine, and the up and down arrow keys change the tempo respectively. The tempo is displayed at the bottom of the last row in quarter sequences per minute, a generic house track for example will play at around 120-130 quarter sequences per minute.

I hope you enjoy playing with it as much as I enjoyed making it!

Techniques Used

Max 6 and OpenFrameworks, were used. Max handles the audio processing and communicates with the interface built with OpenFrameworks using the User Datagram Protocol (UDP) for Open Sound Control (OSC) messages.

Max patch in edit mode;

Max patch in edit mode

At the top left hand corner of the Max patch is found the [phasor~] object, this can be seen as the driving force of the whole drum machine. Just to the right of the [phasor~] is a matrix of 10 rows and 16 columns;


The pattern information is fed from the OpenFrameworks interface via OSC messages coming into the [p Row Info] subpatch shown here;


The random rows are generated by the [p Random Row Generator] to the top right of the matrix.

The matrix stores pattern information and feeds this to an array of toggles inside the [p Row 1 Drums] to [p Row 10 Drums] sub-patches, here is an expanded view of one of these sub-patches;


The non-quantised beats are triggered by the [p Non-Quantised Row 1] to [p Non-Quantised Row 6] sub-patches, here is an expanded view of one of these sub-patches;


Here the non-quantised trigger information is stored in the [coll], this is given the messages “sort”, “renumber” and “dump” in that order at the start of every 16-step sequence. This is important as it keeps the triggers and their corresponding indices in the correct (ascending) order.

There’s quite a few interesting little features in the Max patch, as well as the OpenFrameworks C++ code so please have a look around the source code files. They are all in the Creative Coding from;

Ideas for further work and improvements

The technical knowledge of these creative coding tools that I have gained via this project should be useful when it comes to my final Masters project. In particular having now had experience of getting Max and OpenFrameworks to communicate with each other using OSC messages will open up a myriad of possibilities for project ideas.

With regards to the drum machine project itself, the application could be extended by adding sampling capabilities, or sound manipulation and effects of various forms. One simple idea that I thought of too late is to synchronise the fade-out of the colour interface when it is stopped with a pitch-drop on the sounds. I have found this ( Max for Live device that emulates the pitch drop on a vinyl record when it is stopped. The Max patch behind it looks like this;


The aforementioned issue with regards to retrieving saved patterns is one that certainly needs addressing.


– The following OpenFrameworks example projects were used for inspiration/manipulated/adulterated/ripped off; oscReceiveExample, oscSenderExample, dragDropExample.

– Thanks to Elektron (

Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *