mwg API
    Preparing search index...

    Function missingSoundFontPrograms

    • The programs of usage the font does not carry, so a game can tell at build time which of the instruments its MIDI files ask for would be missing. A bank without the program counts as carried when bank 0 has it (the fallback every player makes), a drum kit only when the font has that exact kit. What plays for a missing one is the missingProgram policy of parseSoundFont. Works on a SoundFont 2 or 3.

      Parameters

      • data: ArrayBuffer | ArrayBufferView<ArrayBufferLike>
      • usage: readonly SoundFontProgram[]

      Returns SoundFontProgram[]

      import { missingSoundFontPrograms, parseMidi, collectSoundFontUsage } from '@datamoc/mwg/audio';

      declare const soundfontBytes: ArrayBuffer;
      declare const midiBytes: ArrayBuffer;

      const usage = collectSoundFontUsage([parseMidi(midiBytes)]);
      for (const { bank, program } of missingSoundFontPrograms(soundfontBytes, usage)) {
      console.log(`bank ${bank} program ${program} is not in the font`);
      }