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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@logue/smfplayer

v0.5.6

Published

smfplayer.js is JavaScript based Standard Midi Player for WebMidiLink based synthesizer.

Downloads

51

Readme

smfplayer.js

jsdelivr CDN NPM Downloads Open in unpkg npm version Open in Gitpod Twitter Follow

smfplayer.js is standard MIDI file player using a WebMidiLink compatible synthesizer.

This program is side of sequencer. Tone Generator side is sf2synth.js.

Usage

import SMF from '@logue/smfplayer';

const player = new SMF.Player();

window.addEventListener(
  'DOMContentLoaded',
  () => {
    /** @type {boolean} */
    const loop = true;
    /** @type {boolean} */
    const cc111 = true;
    /** @type {boolean} */
    const falcom = true;
    /** @type {boolean} */
    const mfi = true;
    /** @type {number} */
    const tempo = 1.0;
    /** @type {number} 0-16383 */
    const volume = 16383 * 0.5;

    // player settings
    player.setLoop(loop); // Player Loop
    player.setCC111Loop(cc111); // CC#111 Loop
    player.setFalcomLoop(falcom); // Ys2 Eternal Loop
    player.setMFiLoop(mfi); // MFi Loop
    player.setTempoRate(tempo); // Playback tempo rate
    player.setMasterVolume(volume); // Master Volume
    player.setWebMidiLink('https://logue.dev/smfplayer.js/wml.html');

    // load standard MIDI file
    loadSMF('hoge.mid');
  },
  false
);

/**
 * @param {string} url
 */
function loadSMF(url) {
  fetch(url)
    .then(response => {
      if (!response.ok) {
        throw new Error('HTTP error, status = ' + response.status);
      }
      return response.arrayBuffer();
    })
    .then(arraybuffer => {
      /** @type {string} */
      const ext = url.split('.').pop();
      switch (ext) {
        case 'midi':
        case 'mid':
          // Load MIDI file
          player.loadMidiFile(arraybuffer);
          break;
        case 'mld':
          // Load Polyphonic Ringtone File
          player.loadMldFile(arraybuffer);
          break;
        case 'ms2mml':
          // Load Maple Story 2 MML File
          player.loadMs2MmlFile(arraybuffer);
          break;
        case 'mms':
          // Load MakiMabi Sequence MML File
          player.loadMakiMabiSequenceFile(arraybuffer);
          break;
        case 'mml':
          // Load 3MLE MML File
          player.load3MleFile(arraybuffer);
          break;
        case 'mmi':
          // Load Mabicco MML File
          player.loadMabiIccoFile(arraybuffer);
          break;
        default:
          throw new Error('Unsupported format:' + ext);
      }
      player.play();
    })
    .catch(e => console.error(e));
}

For more details, please refer to the source code in demo. (Although there are many Bootstrap dependent codes)

CDN

Entry point is SMF.

<script src="https://cdn.jsdelivr.net/npm/@logue/smfplayer@latest/dist/smfplayer.iife.min.js"></script>
<script>
  const player = new SMF.Player();
  // ...
</script>

Methods

| Method | Description | | ------------------------------------- | --------------------------------------------------------------- | | play() | Play Sequence | | stop() | Stop Sequence | | sendAllSoundOff() | Send AllSoundOff to WML | | sendGmReset(lv) | Send GM Reset SysEx to WML. (Set lv to true for GM Level2.) | | sendRawMidiMessage() | Send Midi message directly (such as F0,7E,7F.09.01,F7) | | load3MleFile(ArrayBuffer) | Load 3MLE(*.mml)format MML file. | | loadMakiMabiSequenceFile(ArrayBuffer) | Load MakiMabi Sequence(*.mms)MML file. | | loadMidiFile(ArrayBuffer) | Load Standard MIDI file.(SMF1, SMF2 both supported) | | loadMldFile(ArrayBuffer) | Load Docomo Ringtone Melody(*.mld)file. | | loadMabiIccoFile(ArrayBuffer) | Load MabiIcco(*.mmi)MML file. | | loadMs2MmlFile(ArrayBuffer) | Load MapleStory2 MML(*.ms2mml)file. | | setCC111Loop(boolean) | Enable loop by ControlChange No.111 | | setFalcomLoop(boolean) | Enable Falcom loop (Used MIDI text) | | setLoop(boolean) | Enable Loop | | setMFiLoop(boolean) | Enable Mfi meta data loop. | | setMasterVolume(number) | Set Master volume(0~1) | | setPosition(number) | Jump sequence position. | | setTempoRate(number) | Set Tempo Rate | | setWebMidiLink(string) | Set WML url. | | getCopyright() | Get Copyright meta data. | | getLength() | Get Sequence Length. | | getLyrics() | Get Lyrics meta data of current position. [^1] | | getPosition() | Get current position. | | getSequenceName() | Get Sequence name. (usually contains the song title.) | | getTextEvent() | Get the TextEvent of current position. | | getWebMidiLink() | Get WebMidiLink URL | | getTempo() | Get current tempo. | | getTime(number) | Output current playing time (hh:mm:ss) | | getTotalTime() | Output playing time of MIDI file.[^2] |

[^1] This program does not parse karaoke data. (KAR, XF, etc.) [^2] Since it is calculated based on the current tempo, if the tempo changes in the middle of the song, the value here will also change.

Restrictions when reading MML

When reading the following files, the program change values match those of MSXspirit.dls and are not compatible with GM. Download MSXspirit.sf2 from MabiMmlEmu and load it into wml.html to use it.

| Extension | Description | | --------- | ------------------------------------------------------ | | *.mms | MakiMabi Sequence | | *.mml | 3MLE | | *.mmi | MabiIcco |

When reading an MML file (*.ms2mml) from MapleStory2, the program change is not included in the file format, so the instrument will be 0 (fixed to piano). increase.

Compatibility

  • Firefox 7+
  • Google Chrome 7+
  • Safari 5.1+
  • Edge

TODO

Recomposer file (*.rcm) support.

License

Copyright © 2013 imaya / GREE Inc. Copyright © 2013-2023 by Logue.

PSGConverter.js Copyright © 2006-2012 by Logue.

Licensed under the MIT License.