mwg API
    Preparing search index...

    Function renderMidiThroughSynth

    • Renders a MIDI file through a MidiSynth to stereo frames, the same RenderedMidi the SoundFont path produces, so it plays, loops and seeks like any other track. Messages are delivered at their exact sample, not rounded to a block, so a synth sees the timing the file wrote. The synth is reset first and again afterwards, which leaves it reusable.

      Parameters

      Returns RenderedMidi

      import { parseMidi, renderMidiThroughSynth, type MidiSynth } from '@datamoc/mwg/audio';

      declare const synth: MidiSynth;
      declare const midiBytes: ArrayBuffer;

      const rendered = renderMidiThroughSynth(parseMidi(midiBytes), synth);
      console.log(rendered.sampleRate, rendered.duration);