Notable Pottery Manufacturer

    @logue/sf2synth

    0.4.9 • Public • Published

    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

    CDN

    <script src="https://cdn.jsdelivr.net/npm/@logue/sf2synth@0.4.9/dist/sf2synth.umd.min.js"></script>

    Usage

    <div id="placeholder"></div>
    import SoundFont from '@logue/sf2synth';
    
    // Url to SoundFont file.
    const sf2 = './Yamaha XG Sound Set.sf2';
    
    const option = {
      // attach dom id
      placeholder: 'placeholder',
      // If you not nessesaly to draw keyboad, set false.
      drawSynth: true,
      // Cache Soundfont
      cache: true,
    };
    
    const wml = new SoundFont.WebMidiLink(option);
    wml.setLoadCallback(() => {
      // When ready to load.
    });
    wml.setup(sf2);

    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';
    
    // Url to SoundFont file.
    const sf2 = './Yamaha XG Sound Set.sf2';
    
    const option = {
      // attach dom id
      placeholder: 'placeholder',
      // If you not nessesaly to draw keyboad, set false.
      drawSynth: true,
      // Cache Soundfont
      cache: true,
    };
    
    /** Initialize Web MIDI API */
    const wml = new SoundFont.WebMidiApi(option);
    wml.setLoadCallback(() => {
      // When ready to load.
    });
    wml.setup(sf2);

    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/wml.html

    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-2022 by Logue

    Install

    npm i @logue/sf2synth

    DownloadsWeekly Downloads

    16

    Version

    0.4.9

    License

    MIT

    Unpacked Size

    4.66 MB

    Total Files

    13

    Last publish

    Collaborators

    • logue