spessasynth_lib documentation
    Preparing search index...

    Getting Started with spessasynth_lib

    There are two similar libraries: spessasynth_lib and spessasynth_core:

    • core is the main library that contains all the MIDI, SF2 and DLS parsing, as well as the synthesis engine with its effects. It can run in any JS environment.
    • lib builds on top of core, relying on the Web Audio API to provide an easy-to-use wrapper that runs the engine off the main thread. It depends on core, so all writing and conversion features can be used directly from core.

    So:

    • You want to play MIDI files in the browser without much work.
    • You don't want to have to program your own audio processor or threading.
    • You don't need direct access to the audio engine from the main thread.
    • You want direct audio engine access on the main thread.
    • You need full control over the audio.
    • You are not in a browser.
    • You don't have access to the Web Audio API.
    npm install --save spessasynth_core spessasynth_lib
    

    The minimal working setup requires the WorkletSynthesizer class and adding the worklet module.

    The setup is initialized as follows:

    const context = new AudioContext();
    await context.audioWorklet.addModule("path/to/worklet");
    const synth = new WorkletSynthesizer(context);

    Make sure to replace path/to/worklet with one of the paths described here.

    That's it! Now you can move on to learning how a simple MIDI player works.

    1. Simple MIDI Player - Play a MIDI file with a synthesizer and a sequencer.
    2. Advanced Example - Add a playlist, pause and seek controls.
    3. Clickable Piano - Play notes with the mouse and load a custom sound bank.
    4. Adding Visualizations - Draw per-channel waveforms and the pressed keys.
    5. Rendering Audio To File - Render a MIDI file to WAV with an OfflineAudioContext.
    6. Rendering Separate Channels To File - Render each MIDI channel to its own WAV file.
    7. Worker Synthesizer - Use the WorkerSynthesizer and its export methods.
    8. Direct Audio Engine Access - Render with spessasynth_core on the main thread.