mwg API
    Preparing search index...

    Function decodeSoundFont

    • Decodes a SoundFont 3 into a plain SoundFont 2: every compressed sample a preset reaches (Ogg Vorbis, Ogg Opus or FLAC, told apart by its first bytes) goes through decode (one call per sample, given the codec, returning mono 16-bit frames at the rate the header states) into the sample chunk, and the loop points a SoundFont 3 states relative to its sample become the absolute ones SoundFont 2 uses. A SoundFont 2 comes back unchanged and decode is never called. The result feeds everything that takes SoundFont 2 bytes, renderMidiToBufferAsync included. A loop that ends past the decoded frames is cut to them. limits raises or lowers what a sample and the whole font may decode to (see SoundFontLimits).

      Parameters

      Returns Promise<ArrayBuffer>

      import { decodeSoundFont, webAudioSampleDecoder } from '@datamoc/mwg/audio';

      declare const sf3Bytes: ArrayBuffer;

      const sf2 = await decodeSoundFont(sf3Bytes, webAudioSampleDecoder());
      console.log(sf2.byteLength);