Can 3D printers dance?

3d printer meets creative coding meets experimenting with sounds

Back in January, I participated in a workshop by the talented Basti on intended and unintended uses of 3D printers. During the second part, which was also what interested me, I worked on a piece of code that makes a 3D printer “dance” to music.

Here’s a short video capture during the workshop’s show (Note: if you don’t allow scripts you can see it on instagram):

The code

It took me a while, but I finally managed to clean up the code just a little, and put it online for anyone (like Basti :)) wanting to check it out, use or improve it.

Check it out on Github here

How it works

During the workshop I worked with a creality ender 3D printer, that “danced” to Claude Debussy’s Claire de Lune, thanks to gcode commands I produced and sent via python. The printer moves in response to detected musical notes and audio frequencies. In the simplest version, the python script listens to the microphone for sound and tries and translate sound into gcode movements that it feeds to a printer either by serial connection (live) or a file. It can also use an audio file for input, as well as the computer’s sound system – although the latter is a bit counter-intuitive.

The sound, whatever its chosen source, is translated into frequencies and loudness (RMS).

  1. Tone -> Direction The frequencies, are mapped to notes and accidentals (sharp and flat), which are then mapped to movements like “x right”, “y left”, “change x direction”, etc

  2. Loudness -> speed Loudness (RMS) is encoded so that silence stops movement, and louder is faster.