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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@beatbax/engine

v0.3.0

Published

Live-coding language and runtime for retro console chiptunes.

Readme

@beatbax/engine

Live-coding language and runtime for retro console chiptunes.

npm version License: MIT

Overview

The BeatBax engine is a deterministic, tick-accurate audio engine for creating chiptune music. It currently provides a faithful 4-channel Game Boy APU emulation with support for:

  • Pulse 1 & 2 - Square wave channels with duty cycle and envelope control
  • Wave - Custom wavetable playback (16×4-bit samples)
  • Noise - LFSR-based noise generation with envelope

Additional chipsets will be added in the future.

Installation

npm install @beatbax/engine

Quick Start

import { parse } from '@beatbax/engine/parser';
import { resolveSong } from '@beatbax/engine/song';
import { play } from '@beatbax/engine/audio';

const source = `
  chip gameboy
  bpm 120

  inst lead type=pulse1 duty=50 env=gb:12,down,1

  pat melody = C4 E4 G4 C5

  channel 1 => inst lead pat melody
`;

const ast = parse(source);
const song = resolveSong(ast);
await play(song);

Features

Parser & Language

  • Full BeatBax language parser
  • Pattern and sequence definitions
  • Inline effects and transforms
  • Import/export support

Exports

import { exportJSON } from '@beatbax/engine/export';
import { exportMIDI } from '@beatbax/engine/export';
import { exportUGE } from '@beatbax/engine/export';

// Export to various formats
await exportJSON(song, 'output.json');
await exportMIDI(song, 'output.mid');
await exportUGE(song, 'output.uge');

Imports

import { readUGE } from '@beatbax/engine/import';

// Import hUGETracker files (v1-v6)
const song = await readUGE('input.uge');

Audio Playback

import { play } from '@beatbax/engine/audio';

// Play with controls
const player = await play(song);
player.pause();
player.resume();
player.stop();

API Documentation

Core Modules

  • @beatbax/engine/parser - Parse BeatBax source code
  • @beatbax/engine/song - Song resolution and ISM generation
  • @beatbax/engine/audio - WebAudio playback engine
  • @beatbax/engine/export - Export to JSON, MIDI, UGE
  • @beatbax/engine/import - Import UGE files
  • @beatbax/engine/chips - Game Boy APU emulation
  • @beatbax/engine/scheduler - Deterministic tick scheduler

Browser Support

The engine supports both Node.js and browser environments with conditional exports:

// Automatic browser-safe imports
import { resolveSong } from '@beatbax/engine/song';  // Uses browser version in browsers

Examples

Using Effects

const source = `
  inst lead type=pulse1 duty=50 env=gb:12,down,1

  effect vibLead = vib:4,3
  effect arpMinor = arp:3,7

  pat melody = C4<vibLead> E4 G4<arpMinor>:2

  channel 1 => inst lead pat melody
`;

Export to hUGETracker

import { exportUGE } from '@beatbax/engine/export';

await exportUGE(song, 'song.uge', {
  verbose: true  // Show detailed export info
});

Import and Transform

import { readUGE } from '@beatbax/engine/import';
import { exportMIDI } from '@beatbax/engine/export';

// Import UGE and export as MIDI
const song = await readUGE('input.uge');
await exportMIDI(song, 'output.mid');

TypeScript Support

Full TypeScript definitions included:

import type { AST, Song, Pattern, Instrument } from '@beatbax/engine';

Resources

License

MIT © BeatBax Contributors