ireal-reader

Read iReal Pro files into JS


Keywords
iReal, iReal Pro, json, chords, music, music notation, ireal-reader, irealpro, music-information-retrieval, nodejs
License
MIT
Install
npm install ireal-reader@1.3.1

Documentation

iReal Reader

This is a Node JS module to read music files from iRealPro.

The output is a JS object similar to the one shown below. Repeated measures, endings, segnos and codas are all expanded and written out serially in one array.

{
  name: 'Swing Tunes',
  songs:
   [ {
       title: 'All Of Me',
       composer: 'Marks Gerald',
       style: 'Medium Swing',
       key: 'C',
       transpose: null,
       compStyle: '0',
       bpm: 100,
       repeats: 3,
       music: {
          timeSignature: '44',
          raw: '[*AT44C^7XyQKcl LZEadd9XyQKcl LZAsus A7susadd3LZsA, ,lBLZD-7XyQKcl  ][*BE7XyQKcl LZA-7XyQKcl LZD7XyQKcl LZD-7XyQ|G7XyQ][*AC^7XyQKcl LZE7XyQKcl LZA7XyQKcl LZD-7XyQKcl  ][*CF^7XyQ|F-6(F#o7)XyQ|E-7(C^7/G)XyQ|A7XyQ|D-7XyQ|G7XyQ|C6 Ebo7LZD-7 G7 Z',
          measures:
            [
              ['C^7'], ['C^7'], ['Eadd9'], ['Eadd9'],
              ['Asus', 'A7susadd3'], ['A', 'B'], ['D-7'], ['D-7'],
              ['E7'], ['E7'], ['A-7'], ['A-7'],
              ['D7'], ['D7'], ['D-7'], ['G7'],
              ['C^7'], ['C^7'], ['E7'], ['E7'],
              ['A7'], ['A7'], ['D-7'], ['D-7'],
              ['F^7'], ['F-6', 'F#o7'], ['E-7', 'C^7/G'], ['A7'],
              ['D-7'], ['G7'], ['C6', 'Ebo7'], ['D-7', 'G7']]
          }
       }
     ...
   ]
}

Usage

Install the module with npm install ireal-reader. To save to your projects package.json, use npm install ireal-reader --save.

Then, in your project, read in the HTML or ireal://... url output from iRealPro.

JavaScript

The example below shows how to read the music from an HTML file using plain JavaScript:

const fs = require('fs');
const iRealReader = require('ireal-reader');

fs.readFile("ireal-output-file.html", "utf8", function(err, data) {
    if (err) throw err;
    const playlist = iRealReader(data);
}

TypeScript

The example below shows how to read the music from an HTML file using TypeScript.

First, in your project, npm install ireal-reader-1.3.0.tgz --save. Also, for example, if you are using Angular2, you might need a irealreader.d.ts file containing the text declare module 'ireal-reader'; in your app folder.

Then, load this library in your TypeScript class like so:

import * as iRealReader from 'ireal-reader';

Then, call it:

const iRealHtml: string = '<HTML ...';
const iRealJson = iRealReader(iRealHtml);

Developing

Feel free to fork or submit pull requests. Run tests with npm test

To develop and use the project locally, use npm pack. This will create a .tgz file that can be used locally by other modules. In your other project do npm install path/to/ireal-reader-xxx.tgz

Acknowledgments

The irealb schema was originally cracked by Stephen Irons' Accompaniser.

License

MIT License