Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 956 Bytes

README.md

File metadata and controls

39 lines (28 loc) · 956 Bytes

modplayer

TypeScript mod player/tracker.

Usage

AudioWorklet

import modplayerWorkletUrl from "modplayer/worklet?worker&url";
import { loadWorkletFromBuffer, loadBufferFromUrl } from "modplayer";

const context = new AudioContext({
  sampleRate: 44100,
});
await context.audioWorklet.addModule(modplayerWorkletUrl);
const addModulePromise = context.audioWorklet.addModule(modplayerWorkletUrl);
const { buffer, ext } = await loadBufferFromUrl("/assets/cooltune.mod");
const worklet = loadWorkletFromBuffer(ext, buffer, context, {
    options: {
    autoplay: true,
    repeat: true,
  },
});

worklet.connect(context.destination);

CodeSandbox example

Credits

Based upon @electronoora's webaudio-mod-player.

Forked by Alasdair McLeay:

  • Converted to TypeScript
  • Published to npm
  • Added AudioWorklet (threading) support