Skip to content

Wow! the javascript module player actually works!

Yesterday i started to move my old module player (classic four channel m.k. amiga .mods) originally written in bad c-code over to javascript, and now it actually plays the samples almost like it should, haven’t implemented many effects though, but it works much better than i expected :)

it plays this rather bad incarnation of the Axel F theme i found somewhere on the interwebs entirely using javascript and a couple of html5 audio tags as buffers… nothing magical going on, the player generates audio output into an array of mono samples at the given samplerate, the samples are converted to base64 encoded wave-audio and then put into one of the audiobuffers and then played. “nemo” pointed me to the extended audio api available in Firefox, i’ll have to look into that, that would eliminate the glitches between the bufferchanges.

Tested in Safari and Firefox, works fine in both.

WARNING! It gets extremely loud and distorted in Chrome for some reason, sounds like it doesnt recognize signed/unsigned waveforms or something.

Try it here: http://possan.se/junk/jsmod/

You can check the code out on github: http://github.com/possan/jsmod

  • Adrian Boeing

    Wow, great work! I note the code has a commented out sinewave generator, do you have an alternative version of this which just generates a sine wave for the output?

    • Anonymous

      exactly i used that one to test streaming.. maybe i removed that one in the github repo, i add it when i get home tonight.

  • http://crayolon.net/chipdisco syphus

    Great stuff! I’ve been waiting for somebody to get the ball rolling with module replay in HTML5 as I eventually want to port my Java/Processing mod/xm/s3m DJ player to Processing.js, so it’ll run in a browser without the usual fiddly Java applet issues – http://crayolon.net/chipdisco

    I’m not very clever, so it would have taken me years to figure out how to do replay in HTML5…but your project should be good inspiration for me :)

    Cheers,

    Syphus/Up Rough

  • http://soledadpenades.com/ sole

    Wow, that’s excellent! I heard Chrome guys wanted to implement native buffer audio access or something like that (like that thing from mozilla, but even more powerful). Things are getting interesting :)

  • http://cheesetruck.livejournal.com/ Your Name

    Does it handle soundtracker mods (like echoing and klissje pa klissje) properly, or does the replay need to be adjusted for the older mods? (If it’s at all mikmod based [RAGE RAGE RAGE MUST DESTROY MIKMOD] it won’t handle it at all. If it’s ported from protracker replays, well, aside from the known “define variable and never use it” MT_ something thing that I recall from some sources… it should.

    I should mess with it but to be honest I don’t have time today even tho I want to. ):

    Oh well, I still like it and I wanna see it work properly, which is of course why I say something about it (:

    • Anonymous

      it probably wont handle many tunes at all, the module parsing is very rough at the moment and only like two three effects are implemented… but that can all be fixed, given a lot of free time :)

  • http://cheesetruck.livejournal.com/ Your Name

    Dear web software thing: NO I WANTED TO POST AS TRUCK, OBVIOUSLY. SHEESH. WHY DID YOU SAVE THE COOKIE FROM LAST WEEK WHEN I POSTED TO ANOTHER BLOG WITH MY LJ ACCOUNT. WHY. I DID NOT AUTHORIZE YOU POSTING TO EVERY BLOG AS ‘Your Name’ STUPID WEB SOFTWARE.

    (Look everyone Truck is having one of his fits. Let’s see if he kills anything if we make him use windows.)

    • http://crayolon.net/chipdisco syphus

      I knew it was Truck from only the most subtle clues in your previous comment…

  • aleks

    Nice one! Can’t wait for a properly working javascript modplayer. But I guess it’s difficult with the possibilities currently offered by the browsers.

    Quite fun you posted this just yesterday, as this was the first time I had a look for a JS module player on the webs :) . You have probably seen it already but there is a similar project here: http://github.com/gasman/jsmodplayer

    • Anonymous

      actually i had not seen that one, looking at the source now i see a scary amount of similarities :)