Skip to content

digital-sound-antiques/mgsc-js

Repository files navigation

mgsc-js npm version

mgsc-js is a JavaScript version of MGSC (MML to MGS compiler for MGSDRV) build with Emscripten

Repository: mgsc-js GitHub

Install as Command-Line Tool

$ npm install -g mgsc-js

How to Use Command

$ mgsc-js [options] source

where the source is MGSC's MML source text.

Options

$ mgsc-js
Usage: mgsc [options] source
[options]
  -o, --output FILE   : Specify the output filename.
  -e, --encode ENCODE : Specify the input file encoding [default:AUTO].
                        Available encodings: UTF16, UTF16BE, UTF16LE, 
                        JIS, UTF8, EUCJP, SJIS
  -t                  : Show track memory usage.
  -h, --help          : Show this help.

Install and Use as Library

Install the mgsc-js as a node_module.

$ npm install --save mgsc-js

Then,

const FS = require('fs');
const MGSC = require('mgsc-js');

MGSC.initialize().then(() => {
  const result = MGSC.compile('#opll_mode 0\n#tempo 120\n9 v13@0o4cdefgab>c\n');    
  if (!result.success) {
    console.log(result.errorInfo.message + ' in ' + result.errorInfo.lineNumber);
    console.log('>> ' + result.errorInfo.lineText + '\n');
    process.exit(1);
  }

  FS.writeFileSync('result.mgs', new Buffer(result.mgs), "binary");
});

How to build Project

emscripten >=3.0.0 and cmake >=3.0 are required.

$ emcc -v # confirm emcc is on path and version >= 3.0.0
...
$ git clone --recursive https://github.com/digital-sound-antiques/mgsc-js.git
$ cd mgsc-js
$ npm install
$ npm run build 
$ npm run jsdoc # for document

API Document

http://digital-sound-antiques.github.io/mgsc-js/