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/sf2synth

v0.7.1

Published

SoundFont2 Synthesizer

Downloads

59

Readme

sf2synth.js

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

sf2synth.js is WebMidiLink based SoundFont Synthesizer.

Install

npm install @logue/sf2synth

or

yarn add @logue/sf2synth

Usage

<div id="placeholder"></div>
import SoundFont from '@logue/sf2synth';

const option = {
  // Url to SoundFont file.
  url: 'https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/Yamaha XG Sound Set.sf2', // Default
  // url: 'https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/A320U.sf2', // Same as original sf2synth.js
  // Enter the ID of the destination DOM. If left blank, it will be added to the end of body.
  placeholder: 'placeholder',
  // Displays the MIDI keyboard GUI. Set it to false if you don't need. Since it does not process the drawing load, the operation becomes lighter.
  drawSynth: true,
  // ave the acquired SoundFont data in the browser using the Cache API. (Default is false)
  cache: true,
};

const wml = new SoundFont.WebMidiLink({});
wml.setLoadCallback(() => {
  // When ready to load.
});
wml.setup(); // If you want to override the SoundFont URL, put that address in this function.

Please refer to the index.html source code for details.

CDN

Entry point is SoundFont.

<link
  href="https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/style.min.css"
  rel="stylesheet"
/>
<script src="https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/sf2synth.iife.min.js"></script>
<script>
  const wml = new SoundFont.WebMidiLink({});
  // ...
</script>

ArrayBuffer usage

When using File API, pour the arraybuffer directly into the setup function.

In this case, the cache cannot be used. You will have to implement the caching yourself if necessary.

import SoundFont from '@logue/sf2synth';

/** SoundFont file. */
const buffer = new ArrayBuffer(...);

/** Option */
const option = {
  // attach dom id
  placeholder: 'placeholder',
  // If you not nessesaly to draw keyboad, set false.
  drawSynth: true
};

const wml = new SoundFont.WebMidiLink(option);
wml.setupByBuffer(buffer);

WebMidiApi

WebMidiApi is supported experimentally. A sound will be produced when a MIDI signal is sent to the DOM specified by the placeholder.

import SoundFont from '@logue/sf2synth';

const option = {
  // Default Url to SoundFont file. If blank, the Yamaha XG Sound Set.sf2 from jsdelivr will be loaded.
  // The following address will be the same SoundFont as the original sf2synth.js.
  // url: 'https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/A320U.sf2',

  // attach dom id
  placeholder: 'placeholder',

  // If you not nessesaly to draw keyboad, set false.
  drawSynth: true,

  // Cache Soundfont
  cache: true,

  // postMessage origin
  targetOrigin: '*',

  // Default Color Mode (dark, light)
  colorMode: 'auto',
};

/** Initialize Web MIDI API */
const wml = new SoundFont.WebMidiApi(option);
wml.setLoadCallback(() => {
  // When ready to load.
});

// If you want to explicitly specify another SoundFont, put the SoundFont URL in the setup function.
// No need to restart this program.
wml.setup();

Dark mode

If you want switch dark mode, specify it using the SysEx non-commercial (Manifucture ID = 7D) area.

| SysEx | Mode | | ------------------------- | ----- | | F0 0A 7D 10 00 01 00 F7 | Auto | | F0 0A 7D 10 00 01 01 F7 | Light | | F0 0A 7D 10 00 01 02 F7 | Dark |

This feature may change in the future.

Sample

sf2synth.js corresponds to the sound source in MIDI. Call and use this wml.html from a sequencer like smfplayer.js.

https://logue.dev/sf2synth.js/

Compatibility

equires a browser that supports the Web Audio API.

  • Google Chrome 25+
  • Google Chrome for Android 28+
  • FireFox 25+
  • Edge

MIDI Compatibility

  • sf2synth.js is compliant with WebMidiLink Level 1.
  • Supported MIDI standards are GM Level 2 and YAMAHA XG Lite (equivalent to YAMAHA MU50).
  • MIDI files created in the Roland GS standard may not play properly.
  • Portamento and chorus effect is not supported.
  • A specification called progress has been added as an instruction that is not compliant with WebMidiLink.

See Also

License

Licensed under the MIT License.

  • 2013 by imaya / GREE Inc.
  • 2013-2024 by Logue