import { StreamChannel, parseMidi, playMidiHosted, type AudioCore } from '@datamoc/mwg/audio';
declare const context: AudioContext;
declare const midiBytes: ArrayBuffer;
declare const factory: (rate: number) => AudioCore;
const running = playMidiHosted(parseMidi(midiBytes), {
sampleRate: context.sampleRate,
factory,
channel: new StreamChannel(context),
});
console.log(running.host.stats().mode);
Plays a MIDI file through a synthesis core that runs off the main thread: builds an
AudioCoreHost(a worker where one exists, the main thread otherwise,mode: 'auto'unless told), queues the file's messages on it and hands its output to aStreamChannel. A core too heavy for the frame (several voices of a modelled instrument) then costs the frame nothing; where only the main thread exists the sound is the same andhost.stats().modesays so.