mwg API
    Preparing search index...

    Function renderMidiToBuffer

    • Renders a parsed MIDI file to stereo PCM frames: one offline pass, then the result plays, loops, seeks and re-pitches like any decoded track. Deterministic: the same file and options always produce the same frames, so a test can render and assert without any audio hardware. The synthesis itself lives in renderNotes, which the async twin renderMidiToBufferAsync ships to a worker, so both paths produce the same bits.

      Parameters

      Returns RenderedMidi

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

      declare const midiBytes: ArrayBuffer;

      const rendered = renderMidiToBuffer(parseMidi(midiBytes));
      console.log(rendered.duration, rendered.loopStart, rendered.loopEnd);