Sharing a script that converts MIDI files into the M1006 commands Bambu printers use to play music through their stepper motors, plus the melodies I’ve made with it so far.
Here’s what it sounds like on my P2S:
How this differs from the wiki
The official wiki covers the A1 mini and Bambu’s own converter. This covers the other models, uses my own script for the files Bambu’s converter won’t handle, and explains the part neither of them mentions: why the MIDI has to be rewritten before any converter can help.
The part that actually matters
The conversion is the easy half. The hard half is the MIDI itself. The motors give you a narrow range and one note at a time, and a file downloaded off the internet was written for instruments with none of those limits. Converted straight across it comes out as noise that only vaguely resembles the tune, which is why most people try this once and give up.
A friend of mine is a musician and he reworked the files by hand: octaves shifted, chords stripped to a single line, note lengths adjusted so the rhythm survives. That’s what makes them recognisable. No converter can fix a file that was never going to fit the range in the first place.
Installing it
Open your printer preset in Bambu Studio, turn advanced settings on, go to the Machine G-Code tab. In Machine start G-code, replace everything between the start printer sound dividers with the generated code. The end sound works the same way, using the printer finish sound dividers in Machine end G-code.
Line breaks have to survive the paste. On Windows copy through Wordpad, because Notepad strips them and the code breaks.
Compatibility
Confirmed on my P2S. A1 and A1 mini are officially documented by Bambu, the H2 series is reported working, and the X series has the sound block sitting in its start G-code but never got firmware support for it. I don’t know where the line falls beyond that, so if you get it running on another model, say which one and I’ll add it to the readme.
If you’ve reworked a MIDI that plays well, send it over and I’ll add it to the library. There’s also a thread on r/BambuLab where people have been suggesting tunes: https://www.reddit.com/r/BambuLab/comments/1wj5gku/my_p2s_plays_the_mortal_kombat_theme_when_a_print/