Bored of 3D-printing Benchies? Have your 3D-printer make music instead!
Run
python3 midi2gcode.py your_song.mid > your_song.gcode
Stepper motors generate noise. The pitch of the noice depends on the rotational speed. Slow rotation -> low pitched noise, fast rotation -> high pitched noise.
Since 3D-printers usually have three axes, they can make three pitched noises at once.
This script takes the pitch information from a MIDI file and computes how fast each stepper motor should be rotating.
Together with the note durations from the MIDI file, it then also computes how far each axis needs to travel.
Combining this information for all three axes results in a series of 3D location that the printer can be instructed to move to using G1 gcode commands.
Tested against a Prusa MK3S+.
Supporting other printers probably requires some light edits to midi2gcode.py:
- the
CALIBRATIONfield defines for each axis which pitch is produces at a given speed - the
SPEED_RANGESfield defines which speed ranges produce audible pitches at all - the
LIMITS_MMfield defines the "safe volume" within which the printer can move without destroying things - the
AXISfield defines which MIDI-channel maps to which axis - the
_print_prologueand_print_epiloguefunctions should output gcode that homes the printer / disables all steppers. I stole mine from gcode that was generated by a slicer.