How to Make Music on power on with your 3d printer - WITH LINKS FOR MIDI to GCODE conversion how to.
Posted: Thu Jan 10, 2019 8:42 am
Today we are making music. Not just any kind of music… no we are making the kind of music to inspire to prototype to… to print stupid vases to! (you know if your into that sort of stuff)
Well anyways it's time to get your 8 bit music machine up and going, because we all know that's why you bought a 3d printer for right? I got a method that you can use to give your 3D printer some custom ditty's for your power on, start of print and end of print! It'll take some work but its not that bad honestly super simple and it will not require you to rev up stepper motors or touch your firmware.
First for this example we are gonna write the 1UP Sound effect from Super Mario. Its 8 bit it's simple and its iconic so it makes the perfect candidate for this little project of ours. Our notes just happen to be C-D-E-C-D-G and I did mine around the octave of 6. Which if you didn't learn any music theory and dont understand dont worry I will be including a chart for note to hertz conversion below so you don't have to google it as well as some nice sheet music resources to translate the cryptic language. Plus I already wrote the example code for the 1UP Sound so you dont even have to do any “hard” work.
Now the method I went about this is perfect for the Ender 3 and Geeetech A10 platform and any 3d printer that Accepts the M300 G-Code Command such as the prusa. If you don't know if your printer will work just google your printer model and see the g code libraries for it, that should tell you if you can do this or not. This nifty little command allows you to make a beep at the Hertz and length you want without really knowing programming. What that means you got your own little retro synthesizer waiting to be orchestrated. One note at a time of course.
We can write some little tunes real easy and without really any coding knowledge because we will be writing it all in G code. We will do this all Without having to rev up your stepper motors like I have seen others do.
So open yourself a little notepad file, and put this code in it.
Now I am going to break this code up so you understand exactly what we are doing here. Which this is really straight forward and makes it simple to turn sheet music into your own custom startup tone.
M300 - Is the G Code we use to turn the speaker on, on your 3d printer. This initiates the Beep sequence if you will. Nothing more to it than that. Just a simple directive, informing the printer on what action to take.
S - Is what sets the Hertz followed by the numbers which specify the hertz, or in this case the note the speaker will be playing. Here is a nice Notes To Hertz Chart - Here - this nifty little chart will make sure you have the Hertz value for any note your needing.
P - Sets the time in Milliseconds. Which If your converting music from sheet music I have this nice chart that shows you how to convert the notes to milliseconds. Link here If you don't understand the notes here's a nice little sheet music cheat sheet that literally shows you everything you need to know about sheet music - Sheet Music Cheat Sheet
Also another nifty code for this method is a pause - say you have a pause you need to implement in your tune you can use the code
G04 is just simply a pause G-code and again P sets how long of a pause in milliseconds, so you will calculate your pause in milliseconds using the same sheet music algorithm from earlier, and apply it to this value, the above example is a 100 millisecond pause. For our 1 UP Example we won't be needing a pause at all so don't worry about this for this project.
MIDI to GCODE (Really MIDI to RTTTL to GCODE) for the M300 code
So if you really want to be lazy and dont want to convert sheet music, you can use these two online programs, that when used in combination. you can take MIDI Files and upload them here then take the resulting RTTTL Code and convert it here over to Gcode using this converter that works with a beeper or speaker. You can also just take RTTTL Files and convert them over to MIDI files. RTTTL Files are just ringtone files that are used for Cellphones back in the day that specify the notes. So you can just take that Gcode you just generated and throw it in our text file if you want.
Alright So that little text file we just made take your sd card you use for your 3D Printer save this file to it under the name and file format - auto0.g make sure you select all file types, or else it will save your file as a text file and that wont work.
What the auto0.g file is, is a G code file that automatically runs on printer start up when your sd card is installed. So when you put your sd card in your printer, and turn it on. You should hear a nice little 1 UP tune play. Now if you want to have other auto G code files run afterwards just take the file name and replace the 0 with a 1 and just keep going through numbers if you add more.
Now how to apply this to start and end of print? Just take the G Code we just wrote or whatever song you want and apply it to your printer settings in the start and end G code area of your software before any of the other g code runs. And boom your ready to roll! Cura makes it real nice and easy under the printer settings to do this.
Anyways I hope this was helpful to people, I know I like having the tune so I know when my prints are finished. I will be making a video for this process soon on you tube. But honestly its so simple of a process a video might not even be necessary.
Well anyways it's time to get your 8 bit music machine up and going, because we all know that's why you bought a 3d printer for right? I got a method that you can use to give your 3D printer some custom ditty's for your power on, start of print and end of print! It'll take some work but its not that bad honestly super simple and it will not require you to rev up stepper motors or touch your firmware.
First for this example we are gonna write the 1UP Sound effect from Super Mario. Its 8 bit it's simple and its iconic so it makes the perfect candidate for this little project of ours. Our notes just happen to be C-D-E-C-D-G and I did mine around the octave of 6. Which if you didn't learn any music theory and dont understand dont worry I will be including a chart for note to hertz conversion below so you don't have to google it as well as some nice sheet music resources to translate the cryptic language. Plus I already wrote the example code for the 1UP Sound so you dont even have to do any “hard” work.
Now the method I went about this is perfect for the Ender 3 and Geeetech A10 platform and any 3d printer that Accepts the M300 G-Code Command such as the prusa. If you don't know if your printer will work just google your printer model and see the g code libraries for it, that should tell you if you can do this or not. This nifty little command allows you to make a beep at the Hertz and length you want without really knowing programming. What that means you got your own little retro synthesizer waiting to be orchestrated. One note at a time of course.
We can write some little tunes real easy and without really any coding knowledge because we will be writing it all in G code. We will do this all Without having to rev up your stepper motors like I have seen others do.
So open yourself a little notepad file, and put this code in it.
Code: Select all
M300 S 1138 P 150
M300 S 1567 P 150
M300 S 2637 P 150
M300 S 2093 P 150
M300 S 2349 P 150
M300 S 3135 P 150
M300 - Is the G Code we use to turn the speaker on, on your 3d printer. This initiates the Beep sequence if you will. Nothing more to it than that. Just a simple directive, informing the printer on what action to take.
S - Is what sets the Hertz followed by the numbers which specify the hertz, or in this case the note the speaker will be playing. Here is a nice Notes To Hertz Chart - Here - this nifty little chart will make sure you have the Hertz value for any note your needing.
P - Sets the time in Milliseconds. Which If your converting music from sheet music I have this nice chart that shows you how to convert the notes to milliseconds. Link here If you don't understand the notes here's a nice little sheet music cheat sheet that literally shows you everything you need to know about sheet music - Sheet Music Cheat Sheet
Also another nifty code for this method is a pause - say you have a pause you need to implement in your tune you can use the code
Code: Select all
G04 P100
MIDI to GCODE (Really MIDI to RTTTL to GCODE) for the M300 code
So if you really want to be lazy and dont want to convert sheet music, you can use these two online programs, that when used in combination. you can take MIDI Files and upload them here then take the resulting RTTTL Code and convert it here over to Gcode using this converter that works with a beeper or speaker. You can also just take RTTTL Files and convert them over to MIDI files. RTTTL Files are just ringtone files that are used for Cellphones back in the day that specify the notes. So you can just take that Gcode you just generated and throw it in our text file if you want.
Alright So that little text file we just made take your sd card you use for your 3D Printer save this file to it under the name and file format - auto0.g make sure you select all file types, or else it will save your file as a text file and that wont work.
What the auto0.g file is, is a G code file that automatically runs on printer start up when your sd card is installed. So when you put your sd card in your printer, and turn it on. You should hear a nice little 1 UP tune play. Now if you want to have other auto G code files run afterwards just take the file name and replace the 0 with a 1 and just keep going through numbers if you add more.
Now how to apply this to start and end of print? Just take the G Code we just wrote or whatever song you want and apply it to your printer settings in the start and end G code area of your software before any of the other g code runs. And boom your ready to roll! Cura makes it real nice and easy under the printer settings to do this.
Anyways I hope this was helpful to people, I know I like having the tune so I know when my prints are finished. I will be making a video for this process soon on you tube. But honestly its so simple of a process a video might not even be necessary.