Per-channel mute via the libopenmpt_ext interactive interface - #8
Open
LumenPrima wants to merge 1 commit into
Open
Per-channel mute via the libopenmpt_ext interactive interface#8LumenPrima wants to merge 1 commit into
LumenPrima wants to merge 1 commit into
Conversation
Fills in the toggleMute stub. libopenmpt exposes channel mute only
through openmpt_module_ext's "interactive" interface, a struct of C
function pointers, so calling it from JS needs the wasm function table.
- docker/Dockerfile: export HEAP32 and wasmTable alongside the existing
runtime methods (rebuilt libopenmpt.worklet.js included, +37 bytes).
- worklet: create the module through openmpt_module_ext_create_from_memory
and take the plain handle from openmpt_module_ext_get_module; resolve
set/get_channel_mute_status once per load; destroy through the ext
handle. New messages setChannelMute {ch, mute} and toggleMute ch; the
worklet replies with channelMute {ch, mute} read back from libopenmpt.
On a build without the exports mute is unavailable and warns once.
- chiptune3.js: setChannelMute(ch, mute), toggleMute(ch), onChannelMute.
- index.html: a toggle row in the API table. README: feature + history.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LZxPVZVBEDisdipGRJfcwn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fills in the
toggleMutestub in the worklet.Why it was a stub
libopenmpt only exposes channel mute through
openmpt_module_ext's interactive interface, which comes back as a struct of C function pointers rather than exported functions. Calling one from JS needs the wasm function table, and Emscripten doesn't putwasmTable(orHEAP32, needed to read the pointers) on the module object unless asked. Older toolchains did by default, which is how Chipsound (a libopenmpt-based player built on chiptune3) has had mute working; the Emscripten 6 build dropped them.What
HEAP32andwasmTabletoEXPORTED_RUNTIME_METHODS. The rebuiltlibopenmpt.worklet.jsis included (same 0.8.7, +37 bytes); happy to drop it if you'd rather rebuild yourself.openmpt_module_ext_create_from_memoryand take the plain handle fromopenmpt_module_ext_get_module(everything else keeps usingmodulePtr); resolveset/get_channel_mute_statusfrom the interactive interface once per load; destroy via the ext handle. New messagessetChannelMute {ch, mute}andtoggleMute ch; the worklet replies withchannelMute {ch, mute}read back from libopenmpt so the state is authoritative. On a build without the exports, mute is unavailable and a warning is logged once.setChannelMute(ch, mute),toggleMute(ch),onChannelMute(({ch, mute}) => …).npm run minify.Mutes reset on each load, as libopenmpt does.
Verified
aryx.s3m(12 ch): mute reply{ch:0, mute:true}, toggle backfalse, all channels muted → output silent after the ramp-down block, unmute → audio returns, reload resets,stop()frees the interface and both handles.wasmTable) works unchanged against this build; it is silent against the current published one.🤖 Generated with Claude Code
https://claude.ai/code/session_01LZxPVZVBEDisdipGRJfcwn