Use Gamehero’s MIDI Player to Play Music in Your Game
Ever wonder what ROBLOX would be like with music? User Gamehero certainly has, and stepped outside of just “wondering” and actually created something that’s pretty innovative: a Musical Instrument Digital Interface (MIDI) player. Before we take a look at the player and show you how to use it in your games, let’s go over what exactly a MIDI file is.
MIDI is a technical standard that can carry event messages that specify notation, pitch and velocity, and send them to separate devices. MIDI files have an extremely small footprint–they’re often very small files, especially for how long the songs can actually be. MIDI versions of songs often makes them sound like “8-bit” versions of themselves–they are composed entirely of virtual instruments.
Because MIDI’s have existed for so long (over twenty years at this point), chances are, if there’s a song you enjoy, there’s a MIDI version of it somewhere on the internet. Gamehero has created a MIDI player that can play any MIDI files in your games! There are thousands of MIDI tracks all over the internet–and not just songs–sound effects, vocal cues, and a ton of other audio mediums. Start by downloading the model for the player, here.
“Music really brings games to life,” said Gamehero in an interview. “Music can make games emotional. The right music can completely change an environment.”
The mixer itself intuitive and customizable–you can change the volume of each virtual instrument to make each song sound exactly the way you intend. You can jam over tunes using a virtual piano. You can also customize music in your place to play at certain points, or when certain things happen in your game.
“One example would be creating an invisible brick to pass through that triggers music,” says Gamehero. “I have a sudden urge to make this even easier for less experienced users to put music in their games.”
Creating a MIDI player that works within ROBLOX was no easy task, according to Gamehero. Developing it required a lot of time, some tricky reverse-engineering and a lot of testing.
“There are a ton of ways MIDI files and commands are read,” said Gamehero. “Many are so different that they confused the player and caused errors. It was a real pain rewriting the script to make it compatible and efficient with each new MIDI I found and loaded.”
“It was especially frustrating when I was convinced there were no more errors only to find out from a friend that something else was wrong a month later,” he added.
We had ROBLOX Creative Director John Shedletsky insert the script into Sword Fight on the Heights. We figured that actually loading the player into a game wouldn’t be tricky, but we were curious as to how easy it would be to add our own MIDI song to the player. John investigated.
I was surprised how easy it was to get my own custom MIDI files to play in Sword Fight on the Heights. First I grabbed Gamehero’s MIDI sequencer model. Then I opened my level in ROBLOX Studio and added it to the workspace. After that, it was simple to follow his directions (in the README script) to get music playing in my level. It took two minutes total to get the songs that come with the model to play.
Adding my own songs only took slightly more effort. I had some MIDI files already laying around. I downloaded HxD, a freeware hex editor, to open them and copy the hex representation of the files into the sequencer model (this was the hackiest part). Then, magically, everything just worked. I was expecting to run into file format compatibility issues, but Gamehero has done a really solid job parsing the MIDI file format. All of the MIDIs I tried importing worked properly on the first try. To make them sound even better, he’s provided an editing tool that allows you to swap out instruments and adjust the volume of individual tracks. I haven’t played with it too much, but it looked like a very useful tool. Give it a try.
We look forward to seeing how users leverage music in their games. Adding music to ROBLOX is an idea we’ve tinkered with, but we’ve got several fish to fry before getting to that. In the meantime, our users aren’t going to wait for the features they want. Thanks to Gamehero, you can add background music to your ROBLOX levels today!