Skip to content

nescio007/midi2gcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A MIDI-to-gcode-converter

Bored of 3D-printing Benchies? Have your 3D-printer make music instead!

How?

Run

python3 midi2gcode.py your_song.mid > your_song.gcode

How does it work?

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.

Supported Printers

Tested against a Prusa MK3S+. Supporting other printers probably requires some light edits to midi2gcode.py:

  1. the CALIBRATION field defines for each axis which pitch is produces at a given speed
  2. the SPEED_RANGES field defines which speed ranges produce audible pitches at all
  3. the LIMITS_MM field defines the "safe volume" within which the printer can move without destroying things
  4. the AXIS field defines which MIDI-channel maps to which axis
  5. the _print_prologue and _print_epilogue functions should output gcode that homes the printer / disables all steppers. I stole mine from gcode that was generated by a slicer.

About

A MIDI to gcode converter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages