Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including musicjson2abc with all npm packages installed. Try it out:

var musicjson2abc = require("musicjson2abc")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

musicjson2abc v0.6.0

A command-line tool to convert musicJSON to abc notation.

musicjson2abc

Build Status npm version

A command-line tool to convert musicJSON to abc notation An example of the used format of json is in example.json.

This project is still under development. Feel free to use it and submit issues here.

Getting started

Install the module with:

npm install -g musicjson2abc

Example

var musicjson2abc = require('musicjson2abc');

var abc = musicjson2abc.convert2Abc('{"id":"123456","attributes":{"divisions":4,"clef":{"sign":"G","line":2},"key":{"fifths":-1},"time":{"beats":3,"beat-type":4}},"measures":[{"attributes":{"repeat":{"left":false,"right":false}},"notes":[{"type":"quarter","duration": 4,"rest": false,"pitch": {"step":"C","octave":4,"alter":0,"accidental": "flat"},"$hashKey":"object:1255"}]}]}');

console.log(abc);
// output:
//   X:123456
//   T:123456
//   M:3/4
//   L:1/16
//   K:F
//    _C4|


var json = musicjson2abc.convert2JSON(abc);
console.log(json);
// output:
// {"id":"123456","attributes":{"divisions":4,"clef":{"sign":"G","line":2},"key":{"fifths":-1},"time":{"beats":3,"beat-type":4}},"measures":[{"attributes":{"repeat":{"left":false,"right":false}},"notes":[{"type":"quarter","duration": 4,"rest": false,"pitch": {"step":"C","octave":4,"alter":0,"accidental": "flat"}}]}]}

Command line tool

The command musicjson2abc accepts filepaths for input and output files.

$ musicjson2abc --help

  Usage: musicjson2abc [options] <input> [output]

  Options:

    -h, --help     output usage information
    -r, --reverse  convert abc to json instead
    -d, --debug    outputs debug information on stdout
    -V, --version  output the version number

  Examples:

    $ musicjson2abc input.json output.abc
    $ musicjson2abc input.json output.abc -d
    $ musicjson2abc example.abc example.json -r

  Hint:

    The input file should be a valid json / abc file.
    No syntax checks performed.
    The output file will become a valid abc / json file.
    May overwrite existing files.

Documentation

For full API documentation have a look at API.md.

License

Licensed under the MIT License. See LICENSE for further information.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free