mml-emitter
v1.1.0
Published
MML(Music Macro Language) event emitter for Web Audio API
Downloads
7
Maintainers
Readme
mml-emitter
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
- http://mohayonao.github.io/mml-emitter/
See Also
- MML Syntax
- MMLIterator / MML(Music Macro Language) Iterator
- Configuration
- WebAudioScheduler / Event Scheduler for Web Audio API
- NoteNumber to Frequency
mtof = m => 440 * Math.pow(2, (m - 69) / 12)
License
MIT