modplayer
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

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

Dependencies (3)

Dev Dependencies (7)

Package Sidebar

Install

npm i modplayer

Weekly Downloads

3

Version

0.0.7

License

MIT

Unpacked Size

90 kB

Total Files

35

Last publish

Collaborators

  • penx