MLT NATIVE S3M OPL3 ENGINE ========================= Opal is the OPL3 emulator from Reality Adlib Tracker by Shayde/Reality, released into the public domain. The upstream file also credits fixes by JP Cimalando; this snapshot includes OpenMPT contributors' changes. Upstream revision: dc49d5638db37e157003cd606dc85165551eb9da Source: https://github.com/OpenMPT/openmpt/blob/dc49d5638db37e157003cd606dc85165551eb9da/soundlib/opal.h Original header SHA-256: 16d55838d26cdcc1780f64f2b016c7a2d12fc43a6ddc632da8d3ec86a3847b53 Embedded module SHA-256: c119cbceee136850cd10f520ad71f3f2983d1f1cd3123b1a379b7ab9e93cfffa The adapter and integration are Copyright (C) 2026 Maxime LORRAI, GPL-3.0-only. Opal's public-domain status is unchanged. MLT's complete GPL notice and liability disclaimer remain in index.html and licenses/GPL-3.0.txt. Files ----- opal.h: upstream core with a local utility include, read-only envelope-state accessors, and an observation of each channel's integer mono output. opal-adapter.cpp: one chip per worklet, separate track outputs, and the same integer linear resampling schedule as Opal::Sample. common/mptBaseUtils.h: minimal positive rounded-division utility and placement construction include; no OpenMPT application runtime is required. Build ----- Use WASI SDK 22.0+m (LLVM 18.1.2) from: https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-22 From this directory, invoke its clang++ executable with these arguments: opal-adapter.cpp -O3 -fno-exceptions -fno-rtti -nostartfiles -Wl,--no-entry -Wl,--export=reset -Wl,--export=write -Wl,--export=sample -Wl,--export=outputBuffer -Wl,--export=silent -Wl,--export=__wasm_call_ctors -Wl,--initial-memory=131072 -Wl,--max-memory=131072 -o opal.wasm The compiled module has no imports. Its memory is fixed at 128 KiB. The standalone HTML embeds that module as NATIVE_OPL3_BINARY; the browser compiles it asynchronously before creating a ready FM worklet. No external download, runtime compiler, soundfont or network access is required for FM playback. Scope ----- Native S3M uses nine two-operator melodic voices, each routed through its own MLT track bus. Opal internally supports OPL3 operators, but this integration does not claim percussion-mode or timer/interrupt hardware emulation. Keeping channels separate also keeps their track effects independent. It does not apply the original chip's aggregate saturation after those effects; integer per-channel resampling may differ by rounding from a summed output. The existing MLT OPL2/GENMIDI path is retained separately.