mwg API
    Preparing search index...

    Function sendMidiToHost

    • Starts a MIDI file on a host: resets the core, drops what was rendered ahead and queues every channel message at its own output frame in one post (before any further audio is requested, so a worker never renders the first seconds without them), and returns the frame of the last message. startFrame moves the whole file later.

      Parameters

      Returns number

      import { AudioCoreHost, parseMidi, sendMidiToHost, type AudioCore } from '@datamoc/mwg/audio';

      declare const midiBytes: ArrayBuffer;
      declare const factory: (rate: number) => AudioCore;

      const host = new AudioCoreHost({ sampleRate: 44100, factory });
      const lastFrame = sendMidiToHost(host, parseMidi(midiBytes));
      console.log(lastFrame / 44100);