Create your own drumming machine using the machine learning software Wekinator and the programming language ChucK.

In this article, you are going to learn about how to make a drumming machine using ChucK and Wekinator software. If you are new to ChucK, it is a programming language for real-time sound synthesis and music creation, created by Ge Wang and Perry R. Cook at the Princeton Sound Lab. It is open-source and available for free on MacOS X, Windows, and Linux.

Wekinator is a free, open source software. It allows its users to harness machine learning capabilities to build new musical instruments, gestural game controllers, face recognition, computer vision or listening systems, and more.

Wekinator allows users to build new interactive systems by demonstrating human actions and computer responses rather than writing programming code.

We will process inputs through Wekinator and use the on-screen slider example to send the values of the x and y coordinates. Wekinator will be trained according to the samples we send through processing and it will give the output to ChucK and music will play.

Wekinator Processing Sketch

The processing sketch for this project is available on Wekinator’s example page.

Download the processing sketch “Simple Mouse Dragged Object” from there. Unzip the file and run the sketch in processing. This sketch will give the input to Wekinator. 

The value of the x and y coordinates will be changed by dragging the green box around on the screen. This value will be sent to Wekinator. The processing window will look like this:

The processing window in Wekinator.

Downloading ChucK Code  

The code for ChucK in this project can also be found on Wekinator’s example page. Download Simple Drum Machine Classifier for the operating system that you are using.

Next, open up the terminal and go to the directory and write the following line:

chuck DrumMachine_1ClassifierOutput_4Classes.ck

The command prompt within Wekinator to launch ChucK.

ChucK listens for the output from Wekinator and, upon receiving the output, produces the music.

With this command, ChucK is ready to listen!

Settings in Wekinator to Create Outputs for ChucK

Open Wekinator and adjust the settings to match the settings in the figure below. Set the inputs to “2” and the outputs to “1”. Select the output type to all classifier with 4 classes. Wekinator will send four different outputs to ChucK and ChucK will play four different beats, accordingly.

Adjust the settings on your Wekinator to mimic the ones shown here.

Now click on next button and the next window should look like this:

This window means Wekinator and ChucK are ready to start learning.

With that window open, drag the green box in the processing window to any place and click “randomize”. Select the output in the Wekinator window to 1 and start the recording for a second. It will record some samples.

Next, drag the green box in the processing window to another place within the window and select the Wekinator output to 2. Start recording again for a second.

After output 2 is recorded, drag the green box in the processing window to any other place within the window and select Wekinator output 3 and start the recording for a second.

After recording output 3, drag the green box in the processing window to any other place within the window one last time and select Wekinator output 4 and start recording for a second.

Now click “Train” and then click “Run”. With the four outputs saved, dragging the green box around the processing window will signal ChucK to produce music according to the outputs.

There you have it! A drumming machine created through Wekinator and ChucK. Check out the video below to see the project take shape and to watch the drumming machine in action.

Have you tried other projects using the programming language ChucK? Let us know in the comments!

Muhammad Aqib
I am an embedded programmer with the expertise in Arduino, Raspberry pi, ESP8266, IOT and OpenCV.

Maker Pro Logo
Continue to site
Quote of the day

-