Usually when it comes to films and video games, the music is not the main focus of the experience, but it is still a very important part of it; take the music out and that experience is greatly diminished.
This was aptly demonstrated for me when I wrote my web-based implementation of the game Atoms three years ago. Although I made the game as visually similar to the original as I could, it never really captured that addictive play feeling that the original did. I had a feeling that the main reason for this was the lack of the music that the original had, so much so that the very first issue that I filed in the GitHub project for it was simply titled “Add music!”. But I never did manage to add the music.
Of course the reason I’m writing this post is that this situation has now changed.
Yesterday I was contacted by Daniel Reimann, one of the volunteer editors of the Amiga-News website, asking me a few questions about my project. One of those questions was whether I still planned to add the music. I replied that yes, I very much still wanted to add it, but I didn’t have any source for it, other than a not so great recording of it on YouTube.
He soon got back to me, having done some research of his own, and he had found the original music for me in MOD format, hidden away in an archive on Aminet.
I’m quite familiar with MOD music, having even written some myself some 30 or so years ago, but while it’s a very efficient format (only 53KB in this case), I knew that no web browser in the world would be able to play it (unless someone were to write some tracker software that works in a web browser), so I needed to convert it to a web-compatible format. To do this I simply played the file in MilkyTracker and fed the output into Audacity where I could edit it precisely and generate a couple of mp3 files. I needed 2 mp3 files because the music has a 2-bar introduction that then leads into a continuously looping song.
I took the mp3 files I had made and put them into <audio>
elements in the HTML of the page, then triggered them to play in sequence as soon as the “start game” button is pressed (with the second file set to loop). And it worked surprisingly well.
The transition between the 2 parts of the music is not perfect: there is a noticable pause. Likewise there is a noticable gap when the music loops. Neither of these gaps are present in the mp3 files, it simply seems to be a reality that no browser engine currently implements perfectly gapless playback for <audio>
elements. Fortunately though, these minor issues don’t really detract from the experience.
And so I can now confirm that the game is much more addictive now that it has the classic music added to it. Something about it (and even the way it abruptly stops when the game is over) just seems to invite you to play one more game. And maybe just one more…
Of course someone has already written a web MOD player: http://www.wothke.ch/webxmp/
It doesn’t quite give perfect results with the Atoms music though, but could be worth pursuing.
There’s also https://github.com/jhalme/webaudio-mod-player that I could try.
Agreed, the music can be more than just audio-filler.
BTW. there is another option for mod playback.
“libopenmpt can be compiled to JavaScript and WebAssembly using emscripten, so it can serve as an up-to-date replacement for the ModPlugin”
http://openmpt.org/legacy_software (scroll to the bottom)
Confession: I still use a mod tracker
https://www.renoise.com
And I’ll continue until a better/more efficient way of sequencing samples is developed. In other words, I plan on using a mod tracker until death…
Yes MP3 leaves a gap, and is not a loopable format, hopefully you can try to convert the files to OGG, or compressed WAV (like ADPCM)