Writing an Amiga Protracker Module in Javascript

So I got a nice request on creating a Protracker module for an Amiga music disk from Resistance. Haven't touched protracker since the 90s, and had to catch up on a few of the commands (though I still remember quite a bit). However since I'm now into the habit of actually creating all my music in a programming environment, and not using sequencers or trackers, I decided to go for trying to create the Amiga module in code as well.

The ProTracker file format is very simple and straight forward, and writing a library to generate it from a JavaScript object structure was just a few lines of code. So then it is possible to express a module like this:

const moduledef = {
    songname: "trackerscripting",
    samples: [
         {
            samplename: "bass",
            finetune: 0,
            volume: 64,
            loopstart: 0x1000,
            looplength: 0x800,
            data: [] // sample data bytes
         }
    ],
    songpositions: [
        // patterns to play 
        0,
        1,
        2,
        
    ],
    patterns: [
        [
            // instrument, period, command, value
            [0, 856, 0xc, 0x20],
            [0, 428, 0xc, 0x20]

....