MML(Music Macro Language) event emitter for Web Audio API.
JavaScript HTML
Latest commit 9bb5d8b Dec 17, 2015 @mohayonao Merge pull request #11 from mohayonao/v1.1.0
v1.1.0
Permalink
Failed to load latest commit information.
build v1.1.0 Dec 17, 2015
src use seq-emitter Nov 30, 2015
test update dependencies Dec 7, 2015
.babelrc update dev tools Dec 17, 2015
.eslintrc update dev tools Dec 7, 2015
.gitignore re-init Nov 24, 2015
.travis.yml re-init Nov 24, 2015
README.md update README [ci skip] Dec 7, 2015
index.html update README [ci skip] Dec 7, 2015
index.js module exports for es2015 (babel6) Dec 17, 2015
package.json v1.1.0 Dec 17, 2015

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