Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

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

Resources

Packages

No packages published
You can’t perform that action at this time.