npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@kazuprog/mml-player

v1.0.0

Published

MML(Music Macro Language) player for Web Audio API

Readme

mml-player

MML(Music Macro Language) Player based on mohayonao/mml-emitter demo

Installation

downloads:

API

MMLPlayer

  • constructor(config: object)
    • config.mml: string
    • config.waitForReady: bool
      • wait for AudioContext to be ready (user gesture required)
    • config.reverseOctave: bool
      • reverse < and > command
    • config.defaultParams: object
      • velocity: number
      • velocityMax: number
      • quantize: number
      • quantizeMax: number
      • instNumber: number
      • panpotRange: number

Instance methods

  • setInst(no, inst): void

    • set custom instrument
    • no: int
      • instrument number (@{index})
    • inst: PeriodicWave
    • inst: Array
      • the values of one cycle of the audio waveform
      • e.g. [1,-1](sine wave)
    • inst: [Array, Array]
      • the result of a Fourier transform, where you get frequency domain values from time domain value
      • e.g. [[0,1],[0,0]](sine wave)
  • play(mml = null): void

  • stop(): void

Event

  • onNote
    • type: "note"
    • time: number
    • playbackTime: number
    • trackNumber: number
    • noteNumber: number
    • duration: number
    • velocity: number(0 - 1)
    • quantize: number(0 - 1)
    • slur: Array
      • time: number
      • duration: number
      • noteNumber: number
      • panpot: number(-1 - 1)
    • instNumber: number
    • panpot: number(-1 - 1)

Example

To play sound, the user must make a gesture (click, tap, or keystroke) on the page first.

let mml = "cde2";
let player = new MMLPlayer();

player.onNote = e => {
  console.log("NOTE: " + JSON.stringify(e));
}

document.querySelector("#playbtn").addEventListener('click', e => {
  player.play(mml);
});

// one-liner
new MMLPlayer().play("cde2");

MML Syntax

NoteEvent

  • ([`"]+)?[cdefgab][-+#]?(\d+)?\.*&?
    • note on
    • ([`"]+)?
      • octave change
      • `+
        • octave up
        • e.g. ceg `c egc
      • "+
        • octave down
        • e.g. edc "b c
    • [cdefgab]
      • musical scales
      • e.g. c d e
    • [-+#]?
      • semitone change
      • -
        • lower a semitone
      • [+#]
        • raise a semitone
      • e.g. c c+ d d# e e- d d- c
    • (\d+)?
      • note length (default: l)
      • e.g. c4 c8 c8 c2
    • \.*
      • dotted note
      • e.g. c e8. g16 `c2
    • &
      • slur
      • e.g. "c&`c2
  • \[ (([`"]+)?[cdefgab][-+#]?|[<>])+ \](\d+)?\.*
    • chord (default: l)
    • e.g. [ <g>ce ]2 [ <gb>d ]2 [ <g>ce ]1
  • r(\d+)?\.*
    • rest (default: l)
    • e.g. l16 crcc crcc crccr crcc

NoteLength

  • l(\d+)?\.*
    • length (default: 4)
    • e.g. l8 cc l4 e l2 g
  • ^(\d+)?\.*
    • tie (default: l)
    • e.g l16 c^^ e^^ g^
  • q(\d+)?
    • quantize (default: 75)
    • e.g. l16 q50 crcc crcc crcc crcc

NotePitch

  • o(\d+)?
    • octave (default: 4)
    • e.g. o4 ceg o5 c
  • >(\d+)?
    • octave up (default: 1)
    • e.g. ceg > c
  • <(\d+)?
    • octave down (default: 1)
    • e.g. c < gec
  • k(\+|-)?\d+
    • key change (relavive value)
    • e.g. cde2k+1cde2

Control

  • t(\d+)?
    • tempo (default: 120)
    • e.g. t140 cdefgab<c
  • v(\d+)?
    • velocity (default: 100)
    • e.g. v75 c v50 e v25 g
  • @\d+
    • change instrument
      • 0: sine wave
      • 1: square wave
      • 2: sawtooth wave
      • 3: triangle wave
      • 4: 25% pulse wave
      • 5: 12.5% pulse wave
    • e.g. @0c @1c @2c @3c @4c @5c
  • p(\d+)?
    • panpot (default: 128)
      • 1(left) - 128(center) - 255(right)
    • e.g. p128cp1cp255c
  • $
    • infinite loop
    • e.g. l2 $ [fa>ce] [gb>d] [egb>d] [ea>c]
  • /: ... | ... :/(\d+)?
    • loop (default: 2)
    • commands after | are skipped in the last loop
    • e.g. l2 /: [fa>ce] [gb>d] [egb>d] | [ea>c] :/4 [eg>c]

See Also

License

MIT