npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@webtrack/mod

v0.3.1

Published

Uses Web Audio API to playback `*.mod` files in the browser.

Downloads

7

Readme

@webtrack/mod

Uses Web Audio API to playback *.mod files in the browser.

Supports the Noisetracker/Soundtracker/Protracker/Fasttracker Module Format (*.mod).

Powered by the wasm HxCMod Player.

Usage

npm install -S @webtrack/mod
# yarn add @webtrack/mod
# pnpm add @webtrack/mod

You'll need to load a mod file into the browser. Likely fetching from a remote resource:

import { Mod } from "@webtrack/mod";

const modFile = await fetch("/cool-music.mod").then((res) => res.arrayBuffer());

const player = new Mod({ src: modFile });
await player.play();

A working example can be found in the example app.

A live version is hosted at https://webtrack.vercel.app/

With Vite

Vite seems to have issues bundling third party modules that use URLs with import.meta.url. To bypass this issue we can pass the necessary resources to the constructor. We will manually import the files statically with Vite and pass those assets URLs to the constructor.

import { Mod } from "@webtrack/mod";
// The following assets are statically imported via the `?url` prefix.
// The resolved import will be a string of the location of the asset.
import audioWorkletUrl from "@webtrack/mod/dist/mod-processor.js?url";
import wasmUrl from "@webtrack/mod/dist/hxcmod_player.wasm?url";

const modFile = await fetch("/cool-music.mod").then((res) => res.arrayBuffer());
const mod = new Mod({
  src: modFile,
  audioWorkletUrl,
  wasmUrl,
});

API

Constructor new Mod(options?: { src?: ArrayBuffer | Int8Array, wasmBuffer?: ArrayBuffer })

  • Optional src: The mod file to play. Can be either an ArrayBuffer or Int8Array.
  • Optional wasmBuffer: If the wasm module can't be instantiated automatically, you can manually pass this in. You'll need to fetch the wasm file yourself as an ArrayBuffer. It is bundled with the module at @webtrack/mod/dist/hxcmod_player.wasm.
  • Optional audioWorkletUrl: An asset url for the audio worklet. Useful workaround for bundlers that can't process third party URLs with import.meta.url.
  • Optional wasmUrl: An asset url for the wasm module. Useful workaround for bundlers that can't process third party URLs with import.meta.url.

.loadData({ src: ArrayBuffer | Int8Array }): Promise<void>

Load a mod file in preparation to play

.play(): Promise<void>

Play/resume the currently loaded mod file

.pause(): Promise<void>

Pauses playback of the current mod file

.stop(): Promise<void>

Stops playback of the current mod file. Playing again will resume from the start.

.setVolume(volume: number): void

Sets the volume of playback. The value is between 1 and 0. 1 being 100%, 0.5 being 50% etc.