mwg API
    Preparing search index...

    Class FakeRetroPlayer

    A MidiSynth double for a retro engine: it records every message it was driven with and renders a flat level while any note is on (silence otherwise), so a test can assert what a renderer sent and read the shape of the output without a real synth or clock. Pair it with FakeAudioContext, whose advance() is the audio clock a test moves by hand.

    import { FakeRetroPlayer } from '@datamoc/mwg/testing';

    const synth = new FakeRetroPlayer(8000);
    synth.event(0x90, 60, 100); // note on, middle C
    const left = new Float32Array(4);
    synth.render(left, new Float32Array(4), 0, 4);
    console.log(synth.notesOn, left[0] > 0); // 1, true

    Implements

    Index
    events: [number, number, number][] = []

    every channel message received, as [status, data1, data2] in order

    renders: number = 0
    resets: number = 0
    sampleRate: number

    rate the synth renders at; a render of a file through it comes out at this rate

    sysexMessages: Uint8Array<ArrayBufferLike>[] = []

    every system-exclusive message received, as a copy

    • a channel message as the three bytes a hardware synth would receive (the second data byte is 0 for a program change)

      Parameters

      • status: number
      • data1: number
      • data2: number

      Returns void

    • adds count frames of stereo output at start of both buffers, advancing the synth by that many samples

      Parameters

      • left: Float32Array
      • right: Float32Array
      • start: number
      • count: number

      Returns void

    • a system-exclusive message, with or without the leading 0xF0 and trailing 0xF7

      Parameters

      • bytes: Uint8Array

      Returns void