mwg API
    Preparing search index...

    Class MidiPlayer

    Plays a parsed MidiFile back through mwg/audio's waveform synth, one tone per note, driven by update(dt) like every other dt-driven piece of mwg/core.

    Index
    • get duration(): number

      total playback length in seconds, from the last scheduled note's own end

      Returns number

    • Humanizes first, then schedules: the one call a game needs when a file should sound played rather than played back. The constructor stays synchronous, so the async work of resolving an engine happens here instead of inside frame-time code.

      Parameters

      Returns Promise<MidiPlayer>

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

      declare const midiBytes: ArrayBuffer;

      const player = await MidiPlayer.create(parseMidi(midiBytes), {
      humanize: { intensity: 0.5, seed: 3, style: 'jazz' },
      });
      player.play();