This is the Javascript/browser version of
Therapy MOD player (tmodplay)
an audio player for the MOD music format
- Multichannel support
- Floating point mixers with volume ramping
- Variable amplification with clipping
- Various sample interpolation methods
- Stereo crossfade for hard panned (Amiga) MODs
- Real stereo mode for MODs utilizing panning commands
- Responsive graphical user interface with keyboard and mouse support, scopes and RMS meters
It delivers 107% of the original tmodplay experience in the browser with a few improvements (floating point mixing for cleaner audio, BLEP interpolation, volume ramping for click-free playback, high resolution UI, mouse support).
Try it on https://a11599.github.io/tmodplay-js/!
There are some interesting recent high level languages that I ponder learning and tmodplay seemed to be a good candidate as a porting exercise because it does quite a lot of things. But for this I prefer having a cleaner base reference than the heavily 386-optimized x86 assembly source of mod. So here it is.
The player requires a recent browser. It uses (among others):
- Javascript classes
- Javascript modules
- The Web Audio API, rendering in a background thread via AudioWorkletProcessor
- Asynchronous functions
- ArrayBuffer and typed arrays to handle binary data
- Canvas to render the oscilloscopes
The player has no external dependencies, all it needs is a standards-compliant browser. The fact that doing something like this is possible in the browser without resorting to all kinds of hacks and trickery shows how far the platform got. Even more impressive is that playing dope.mod
uses only a few percent of an Intel Coffee Lake (8th gen) core at maximum sound quality settings (or even BLEP interpolation) when the code is not even optimized at all.
Drop a .mod file onto the page or click the eject button to open the file picker dialog. After dropping/opening the file, tmodplay will parse it and start playback (when dropping in Firefox you also have to click the play button for the first time).
Click "Press F1 for help" or the exclamation mark icon on mobile, or actually press F1
to view the user guide for details.
This webapplication requires no build process, it runs as-is from source. For development an HTTP server is needed, because Javascript modules cannot be loaded from file sources.
A simple no-dependency HTTP server is provided in server.js
which needs node.js. Install node.js and run node server
to start it, then open http://localhost in the browser of your choice. If port 80 is in use on your machine, you can specify an alternate port as a command line argument. For example to run the HTTP server on port 3000, run node server 3000
.