mwg API
    Preparing search index...

    Function loadSoundFont

    • Reads a SoundFont 2 or 3 into layered preset voices: parseSoundFont for a plain font, and a SoundFont 3 decoded first through decode, webAudioSampleDecoder() (the browser) unless one is given. This is what a game calls on the bytes it ships, whichever kind they are.

      Parameters

      Returns Promise<SoundFont>

      import { loadSoundFont, parseMidi, renderMidiToBuffer } from '@datamoc/mwg/audio';

      declare const fontBytes: ArrayBuffer;
      declare const midiBytes: ArrayBuffer;

      const font = await loadSoundFont(fontBytes);
      const rendered = renderMidiToBuffer(parseMidi(midiBytes), { soundfont: font });
      console.log(rendered.duration);