top of page
CNC Cutter Stepper Music

Für Elise by Ludwig van Beethoven, Played on DIY CNC
00:00/00:00
Conception
I began this project when I noticed something interesting while combining the look ahead code with the circular interpolation code in my G-code interpreter. In the process, I noticed that my stepper motors created distinct audible harmonics and resonant frequencies. I wanted to explore this behavior further, and began systematically mapping acoustic frequency outputs to their feedrate inputs. The acoustic resonance I heard stemmed from the physical characteristics of my machine: low mass combined with mechanical amplification.
_mp4.jpg)
I wanted to explore the practical applications of these motor acoustics, so I expanded my G-code interpreter to include a function capable of processing custom G-code syntax relying on frequencies and duration to actuate motors, rather than feedrate and positioning. Key features of this addition include:
-
Location Monitoring: Updates the machine coordinates continuously to prevent drift
-
Physical Bound Management: Using a continuous triangle wave to prevent collisions near soft axis limits to enable longer sustained notes without violating machine constraintsÂ
-
Asynchronous Multi-Axis Control: Enabling polyphony by running multiple axes concurrently with an independent timing loop for simultaneous melodies.
-
Easy Configuration: Added a custom command to adjust syntax to accept both Hertz values and standard note values.
Once I had this base idea built up, I began improving it, testing it with code that I had written for the machine to play melodies, to ensure consistency and accuracy. This, however, created the issue of how to write and generate the code for the interpreter to run.
Prototyping and Adding in Manual Music
Coding an Automatic Music Writer
I wanted a way to automatically generate the G-code from any type of music file.
I had been previously working on a piece of code that could automatically detect key and tempo of songs to make playlists from audio files. Due to this familiarity with using python and its associated libraries for analyzing audio files, I decided to write the music analysis and compiler in Python. In the process, I explored the complex mathematical basis for audio analysis and included features like the following:
-
Stem Separation: Using the Demuc’s deep-learning framework to isolate music stems from raw audio files,Â
-
Pitch Extraction: Applying the Librosa python library for bounded pitch tracking across the individual audio stems to extract frequencies within designated musical ranges
-
Signal Processing: Utilizing a sliding window mode filter, and restricting frequency values to a 12-TET chromatic scale with cents, and durations to subdivisions of a detected track tempo
-
Custom Formatting: Compiles extracted music data into the modified G-code syntax based on user input values.
The end result is being able to automatically play songs on my machine!
Note: this page has really cool audio! You should unmute to listen!
Note: this page has really cool audio! You should unmute to listen!
Note: this page has really cool audio! You should unmute to listen!
bottom of page