6.3 KiB
ModFM (Web-based Tracker Music Player)
ModFM
ModFM is a web-based Tracker format music player built with Nuxt.js, WebAssembly (libopenmpt), and the Web Audio API (AudioWorklet). It supports playing various retro tracker formats (such as MOD, XM, S3M, IT, etc.) and integrates a SidWiz-style oscilloscope visualizer to display stable real-time waveforms for each channel.
Tech Stack
- Core Framework: Nuxt.js (Vue 3 / TypeScript)
- Audio Decoding:
libopenmptcompiled to WebAssembly - Audio Playback: Web Audio API (AudioWorklet) running on an asynchronous rendering thread
- Waveform Rendering: Waveform extraction and Canvas real-time rendering based on the
SidWizalgorithm - Styling: Tailwind CSS
Directory Structure
modfm/
├── app/ # Frontend views and interactive components (Vue 3 / Nuxt 3)
├── chiptune/ # AudioWorklet logic and WASM packaging scripts
├── data/ # Local data storage (ignored, containing .gitkeep)
│ └── music/ # Default local folder for music files
├── libopenmpt/ # C/C++ core decoding library with the ported SidWiz algorithm
├── public/ # Static assets (including compiled WASM glue files)
├── server/ # Backend API routes and SQLite database integration layer
│ ├── db.ts # Database initialization and schema setup
│ └── utils/
│ └── scanner.ts # Incremental music directory scanner
├── types/ # TypeScript declaration files
├── package.json # Project dependencies and scripts
├── LICENSE # MIT open-source license file
└── BUILD_libopenmpt.md # WebAssembly build instructions for the core library
Prerequisites
- Node.js:
node >= 18.0.0 - Package Manager:
npmorpnpmis recommended - C/C++ Toolchain (Optional): Only required if you modify and need to rebuild the
libopenmptWebAssembly binary. Local installation of Emscripten SDK is required.
Environment Variables
The project supports runtime configuration via the following environment variables:
| Variable | Description | Default | Example |
|---|---|---|---|
MUSIC_PATH |
Custom absolute path to scan for music files. If not specified, it defaults to the local data/music directory. |
[Project Root]/data/music |
/var/music/my_mods |
PORT |
The listening port for production preview (npm run preview) or dev mode. |
3400 (preview) / 3401 (dev) |
8080 |
Quick Start
1. Install Dependencies
# npm
npm install
# pnpm
pnpm install
2. Development Server
Start the development server (default port 3401):
npm run dev
Open http://localhost:3401 in your browser.
3. Production Build & Preview
Build the application for production:
npm run build
Preview the production build (default port 3400):
npm run preview
Development & Configuration Guide
1. Database Setup
The server uses SQLite (via the better-sqlite3 driver):
- Automated Setup: On the first launch, the app automatically creates a
data/directory andapp.sqlitedatabase file in the project root, initializing all schema tables (users,songs,favorites, etc.) and indexes. No manual SQL scripts are required.
2. Music Import & Scan
- Default Path: Place your music files (such as
mod,xm,it,s3mtracker modules, or traditionalmp3,ogg,wavfiles) in the localdata/music/folder, or specify a custom directory using theMUSIC_PATHenvironment variable. - Scanning Mechanism:
- First-run Auto Scan: If the database
songstable is empty upon startup, a background incremental scanner automatically populates the database from the designated path. - Manual Trigger: Send a
POSTrequest to/api/admin/scanto manually force an incremental scan and clean up obsolete records.
- First-run Auto Scan: If the database
3. Custom Modifications to libopenmpt (Vendored Modifications)
To enable real-time, jitter-free oscilloscope rendering, we deeply integrated and customized the libopenmpt decoder. All modifications are in the libopenmpt/ folder:
- Waveform Processor: Added waveform_processor.c and waveform_processor.h to implement the C version of the
PeakSpeedTriggeralignment algorithm, 1-pole high-pass filter, and adaptive period tracking. - Mixer Interception: Modified Fastmix.cpp to intercept raw PCM float outputs from each active channel and feed them into the waveform processor.
- Interface Exposure: Modified Sndfile.cpp to reset the processors when loading a track and export WASM bindings for the frontend AudioWorklet to read the stabilized waveform buffers.
Tip
If you make changes to the C/C++ files under
libopenmpt/and need to compile it, please refer to the WASM Build Guide.
License & Third-Party Credits
The primary codebase of ModFM is licensed under the MIT License.
This project vendors or links with several open-source subprojects:
- libopenmpt (located at libopenmpt/) - BSD-3-Clause License. Copyright (c) 2004-2026 OpenMPT Developers. Used for tracker decoding.
- SidWiz (algorithm reference) - MIT License reference. The waveform synchronization logic (PeakSpeedTrigger & adaptive width) is ported from Maxim's SidWizPlus.
- chiptune3.worklet.js (located at chiptune/) - MIT License. Custom fork based on DrSnuggles' chiptune3.js framework.
NPM Dependency Licenses
@nuxtjs/color-mode: MITbcryptjs: BSD-3-Clausebetter-sqlite3: MITnuxt: MITvue: MITvue-router: MIT@nuxtjs/tailwindcss: MIT@types/node: MIT
