YM2612 WASM Usage

This page is the browser-readable version of the basic WASM usage note. It shows the minimum path from generated files to JavaScript control.

Related source: web/README.md, web/ym2612.js, SDK YM2612 wrapper

Build

sh scripts/build_ym2612_wasm.sh

The build verifies the fixed SDK source release included in the checkout. It requires Emscripten and Python 3. See the build and SDK update instructions.

This generates:

Minimal Browser Usage

import ym2612ModuleFactory from "./generated/ym2612_wasm.js";
import { createYm2612, YM2612_CLOCK } from "../js/ym2612.js";

const ym2612 = await createYm2612(ym2612ModuleFactory);
const sampleRate = ym2612.sampleRate(YM2612_CLOCK);

ym2612.reset();
ym2612.writeRegister(0x30, 0x01);
ym2612.writeRegister(0x34, 0x01);
ym2612.writeRegister(0x38, 0x01);
ym2612.writeRegister(0x3c, 0x01);

const { left, right } = ym2612.generateStereo(128);

Wrapper Methods

Good Next Reads

Back