MML(Music Macro Language) event emitter for Web Audio API.
JavaScript HTML
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build
src
test
.babelrc
.eslintrc
.gitignore
.travis.yml
README.md
index.html
index.js
package.json

README.md

mml-emitter

Build Status NPM Version License

MML(Music Macro Language) event emitter for Web Audio API

Installation

$ npm install mml-emitter

downloads:

API

MMLEmitter

  • constructor(source: string, config = {})

Instance methods

Also implements methods from the interface EventEmitter.

  • start([ t0: number ]): void
  • stop([ t0: number ]): void

Events

  • note
    • type: "note"
    • playbackTime: number
    • trackNumber: number
    • noteNumber: number
    • duration: number
    • velocity: number
    • quantize: number
  • end
    • type: "end"
    • playbackTime: number
    • trackNumber: number
  • end:all
    • type: "end:all"
    • playbackTime: number

Example

import MMLEmitter from "mml-emitter";

let mml = "t200 o6 l8 e g > e c d g";
let config = { context: audioContext };
let mmlEmitter = new MMLEmitter(mml, config);

mmlEmitter.on("note", (e) => {
  console.log("NOTE: " + JSON.stringify(e));
});
mmlEmitter.on("end:all", (e) => {
  console.log("END : " + JSON.stringify(e));
  mmlEmitter.stop();
});

mmlEmitter.start();

Demo

See Also

  • MML Syntax
  • Configuration
  • NoteNumber to Frequency
    • mtof = m => 440 * Math.pow(2, (m - 69) / 12)

License

MIT