Tetorica FM2612 (hello_ymfm_wasm)

Tetorica is a tool for live coding retro game sounds in JavaScript, including the sounds of the Sega Genesis / Mega Drive and Game Boy.

Goals

This repository has four goals:

This repository also provides YM2612 WebAssembly modules and JavaScript interfaces for browser-side use.

Repository: https://github.com/kyorohiro/hello_ymfm_wasm

These demos use ymfm by Aaron Giles under the BSD 3-Clause License.

npm Packages

Use Tetorica in your own projects: analyze existing VGM music with tetorica-vgm, or build sound-chip audio with tetorica-fm2612. Node.js usage requires Node.js 22 or later.

VGM tools · Node.js CLI / API

tetorica-vgm

Analyze VGM/VGZ files, export scores and FM voices, and render WAV audio. Use the command line or import the analysis and export APIs into a Node.js application.

npm install tetorica-vgm
npx tetorica-vgm analyze song.vgz --json

Sound-chip audio · Browser / Node.js

tetorica-fm2612

Import sound-chip cores and synth APIs as ES modules with prebuilt WASM. Generate PCM in Node.js, or add FM, PSG and PCM audio to a browser app with the included Web Audio runtime.

npm install tetorica-fm2612

Includes YM2612, related Yamaha chips, Sega PSG, RF5C164 and other sound chips. Start with createSoundChip, YM2612Synth or MegaSynth.

Native C++ / WASM Sources

Reusable sound-chip sources · C/C++ / WebAssembly

tetorica-soundchip-native

Build sound-chip audio into your own application with C/C++ cores, native adapter sources and WebAssembly build recipes collected in one repository. Component licenses, source provenance and local modifications are documented alongside the code.

The standalone native build currently supports YM2612 (ymfm). Other chip adapters are included as reference sources, with their build requirements and backend differences documented.

Tetorica Tools (Experimental)

YM2612 Playground Try a small JavaScript playground with play(), beat(), liveLoop(), and raw fm access. Try with Nuked-OPN2 → PC-98 YM2608 Playground → PC-98 YM2203 Playground → Neo Geo YM2610 Playground →
YM2612 Synth Demo Try a small YM2612Synth keyboard with a guitar-like PC key layout and preset switching. Try with Nuked-OPN2 →
FM2612 VGM Analyzer Inspect parsed commands, watch 6 YM2612 channels, and export snapshot data or TFI patches. Sound chip support → Try with Nuked-OPN2 →
Tetorica MIDI Playground Live-code MIDI melodies and loops in JavaScript. Connect this macOS app to GarageBand, a DAW, or a MIDI instrument. Download for macOS → View on itch.io →

Introduction

Embed Sound Chips in Web Apps and Games

Learn how to use the tetorica-fm2612 npm package through small, complete examples. Explore direct chip control, AudioWorklet output, MegaSynth with FX, event recording and looping, Playground embedding, VGM playback, and TFI / VGI instruments.

References

ymfm, libymfm.wasm, MAME, retropc.net, YM2612 pin reference, VGMPF YM2612, SpritesMind thread, chipmusic YM2612, DefleMask, GENajam, megatoy, Maple's Garden article, Aidan Lawrence's Sega Genesis video game music player, Zophar's Domain Genesis Music, SMS Power