@openclaw/whatsapp 2026.9.6 → 2026.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/icon.png +0 -0
- package/dist/.setup/{accounts-D_NGDjCx.mjs → accounts-CtRPAQCL.mjs} +3 -9
- package/dist/.setup/{action-runtime-DZZFamfl.mjs → action-runtime-DeVk5V7r.mjs} +2 -2
- package/dist/.setup/{approval-handler.runtime-C0hzmMSj.mjs → approval-handler.runtime-CjqMlPOX.mjs} +6 -26
- package/dist/.setup/{approval-reactions-BnXw-UZI.mjs → approval-reactions-DiOFvb1s.mjs} +8 -14
- package/dist/.setup/{auth-store-Dh8a3cba.mjs → auth-store-BBonwKks.mjs} +9 -33
- package/dist/.setup/{channel-Bg_fS2iF.mjs → channel-CJFE0kD_.mjs} +82 -154
- package/dist/.setup/{channel-react-action-1iBiEnq7.mjs → channel-react-action-2r_hjLZV.mjs} +4 -8
- package/dist/.setup/{channel.runtime-rurG-kbr.mjs → channel.runtime-C94goLw9.mjs} +4 -4
- package/dist/.setup/{channel.setup-C8P5q8uD.mjs → channel.setup-CfN1UfdY.mjs} +1 -1
- package/dist/.setup/{connection-controller-C60mU7j7.mjs → connection-controller-CHo1oRJA.mjs} +13 -63
- package/dist/.setup/{creds-files-Drg3usj1.mjs → creds-files-CDATZWWM.mjs} +5 -11
- package/dist/.setup/{directory-config-BHPoBklt.mjs → directory-config-DUiJ5d8I.mjs} +13 -14
- package/dist/.setup/doctor-iMwg0Vhr.mjs +222 -0
- package/dist/.setup/group-config-path-DZr3ucUO.mjs +40 -0
- package/dist/.setup/{group-session-key-D22hYMdE.mjs → group-session-key-2-mja4OF.mjs} +3 -9
- package/dist/.setup/{login-2dmd1TfE.mjs → login-BFlvSh9h.mjs} +9 -11
- package/dist/.setup/{login-qr-CgKtO_ef.mjs → login-qr-Ayb8i25J.mjs} +29 -77
- package/dist/.setup/{monitor-By82ehLA.mjs → monitor-CGpV2VNN.mjs} +376 -504
- package/dist/.setup/{question-reactions-D3Zq9Gbn.mjs → question-reactions-CPyyi5AY.mjs} +2 -2
- package/dist/.setup/rolldown-runtime-BBjsoOtd.mjs +27 -0
- package/dist/.setup/{send-C6jDmcL9.mjs → send-BGdvf5cC.mjs} +31 -80
- package/dist/.setup/{send-api-B4DOt2RJ.mjs → send-api-H4AkQJjT.mjs} +45 -109
- package/dist/.setup/{session-errors-JuazczrA.mjs → session-errors-B8UcAnZN.mjs} +1 -4
- package/dist/.setup/{session.runtime-DcJuO42v.mjs → session.runtime-st1konFI.mjs} +1 -1
- package/dist/.setup/{setup-finalize-pGqWOiFX.mjs → setup-finalize-DmPX4EaW.mjs} +32 -70
- package/dist/.setup/setup-plugin-api-vJlxKzca.mjs +3 -0
- package/dist/.setup/{setup-surface-B9CYwDPZ.mjs → setup-surface-43fj197P.mjs} +3 -3
- package/dist/.setup/{shared-DVgQ8kRG.mjs → shared-DgOG5Iqr.mjs} +26 -37
- package/dist/.setup/{socket-close-CCVSFufF.mjs → socket-close-CT__V2fz.mjs} +80 -92
- package/dist/.setup/{targets-runtime-RBjx3pg_.mjs → targets-runtime-DmiqXIXO.mjs} +2 -7
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/agent-tools-api.js +5 -12
- package/dist/api.js +10 -10
- package/dist/auth-presence.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +9 -10
- package/dist/light-runtime-api.js +2 -2
- package/dist/login-qr-runtime.js +1 -1
- package/dist/runtime-api.js +9 -9
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/node_modules/audio-decode/LICENSE +9 -10
- package/node_modules/audio-decode/README.md +16 -0
- package/node_modules/audio-decode/audio-decode.d.ts +2 -14
- package/node_modules/audio-decode/audio-decode.js +4 -92
- package/node_modules/audio-decode/meta.js +1 -0
- package/node_modules/audio-decode/node_modules/{audio-buffer → @audio/decode}/LICENSE +1 -1
- package/node_modules/audio-decode/node_modules/@audio/decode/audio-decode.d.ts +52 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/audio-decode.js +242 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/meta.js +14 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/package.json +114 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/readme.md +191 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/stream.d.ts +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/stream.js +1 -0
- package/node_modules/audio-decode/node_modules/@audio/decode/test.html +52 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/LICENSE +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/README.md +80 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/alac.js +326 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/decode-aac.d.ts +24 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/decode-aac.js +452 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/meta.js +81 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/package.json +63 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aac/src/aac.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/LICENSE +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/LICENSE.liba52 +340 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/README.md +41 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/decode-ac3.d.ts +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/decode-ac3.js +131 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/package.json +64 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-ac3/src/ac3.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/README.md +46 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/decode-aiff.d.ts +16 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/decode-aiff.js +583 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-aiff/package.json +52 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/LICENSE +191 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/README.md +65 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/decode-amr.d.ts +16 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/decode-amr.js +150 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/package.json +58 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-amr/src/amr.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/README.md +53 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/decode-avi.d.ts +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/decode-avi.js +241 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-avi/package.json +66 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/README.md +48 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/decode-caf.d.ts +16 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/decode-caf.js +238 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-caf/package.json +53 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/README.md +73 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/audio.d.ts +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/audio.js +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/decode-dsd.d.ts +29 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/decode-dsd.js +423 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/meta.js +40 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dsd/package.json +64 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/LICENSE +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/LICENSE.libdca +339 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/README.md +41 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/decode-dts.d.ts +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/decode-dts.js +139 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/package.json +64 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-dts/src/dts.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/LICENSE +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/LICENSE.ffmpeg +502 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/README.md +45 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/decode-eac3.d.ts +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/decode-eac3.js +124 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/package.json +68 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-eac3/src/eac3.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/LICENSE +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/README.md +23 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/decode-flac.d.ts +18 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/decode-flac.js +3172 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/meta.js +115 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-flac/package.json +60 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/LICENSE +23 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/LICENSE.libopenmpt +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/README.md +86 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/audio.d.ts +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/audio.js +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/decode-mod.d.ts +58 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/decode-mod.js +148 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/package.json +68 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mod/src/mod.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/LICENSE +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/README.md +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/decode-mp3.d.ts +16 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/decode-mp3.js +793 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/meta.js +143 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp3/package.json +60 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/README.md +58 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/decode-mp4.d.ts +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/decode-mp4.js +455 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mp4/package.json +74 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/LICENSE +31 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/LICENSE.libmpcdec +31 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/README.md +60 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/decode-mpc.d.ts +20 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/decode-mpc.js +158 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/package.json +64 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-mpc/src/mpc.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/LICENSE +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/LICENSE.libopus +44 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/README.md +32 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/core.d.ts +33 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/core.js +147 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/decode-opus.d.ts +18 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/decode-opus.js +1 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/meta.js +103 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/package.json +68 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/src/decode-opus.js +2 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-opus/src/opus.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/LICENSE +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/README.md +19 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/decode-qoa.d.ts +16 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/decode-qoa.js +275 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-qoa/package.json +56 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/LICENSE.ttadec +39 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/README.md +58 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/decode-tta.d.ts +17 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/decode-tta.js +302 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-tta/package.json +58 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/LICENSE +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/README.md +33 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/decode-vorbis.d.ts +18 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/decode-vorbis.js +2984 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/meta.js +102 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/package.json +60 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/README.md +23 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/decode-wav.d.ts +8 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/decode-wav.js +256 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/meta.js +114 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wav/package.json +52 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/LICENSE +29 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/LICENSE.wavpack +25 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/README.md +41 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/audio.js +9 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/decode-wavpack.d.ts +18 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/decode-wavpack.js +140 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/package.json +62 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wavpack/src/wavpack.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/LICENSE +21 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/LICENSE.libopus +44 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/README.md +59 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/decode-webm.d.ts +18 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/decode-webm.js +141 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/package.json +76 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-webm/src/opus.wasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/LICENSE +12 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/README.md +74 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/audio.d.ts +15 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/audio.js +10 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/decode-wma.d.ts +33 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/decode-wma.js +516 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/package.json +57 -0
- package/node_modules/audio-decode/node_modules/@audio/decode-wma/src/wma.wasm.js +0 -0
- package/node_modules/audio-decode/package.json +37 -39
- package/node_modules/audio-decode/stream.d.ts +2 -0
- package/node_modules/audio-decode/stream.js +2 -0
- package/node_modules/baileys/lib/Utils/messages-media.js +1 -1
- package/node_modules/baileys/node_modules/file-type/package.json +1 -1
- package/node_modules/baileys/node_modules/file-type/readme.md +2 -0
- package/node_modules/baileys/node_modules/file-type/source/detectors/zip.js +9 -4
- package/node_modules/baileys/package.json +1 -1
- package/node_modules/typebox/build/compile/code.mjs +1 -2
- package/node_modules/typebox/build/compile/validator.mjs +5 -1
- package/node_modules/typebox/build/format/iri.mjs +16 -9
- package/node_modules/typebox/build/guard/emit.mjs +2 -2
- package/node_modules/typebox/build/guard/guard.d.mts +7 -5
- package/node_modules/typebox/build/guard/guard.mjs +14 -9
- package/node_modules/typebox/build/guard/index.mjs +6 -0
- package/node_modules/typebox/build/guard/unicode/unicode.d.mts +6 -0
- package/node_modules/typebox/build/guard/unicode/unicode.mjs +35 -0
- package/node_modules/typebox/build/guard/{string.mjs → unicode/unicode_segment.mjs} +16 -19
- package/node_modules/typebox/build/schema/build.mjs +2 -3
- package/node_modules/typebox/build/schema/engine/_pathing.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/_pathing.mjs +11 -0
- package/node_modules/typebox/build/schema/engine/_refine.mjs +13 -5
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/format.mjs +9 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/properties.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -1
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/ref.d.mts +1 -1
- package/node_modules/typebox/build/schema/engine/ref.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/schema.mjs +24 -24
- package/node_modules/typebox/build/schema/parse.mjs +3 -0
- package/node_modules/typebox/build/schema/pointer/pointer.d.mts +1 -6
- package/node_modules/typebox/build/schema/pointer/pointer.mjs +47 -64
- package/node_modules/typebox/build/system/settings/internal.d.mts +2 -0
- package/node_modules/typebox/build/system/settings/internal.mjs +20 -0
- package/node_modules/typebox/build/system/settings/settings.d.mts +11 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +14 -0
- package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
- package/node_modules/typebox/build/type/extends/inference.mjs +15 -2
- package/node_modules/typebox/build/type/extends/tuple.d.mts +2 -1
- package/node_modules/typebox/build/type/extends/tuple.mjs +21 -1
- package/node_modules/typebox/build/value/parse/parse.mjs +10 -4
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +3 -1
- package/package.json +6 -6
- package/dist/.setup/doctor-BPb-SjdE.mjs +0 -65
- package/dist/.setup/group-config-path-BGyzT9Lg.mjs +0 -54
- package/dist/.setup/normalize-DdsROMMa.mjs +0 -2
- package/dist/.setup/rolldown-runtime-D7D4PA-g.mjs +0 -13
- package/dist/.setup/runtime-group-policy-DeSRFXEV.mjs +0 -11
- package/dist/.setup/setup-plugin-api-2wUapweU.mjs +0 -3
- package/dist/.setup/text-runtime-CHl0iPYe.mjs +0 -4
- package/node_modules/audio-decode/.eslintrc.json +0 -43
- package/node_modules/audio-decode/.github/workflows/test.js.yml +0 -31
- package/node_modules/audio-decode/.travis.yml +0 -13
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/README.md +0 -293
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/dist/opus-ml-decoder.min.js +0 -11646
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/dist/opus-ml-decoder.min.js.map +0 -1
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/index.js +0 -8
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/package.json +0 -58
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/src/EmscriptenWasm.js +0 -0
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/src/OpusMLDecoder.js +0 -253
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/src/OpusMLDecoderWebWorker.js +0 -17
- package/node_modules/audio-decode/node_modules/@wasm-audio-decoders/opus-ml/types.d.ts +0 -77
- package/node_modules/audio-decode/node_modules/audio-buffer/.eslintrc.json +0 -44
- package/node_modules/audio-decode/node_modules/audio-buffer/.github/workflows/node.js.yml +0 -31
- package/node_modules/audio-decode/node_modules/audio-buffer/.travis.yml +0 -7
- package/node_modules/audio-decode/node_modules/audio-buffer/index.js +0 -76
- package/node_modules/audio-decode/node_modules/audio-buffer/package.json +0 -37
- package/node_modules/audio-decode/node_modules/audio-buffer/readme.md +0 -56
- package/node_modules/audio-decode/node_modules/node-wav/README.md +0 -35
- package/node_modules/audio-decode/node_modules/node-wav/file.wav +0 -0
- package/node_modules/audio-decode/node_modules/node-wav/index.js +0 -291
- package/node_modules/audio-decode/node_modules/node-wav/package.json +0 -29
- package/node_modules/audio-decode/node_modules/node-wav/tests/file1.wav +0 -0
- package/node_modules/audio-decode/node_modules/node-wav/tests/test.js +0 -66
- package/node_modules/audio-decode/node_modules/node-wav/x.js +0 -12
- package/node_modules/audio-decode/node_modules/node-wav/x.json +0 -86702
- package/node_modules/audio-decode/node_modules/node-wav/x.js~ +0 -13
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/README.md +0 -320
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/dist/ogg-opus-decoder.min.js +0 -232
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/dist/ogg-opus-decoder.min.js.map +0 -1
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/dist/ogg-opus-decoder.opus-ml.min.js +0 -0
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/dist/ogg-opus-decoder.opus-ml.min.js.map +0 -1
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/index.js +0 -8
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/package.json +0 -74
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/src/OggOpusDecoder.js +0 -226
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/src/OggOpusDecoderWebWorker.js +0 -17
- package/node_modules/audio-decode/node_modules/ogg-opus-decoder/types.d.ts +0 -37
- package/node_modules/audio-decode/node_modules/opus-decoder/README.md +0 -265
- package/node_modules/audio-decode/node_modules/opus-decoder/dist/opus-decoder.min.js +0 -232
- package/node_modules/audio-decode/node_modules/opus-decoder/dist/opus-decoder.min.js.map +0 -1
- package/node_modules/audio-decode/node_modules/opus-decoder/index.js +0 -8
- package/node_modules/audio-decode/node_modules/opus-decoder/package.json +0 -56
- package/node_modules/audio-decode/node_modules/opus-decoder/src/EmscriptenWasm.js +0 -0
- package/node_modules/audio-decode/node_modules/opus-decoder/src/OpusDecoder.js +0 -239
- package/node_modules/audio-decode/node_modules/opus-decoder/src/OpusDecoderWebWorker.js +0 -17
- package/node_modules/audio-decode/node_modules/opus-decoder/types.d.ts +0 -74
- package/node_modules/audio-decode/readme.md +0 -49
- package/node_modules/audio-decode/tea.yaml +0 -6
- package/node_modules/audio-decode/test-case.js +0 -11
- package/node_modules/audio-decode/test.html +0 -15
- package/node_modules/audio-decode/test.js +0 -107
- /package/node_modules/typebox/build/guard/{string.d.mts → unicode/unicode_segment.d.mts} +0 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MP4 / MOV / M4A / M4V / 3GP audio decoder — ISO BMFF demuxer that routes the audio track to a codec:
|
|
3
|
+
* AAC, ALAC → @audio/decode-aac · MP3 → @audio/decode-mp3 · FLAC → @audio/decode-flac
|
|
4
|
+
* Opus → @audio/decode-opus/core · AMR → @audio/decode-amr · AC-3 → @audio/decode-ac3 · E-AC-3 → @audio/decode-eac3
|
|
5
|
+
* DTS → @audio/decode-dts · PCM / µ-law / A-law inline.
|
|
6
|
+
*
|
|
7
|
+
* let { channelData, sampleRate } = await decode(mp4buf)
|
|
8
|
+
* let dec = await decoder(); let result = await dec.decode(chunk)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const EMPTY = Object.freeze({ channelData: [], sampleRate: 0 })
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Whole-file decode
|
|
15
|
+
* @param {Uint8Array|ArrayBuffer} src
|
|
16
|
+
* @returns {Promise<{channelData: Float32Array[], sampleRate: number}>}
|
|
17
|
+
*/
|
|
18
|
+
export default async function decode(src) {
|
|
19
|
+
if (!src || typeof src === 'string' || !(src.buffer || src.byteLength != null || src.length))
|
|
20
|
+
throw TypeError('Expected ArrayBuffer or Uint8Array')
|
|
21
|
+
let buf = src instanceof Uint8Array ? src : new Uint8Array(src.buffer || src)
|
|
22
|
+
let dec = new MP4Decoder()
|
|
23
|
+
try {
|
|
24
|
+
let result = await dec.decode(buf)
|
|
25
|
+
return merge(result, await dec.flush())
|
|
26
|
+
} finally { dec.free() }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Create streaming decoder instance. decode() is synchronous once the track header (moov) has been
|
|
31
|
+
* seen; the call that completes the header returns a Promise while the codec module loads.
|
|
32
|
+
*/
|
|
33
|
+
export async function decoder() {
|
|
34
|
+
return new MP4Decoder()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
class MP4Decoder {
|
|
38
|
+
constructor() {
|
|
39
|
+
this.accum = [] // header accumulator (until moov is complete)
|
|
40
|
+
this.accumLen = 0
|
|
41
|
+
this.pending = null // codec load in flight
|
|
42
|
+
this.codec = null // { feed(frames), flush(), free() }
|
|
43
|
+
this.st = null // sample-table walker: { sizes, stco, stsc, idx, ci, sInC, spc, nextOff }
|
|
44
|
+
this.left = null // unconsumed bytes
|
|
45
|
+
this.fileOff = 0 // absolute file offset of left[0]
|
|
46
|
+
this.skip = 0 // bytes to discard before the next sample
|
|
47
|
+
this.freed = false
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
decode(data) {
|
|
51
|
+
if (this.freed) throw Error('Decoder already freed')
|
|
52
|
+
if (!data || !data.byteLength) return EMPTY
|
|
53
|
+
let buf = data instanceof Uint8Array ? data : new Uint8Array(data)
|
|
54
|
+
if (this.pending) return this.pending.then(() => this.decode(buf))
|
|
55
|
+
if (this.st) return this.feed(buf)
|
|
56
|
+
|
|
57
|
+
this.accum.push(buf); this.accumLen += buf.length
|
|
58
|
+
let all = this.accum.length === 1 ? this.accum[0] : concat(this.accum, this.accumLen)
|
|
59
|
+
let track = parseTrack(all)
|
|
60
|
+
if (!track) return EMPTY // moov not complete yet
|
|
61
|
+
this.accum = []; this.accumLen = 0
|
|
62
|
+
return this.pending = createCodec(track).then(codec => {
|
|
63
|
+
this.pending = null
|
|
64
|
+
if (this.freed) { codec.free(); return EMPTY }
|
|
65
|
+
this.codec = codec
|
|
66
|
+
let { sizes, stco, stsc } = track
|
|
67
|
+
this.st = { sizes, stco, stsc, idx: 0, ci: 0, sInC: 0, spc: spcAt(0, stsc), nextOff: stco[0] }
|
|
68
|
+
this.left = all; this.fileOff = 0; this.skip = 0
|
|
69
|
+
return this.extract()
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
feed(buf) {
|
|
74
|
+
if (this.skip > 0) {
|
|
75
|
+
let n = Math.min(this.skip, buf.length)
|
|
76
|
+
this.skip -= n; this.fileOff += n
|
|
77
|
+
buf = buf.subarray(n)
|
|
78
|
+
if (!buf.length) return EMPTY
|
|
79
|
+
}
|
|
80
|
+
this.left = append(this.left, buf)
|
|
81
|
+
return this.extract()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Walk sample tables by absolute file offset so chunk boundaries are irrelevant.
|
|
85
|
+
extract() {
|
|
86
|
+
let st = this.st, frames = []
|
|
87
|
+
while (st.idx < st.sizes.length) {
|
|
88
|
+
let off = st.nextOff, sz = st.sizes[st.idx]
|
|
89
|
+
let bufOff = off - this.fileOff
|
|
90
|
+
if (bufOff + sz > this.left.length) break
|
|
91
|
+
if (bufOff >= 0) frames.push(this.left.subarray(bufOff, bufOff + sz))
|
|
92
|
+
advance(st)
|
|
93
|
+
}
|
|
94
|
+
if (st.idx < st.sizes.length) {
|
|
95
|
+
let nextOff = st.nextOff, end = this.fileOff + this.left.length
|
|
96
|
+
if (nextOff >= end) { this.skip = nextOff - end; this.fileOff = end; this.left = null }
|
|
97
|
+
else if (nextOff > this.fileOff) { this.left = this.left.subarray(nextOff - this.fileOff).slice(); this.fileOff = nextOff }
|
|
98
|
+
} else this.left = null
|
|
99
|
+
return frames.length ? this.codec.feed(frames) : EMPTY
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
flush() {
|
|
103
|
+
if (this.freed) return EMPTY
|
|
104
|
+
if (this.pending) return this.pending.then(() => this.flush())
|
|
105
|
+
this.freed = true
|
|
106
|
+
if (!this.codec) {
|
|
107
|
+
if (this.accumLen && findBox(concat(this.accum, this.accumLen), 'moof')) throw Error('Fragmented MP4 is not supported')
|
|
108
|
+
throw Error(this.accumLen ? 'No audio track found in MP4' : 'Not an MP4 file')
|
|
109
|
+
}
|
|
110
|
+
try { return this.codec.flush() } finally { this.codec.free(); this.codec = null; this.left = null }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
free() {
|
|
114
|
+
if (this.freed) return
|
|
115
|
+
this.freed = true
|
|
116
|
+
this.codec?.free(); this.codec = null
|
|
117
|
+
this.accum = []; this.left = null; this.st = null
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
// ===== ISO BMFF demuxer =====
|
|
123
|
+
|
|
124
|
+
const CONTAINERS = new Set(['moov', 'trak', 'mdia', 'minf', 'stbl', 'udta', 'edts', 'sinf', 'wave'])
|
|
125
|
+
|
|
126
|
+
/** Walk boxes in [start, end), calling cb(type, body, bodyOff) for leaves and cb(type, null) at container boundaries. */
|
|
127
|
+
function walk(buf, start, end, cb) {
|
|
128
|
+
let off = start
|
|
129
|
+
while (off < end - 8) {
|
|
130
|
+
let size = r32(buf, off)
|
|
131
|
+
let type = str4(buf, off + 4)
|
|
132
|
+
if (size === 0) size = end - off
|
|
133
|
+
else if (size === 1 && off + 16 <= end) { size = r32(buf, off + 12); if (size < 16) break }
|
|
134
|
+
else if (size < 8) break
|
|
135
|
+
if (type === 'mdat') { off += size; continue } // raw samples — read by offset later
|
|
136
|
+
if (off + size > end) return false // truncated box: wait for more data
|
|
137
|
+
let body = off + 8
|
|
138
|
+
if (type === 'stsd') parseStsd(buf, body, off + size, cb)
|
|
139
|
+
else if (type === 'meta') walk(buf, body + 4, off + size, cb)
|
|
140
|
+
else if (CONTAINERS.has(type)) { cb(type, null); walk(buf, body, off + size, cb); cb('/' + type, null) }
|
|
141
|
+
else cb(type, buf.subarray(body, off + size), body)
|
|
142
|
+
off += size
|
|
143
|
+
}
|
|
144
|
+
return true
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function findBox(buf, name) {
|
|
148
|
+
let found = false
|
|
149
|
+
walk(buf, 0, buf.length, type => { if (type === name) found = true })
|
|
150
|
+
return found
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// QuickTime sound sample description: v0 = 36-byte header, v1 adds 16 bytes, v2 declares its own size.
|
|
154
|
+
function parseStsd(buf, off, end, cb) {
|
|
155
|
+
let n = r32(buf, off + 4), pos = off + 8
|
|
156
|
+
for (let i = 0; i < n && pos + 16 <= end; i++) {
|
|
157
|
+
let size = r32(buf, pos), type = str4(buf, pos + 4)
|
|
158
|
+
if (size < 16) break
|
|
159
|
+
let ver = r16(buf, pos + 16)
|
|
160
|
+
let e = { type, ver }
|
|
161
|
+
if (ver === 2) {
|
|
162
|
+
let dv = new DataView(buf.buffer, buf.byteOffset)
|
|
163
|
+
e.sampleRate = dv.getFloat64(pos + 40)
|
|
164
|
+
e.channels = r32(buf, pos + 48)
|
|
165
|
+
e.bits = r32(buf, pos + 56)
|
|
166
|
+
e.flags = r32(buf, pos + 60)
|
|
167
|
+
e.head = r32(buf, pos + 36) || 72
|
|
168
|
+
} else {
|
|
169
|
+
e.channels = r16(buf, pos + 24)
|
|
170
|
+
e.bits = r16(buf, pos + 26)
|
|
171
|
+
e.sampleRate = r16(buf, pos + 32) // 16.16 fixed — integer part
|
|
172
|
+
e.head = ver === 1 ? 52 : 36
|
|
173
|
+
}
|
|
174
|
+
cb('entry', e)
|
|
175
|
+
if (size > e.head) walk(buf, pos + e.head, pos + size, cb)
|
|
176
|
+
pos += size
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Parse the first audio track out of a complete moov. Returns null while moov is incomplete or absent. */
|
|
181
|
+
function parseTrack(buf) {
|
|
182
|
+
let traks = [], t = null, moov = false
|
|
183
|
+
walk(buf, 0, buf.length, (type, data, off) => {
|
|
184
|
+
if (type === 'moov') moov = true
|
|
185
|
+
else if (type === 'trak') traks.push(t = { children: {} })
|
|
186
|
+
else if (!t) return
|
|
187
|
+
else if (type === 'hdlr') t.handler = str4(data, 8)
|
|
188
|
+
else if (type === 'mdhd') t.timescale = r32(data, data[0] === 1 ? 20 : 12)
|
|
189
|
+
else if (type === 'entry') t.entry ??= data
|
|
190
|
+
else if (type === 'stsz') t.sizes = parseStsz(data)
|
|
191
|
+
else if (type === 'stco') t.stco = parseStco(data)
|
|
192
|
+
else if (type === 'co64') t.stco = parseCo64(data)
|
|
193
|
+
else if (type === 'stsc') t.stsc = parseStsc(data)
|
|
194
|
+
else if (data) t.children[type] ??= data
|
|
195
|
+
})
|
|
196
|
+
if (!moov) return null
|
|
197
|
+
let track = traks.find(t => t.handler === 'soun' && t.entry) ?? traks.find(t => t.entry && AUDIO_TYPES.has(t.entry.type))
|
|
198
|
+
if (!track) throw Error('No audio track found in MP4')
|
|
199
|
+
if (!track.sizes || !track.stco?.length) throw Error('Audio track has no sample tables')
|
|
200
|
+
if (!track.entry.sampleRate && track.timescale) track.entry.sampleRate = track.timescale
|
|
201
|
+
return track
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const AUDIO_TYPES = new Set(['mp4a', 'alac', '.mp3', 'fLaC', 'Opus', 'sowt', 'twos', 'in24', 'in32', 'fl32', 'fl64', 'lpcm', 'ipcm', 'fpcm', 'raw ', 'NONE', 'ulaw', 'alaw', 'samr', 'sawb', 'ac-3', 'ec-3'])
|
|
205
|
+
|
|
206
|
+
/** esds → { oti, dsi } (objectTypeIndication + DecoderSpecificInfo) */
|
|
207
|
+
function parseEsds(data) {
|
|
208
|
+
let off = 4, oti = 0
|
|
209
|
+
while (off < data.length - 2) {
|
|
210
|
+
let tag = data[off++], len = 0, b
|
|
211
|
+
do { b = data[off++]; len = (len << 7) | (b & 0x7f) } while (b & 0x80 && off < data.length)
|
|
212
|
+
if (tag === 0x03) off += 3
|
|
213
|
+
else if (tag === 0x04) { oti = data[off]; off += 13 }
|
|
214
|
+
else if (tag === 0x05) return { oti, dsi: data.subarray(off, off + len) }
|
|
215
|
+
else off += len
|
|
216
|
+
}
|
|
217
|
+
return { oti, dsi: null }
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function parseStsz(d) {
|
|
221
|
+
let sz = r32(d, 4), n = r32(d, 8)
|
|
222
|
+
if (sz) return new Array(n).fill(sz)
|
|
223
|
+
let sizes = new Array(n)
|
|
224
|
+
for (let i = 0; i < n; i++) sizes[i] = r32(d, 12 + i * 4)
|
|
225
|
+
return sizes
|
|
226
|
+
}
|
|
227
|
+
function parseStco(d) { let n = r32(d, 4), o = new Array(n); for (let i = 0; i < n; i++) o[i] = r32(d, 8 + i * 4); return o }
|
|
228
|
+
function parseCo64(d) { let n = r32(d, 4), o = new Array(n); for (let i = 0; i < n; i++) o[i] = r32(d, 8 + i * 8) * 0x100000000 + r32(d, 12 + i * 8); return o }
|
|
229
|
+
function parseStsc(d) { let n = r32(d, 4), e = new Array(n); for (let i = 0; i < n; i++) e[i] = { first: r32(d, 8 + i * 12), spc: r32(d, 12 + i * 12) }; return e }
|
|
230
|
+
|
|
231
|
+
function spcAt(ci, stsc) {
|
|
232
|
+
if (!stsc?.length) return 1
|
|
233
|
+
let spc = 1, cn = ci + 1
|
|
234
|
+
for (let j = stsc.length - 1; j >= 0; j--) if (cn >= stsc[j].first) { spc = stsc[j].spc; break }
|
|
235
|
+
return spc
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function advance(st) {
|
|
239
|
+
st.nextOff += st.sizes[st.idx]
|
|
240
|
+
st.idx++; st.sInC++
|
|
241
|
+
if (st.sInC >= st.spc && st.ci + 1 < st.stco.length) {
|
|
242
|
+
st.ci++; st.sInC = 0
|
|
243
|
+
st.spc = spcAt(st.ci, st.stsc)
|
|
244
|
+
st.nextOff = st.stco[st.ci]
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
// ===== codec routing =====
|
|
250
|
+
|
|
251
|
+
const MP3_OTI = new Set([0x69, 0x6B]), AAC_OTI = new Set([0x40, 0x66, 0x67, 0x68])
|
|
252
|
+
const UNSUPPORTED = { 0xE1: 'QCELP' }
|
|
253
|
+
const DTS_TYPES = new Set(['dtsc', 'dtsh', 'dtsl', 'dtse']) // DTS-HD variants carry a decodable core
|
|
254
|
+
|
|
255
|
+
async function createCodec({ entry, children }) {
|
|
256
|
+
let { type } = entry
|
|
257
|
+
if (type === 'mp4a') {
|
|
258
|
+
let { oti, dsi } = children.esds ? parseEsds(children.esds) : {}
|
|
259
|
+
if (MP3_OTI.has(oti)) return frames(import('@audio/decode-mp3'))
|
|
260
|
+
if (oti === 0xA5) return frames(import('@audio/decode-ac3'))
|
|
261
|
+
if (oti === 0xA9) return frames(import('@audio/decode-dts'))
|
|
262
|
+
if (oti === 0xA6) return frames(import('@audio/decode-eac3'))
|
|
263
|
+
if (!oti || AAC_OTI.has(oti)) {
|
|
264
|
+
if (!dsi) throw Error('MP4 AAC track has no AudioSpecificConfig')
|
|
265
|
+
return aac({ asc: dsi })
|
|
266
|
+
}
|
|
267
|
+
throw unsupported(UNSUPPORTED[oti] || 'esds object type 0x' + oti.toString(16))
|
|
268
|
+
}
|
|
269
|
+
if (type === 'alac') {
|
|
270
|
+
if (!children.alac) throw Error('MP4 ALAC track has no magic cookie')
|
|
271
|
+
return aac({ alac: children.alac })
|
|
272
|
+
}
|
|
273
|
+
if (type === '.mp3') return frames(import('@audio/decode-mp3'))
|
|
274
|
+
if (type === 'fLaC') {
|
|
275
|
+
if (!children.dfLa) throw Error('MP4 FLAC track has no dfLa box')
|
|
276
|
+
return flac(children.dfLa.subarray(4))
|
|
277
|
+
}
|
|
278
|
+
if (type === 'Opus') {
|
|
279
|
+
if (!children.dOps) throw Error('MP4 Opus track has no dOps box')
|
|
280
|
+
return opus(children.dOps)
|
|
281
|
+
}
|
|
282
|
+
if (type === 'samr' || type === 'sawb') return amr(type === 'sawb')
|
|
283
|
+
if (type === 'ac-3') return frames(import('@audio/decode-ac3'))
|
|
284
|
+
if (type === 'ec-3') return frames(import('@audio/decode-eac3'))
|
|
285
|
+
if (DTS_TYPES.has(type)) return frames(import('@audio/decode-dts'))
|
|
286
|
+
let fmt = pcmFormat(entry, children)
|
|
287
|
+
if (fmt) return pcm(fmt)
|
|
288
|
+
throw unsupported(UNSUPPORTED[type] || type)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function unsupported(name) { return Error('Unsupported MP4 audio codec: ' + name) }
|
|
292
|
+
|
|
293
|
+
function pcmFormat(e, ch) {
|
|
294
|
+
let { type, channels, bits, sampleRate } = e
|
|
295
|
+
let f = { channels, sampleRate, bits, float: false, be: false, signed: true }
|
|
296
|
+
let enda = ch.enda ? r16(ch.enda, 0) === 1 : null // QuickTime endianness flag: 1 = little
|
|
297
|
+
switch (type) {
|
|
298
|
+
case 'sowt': f.bits = bits || 16; break
|
|
299
|
+
case 'twos': f.bits = bits || 16; f.be = true; break
|
|
300
|
+
case 'in24': f.bits = 24; f.be = !enda; break
|
|
301
|
+
case 'in32': f.bits = 32; f.be = !enda; break
|
|
302
|
+
case 'fl32': f.bits = 32; f.float = true; f.be = !enda; break
|
|
303
|
+
case 'fl64': f.bits = 64; f.float = true; f.be = !enda; break
|
|
304
|
+
case 'raw ': case 'NONE': f.bits = bits || 8; f.signed = f.bits > 8; break
|
|
305
|
+
case 'ulaw': f.bits = 8; f.law = 'u'; break
|
|
306
|
+
case 'alaw': f.bits = 8; f.law = 'a'; break
|
|
307
|
+
case 'lpcm': f.float = !!(e.flags & 1); f.be = !!(e.flags & 2); f.signed = !!(e.flags & 4) || f.float; break
|
|
308
|
+
case 'ipcm': case 'fpcm': {
|
|
309
|
+
let c = ch.pcmC
|
|
310
|
+
if (!c) return null
|
|
311
|
+
f.float = type === 'fpcm'; f.be = !(c[4] & 1); f.bits = c[5]
|
|
312
|
+
break
|
|
313
|
+
}
|
|
314
|
+
default: return null
|
|
315
|
+
}
|
|
316
|
+
if (!f.channels || !f.sampleRate || !f.bits) return null
|
|
317
|
+
return f
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// --- adapters: { feed(frames: Uint8Array[]), flush(), free() } ---
|
|
321
|
+
|
|
322
|
+
async function aac(opts) {
|
|
323
|
+
let dec = await (await import('@audio/decode-aac')).decoder(opts)
|
|
324
|
+
return { feed: frames => dec.decode(frames), flush: () => dec.flush(), free: () => dec.free() }
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// self-synchronizing frame streams (MP3, AC-3, DTS): the codec resyncs on concatenated samples
|
|
328
|
+
async function frames(load) {
|
|
329
|
+
let dec = await (await load).decoder()
|
|
330
|
+
return { feed: frames => dec.decode(concat(frames)), flush: () => dec.flush?.() ?? EMPTY, free: () => dec.free() }
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
async function flac(blocks) {
|
|
334
|
+
let dec = await (await import('@audio/decode-flac')).decoder()
|
|
335
|
+
let head = concat([new Uint8Array([0x66, 0x4C, 0x61, 0x43]), blocks]) // "fLaC" + METADATA_BLOCKs
|
|
336
|
+
let started = false
|
|
337
|
+
return {
|
|
338
|
+
feed: frames => { let bytes = concat(frames); if (!started) { started = true; bytes = concat([head, bytes]) } return dec.decode(bytes) },
|
|
339
|
+
flush: () => started ? dec.flush() : EMPTY,
|
|
340
|
+
free: () => dec.free()
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
async function opus(dOps) {
|
|
345
|
+
let channels = dOps[1]
|
|
346
|
+
let opts = { channels, sampleRate: 48000, preSkip: r16(dOps, 2), outputGain: (r16(dOps, 8) << 16) >> 16 }
|
|
347
|
+
if (dOps[10] > 0) {
|
|
348
|
+
opts.streamCount = dOps[11]; opts.coupledStreamCount = dOps[12]
|
|
349
|
+
opts.channelMappingTable = Array.from(dOps.subarray(13, 13 + channels))
|
|
350
|
+
}
|
|
351
|
+
let dec = await (await import('@audio/decode-opus/core')).createOpusDecoder()
|
|
352
|
+
dec.configure(opts)
|
|
353
|
+
return {
|
|
354
|
+
feed: frames => {
|
|
355
|
+
let r = dec.decodeFrames(frames)
|
|
356
|
+
if (!r.samplesDecoded) return EMPTY
|
|
357
|
+
return { channelData: r.channelData.map(c => c.subarray(0, r.samplesDecoded)), sampleRate: r.sampleRate }
|
|
358
|
+
},
|
|
359
|
+
flush: () => EMPTY,
|
|
360
|
+
free: () => dec.free()
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
async function amr(wb) {
|
|
365
|
+
let dec = await (await import('@audio/decode-amr')).decoder()
|
|
366
|
+
let magic = new TextEncoder().encode(wb ? '#!AMR-WB\n' : '#!AMR\n'), started = false
|
|
367
|
+
return {
|
|
368
|
+
feed: frames => { let bytes = concat(frames); if (!started) { started = true; bytes = concat([magic, bytes]) } return dec.decode(bytes) },
|
|
369
|
+
flush: () => dec.flush?.() ?? EMPTY,
|
|
370
|
+
free: () => dec.free()
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// interleaved PCM → planar float. Keeps a partial frame between calls.
|
|
375
|
+
function pcm({ channels, sampleRate, bits, float, be, signed, law }) {
|
|
376
|
+
let bps = bits >> 3, frame = bps * channels, left = null
|
|
377
|
+
let read = law === 'u' ? ulaw : law === 'a' ? alaw : reader(bits, float, be, signed)
|
|
378
|
+
return {
|
|
379
|
+
feed(frames) {
|
|
380
|
+
let buf = concat(left ? [left, ...frames] : frames)
|
|
381
|
+
let n = Math.floor(buf.length / frame)
|
|
382
|
+
left = n * frame < buf.length ? buf.slice(n * frame) : null
|
|
383
|
+
if (!n) return EMPTY
|
|
384
|
+
let dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
385
|
+
let channelData = Array.from({ length: channels }, () => new Float32Array(n))
|
|
386
|
+
for (let i = 0, off = 0; i < n; i++)
|
|
387
|
+
for (let c = 0; c < channels; c++, off += bps) channelData[c][i] = read(dv, off)
|
|
388
|
+
return { channelData, sampleRate }
|
|
389
|
+
},
|
|
390
|
+
flush: () => EMPTY,
|
|
391
|
+
free() { left = null }
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function reader(bits, float, be, signed) {
|
|
396
|
+
let le = !be
|
|
397
|
+
if (float) return bits === 64 ? (dv, o) => dv.getFloat64(o, le) : (dv, o) => dv.getFloat32(o, le)
|
|
398
|
+
switch (bits) {
|
|
399
|
+
case 8: return signed ? (dv, o) => dv.getInt8(o) / 128 : (dv, o) => (dv.getUint8(o) - 128) / 128
|
|
400
|
+
case 16: return (dv, o) => dv.getInt16(o, le) / 32768
|
|
401
|
+
case 24: return be
|
|
402
|
+
? (dv, o) => ((dv.getUint8(o) << 24 | dv.getUint8(o + 1) << 16 | dv.getUint8(o + 2) << 8) >> 8) / 8388608
|
|
403
|
+
: (dv, o) => ((dv.getUint8(o + 2) << 24 | dv.getUint8(o + 1) << 16 | dv.getUint8(o) << 8) >> 8) / 8388608
|
|
404
|
+
case 32: return (dv, o) => dv.getInt32(o, le) / 2147483648
|
|
405
|
+
}
|
|
406
|
+
throw Error('Unsupported PCM bit depth: ' + bits)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// ITU-T G.711
|
|
410
|
+
function ulaw(dv, o) {
|
|
411
|
+
let u = ~dv.getUint8(o) & 0xFF
|
|
412
|
+
let t = (((u & 0x0F) << 3) + 0x84) << ((u & 0x70) >> 4)
|
|
413
|
+
return ((u & 0x80) ? 0x84 - t : t - 0x84) / 32768
|
|
414
|
+
}
|
|
415
|
+
function alaw(dv, o) {
|
|
416
|
+
let a = dv.getUint8(o) ^ 0x55
|
|
417
|
+
let t = (a & 0x0F) << 4, seg = (a & 0x70) >> 4
|
|
418
|
+
t = seg === 0 ? t + 8 : seg === 1 ? t + 0x108 : (t + 0x108) << (seg - 1)
|
|
419
|
+
return ((a & 0x80) ? t : -t) / 32768
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
// ===== helpers =====
|
|
424
|
+
|
|
425
|
+
function r32(b, o) { return (b[o] << 24 | b[o + 1] << 16 | b[o + 2] << 8 | b[o + 3]) >>> 0 }
|
|
426
|
+
function r16(b, o) { return b[o] << 8 | b[o + 1] }
|
|
427
|
+
function str4(b, o) { return String.fromCharCode(b[o], b[o + 1], b[o + 2], b[o + 3]) }
|
|
428
|
+
|
|
429
|
+
function append(left, buf) {
|
|
430
|
+
if (!left?.length) return buf.slice()
|
|
431
|
+
let out = new Uint8Array(left.length + buf.length)
|
|
432
|
+
out.set(left); out.set(buf, left.length)
|
|
433
|
+
return out
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function concat(parts, total) {
|
|
437
|
+
if (parts.length === 1) return parts[0]
|
|
438
|
+
if (total == null) { total = 0; for (let p of parts) total += p.length }
|
|
439
|
+
let out = new Uint8Array(total), off = 0
|
|
440
|
+
for (let p of parts) { out.set(p, off); off += p.length }
|
|
441
|
+
return out
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function merge(a, b) {
|
|
445
|
+
if (!b?.channelData?.length) return a
|
|
446
|
+
if (!a?.channelData?.length) return b
|
|
447
|
+
return {
|
|
448
|
+
channelData: a.channelData.map((ch, i) => {
|
|
449
|
+
let m = new Float32Array(ch.length + b.channelData[i].length)
|
|
450
|
+
m.set(ch); m.set(b.channelData[i], ch.length)
|
|
451
|
+
return m
|
|
452
|
+
}),
|
|
453
|
+
sampleRate: a.sampleRate
|
|
454
|
+
}
|
|
455
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@audio/decode-mp4",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Decode the audio track of MP4, MOV, M4A, M4V and 3GP files (AAC, ALAC, MP3, FLAC, Opus, AMR, PCM) to PCM samples",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "decode-mp4.js",
|
|
7
|
+
"types": "decode-mp4.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./decode-mp4.js",
|
|
10
|
+
"./audio": {
|
|
11
|
+
"types": "./audio.d.ts",
|
|
12
|
+
"default": "./audio.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "node test.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"decode-mp4.js",
|
|
24
|
+
"decode-mp4.d.ts",
|
|
25
|
+
"audio.js",
|
|
26
|
+
"audio.d.ts",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@audio/decode-aac": "^1.5.0",
|
|
31
|
+
"@audio/decode-ac3": "^1.0.0",
|
|
32
|
+
"@audio/decode-amr": "^1.3.0",
|
|
33
|
+
"@audio/decode-dts": "^1.0.0",
|
|
34
|
+
"@audio/decode-flac": "^1.3.0",
|
|
35
|
+
"@audio/decode-mp3": "^1.3.0",
|
|
36
|
+
"@audio/decode-opus": "^1.3.0",
|
|
37
|
+
"@audio/decode-eac3": "^1.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"tst": "^9.2.2"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"mp4",
|
|
47
|
+
"mov",
|
|
48
|
+
"m4a",
|
|
49
|
+
"m4v",
|
|
50
|
+
"3gp",
|
|
51
|
+
"quicktime",
|
|
52
|
+
"isobmff",
|
|
53
|
+
"demux",
|
|
54
|
+
"video",
|
|
55
|
+
"audio",
|
|
56
|
+
"decode",
|
|
57
|
+
"decoder",
|
|
58
|
+
"aac",
|
|
59
|
+
"alac",
|
|
60
|
+
"pcm"
|
|
61
|
+
],
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"author": "audiojs",
|
|
64
|
+
"homepage": "https://github.com/audiojs/decode/tree/main/packages/decode-mp4",
|
|
65
|
+
"repository": {
|
|
66
|
+
"type": "git",
|
|
67
|
+
"url": "git+https://github.com/audiojs/decode.git",
|
|
68
|
+
"directory": "packages/decode-mp4"
|
|
69
|
+
},
|
|
70
|
+
"bugs": "https://github.com/audiojs/decode/issues",
|
|
71
|
+
"audio": "./audio.js",
|
|
72
|
+
"sideEffects": false,
|
|
73
|
+
"funding": "https://github.com/sponsors/audiojs"
|
|
74
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
This work is offered to Krishna (https://github.com/krishnized/license).
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 audiojs
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are
|
|
7
|
+
met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright
|
|
10
|
+
notice, this list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above
|
|
13
|
+
copyright notice, this list of conditions and the following
|
|
14
|
+
disclaimer in the documentation and/or other materials provided
|
|
15
|
+
with the distribution.
|
|
16
|
+
|
|
17
|
+
* Neither the name of audiojs nor the names of its contributors
|
|
18
|
+
may be used to endorse or promote products derived from this
|
|
19
|
+
software without specific prior written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
25
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
26
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
27
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
28
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
29
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
30
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Copyright (c) 2005, The Musepack Development Team
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are
|
|
6
|
+
met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above
|
|
12
|
+
copyright notice, this list of conditions and the following
|
|
13
|
+
disclaimer in the documentation and/or other materials provided
|
|
14
|
+
with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the The Musepack Development Team nor the
|
|
17
|
+
names of its contributors may be used to endorse or promote
|
|
18
|
+
products derived from this software without specific prior
|
|
19
|
+
written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
25
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
26
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
27
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
28
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
29
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
30
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# @audio/decode-mpc
|
|
2
|
+
|
|
3
|
+
Decode Musepack (MPC) to PCM float samples.<br>
|
|
4
|
+
[libmpcdec](https://svn.musepack.net/libmpc/) (mirrored at [evpobr/libmpc](https://github.com/evpobr/libmpc)) compiled to a single-file WASM ES module — no side files, loads from any CDN, Node, workers and AudioWorklets.
|
|
5
|
+
|
|
6
|
+
[](https://npmjs.org/package/@audio/decode-mpc/)
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
import decode, { decoder } from '@audio/decode-mpc'
|
|
10
|
+
|
|
11
|
+
let { channelData, sampleRate } = await decode(mpcBytes)
|
|
12
|
+
|
|
13
|
+
let dec = await decoder()
|
|
14
|
+
let head = dec.decode(chunk1) // synchronous; returns whatever the bytes seen so far allow
|
|
15
|
+
let tail = dec.flush()
|
|
16
|
+
dec.free()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Decodes both stream generations: SV7 (`MP+` magic, 1999–2006 era encoders) and SV8 (`MPCK` magic, current). The demuxer (container framing, APEv2/ID3v1 tags, seek tables) runs inside libmpcdec itself; this package only feeds it bytes. Mono or stereo, whatever the stream declares. Built with `MPC_FIXED_POINT` off, so libmpcdec hands back native float samples — no fixed-point requantization step.
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### `decode(src: Uint8Array | ArrayBuffer): Promise<AudioData>`
|
|
24
|
+
|
|
25
|
+
Decode a complete stream. Throws if the input never parses as Musepack (no `MP+`/`MPCK` magic, or a header that still won't parse after a generous budget).
|
|
26
|
+
|
|
27
|
+
### `decoder(): Promise<MpcDecoder>`
|
|
28
|
+
|
|
29
|
+
Streaming decoder: `decode(chunk)` returns the samples of every complete frame the data seen so far allows, `flush()` decodes anything a safety margin was withholding at the true end of stream, `free()` releases WASM memory. `errors` counts frames abandoned after a bitstream desync (see Streaming below — this stops the decoder, it does not resync and skip).
|
|
30
|
+
|
|
31
|
+
### `AudioData`
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
{ channelData: Float32Array[], sampleRate: number }
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Streaming
|
|
38
|
+
|
|
39
|
+
`decode(chunk)` feeds bytes into a growable buffer inside WASM and retries `mpc_demux_init()` on every call until the header parses — libmpcdec's `mpc_reader` callback interface has no "not enough data yet" signal distinct from "end of stream," and a frame decode that runs out of buffered bytes mid-frame leaves the bitstream position permanently desynced (no retry). So frames are only decoded once at least 4352 bytes (`MAX_FRAME_SIZE`, libmpcdec's own worst-case compressed frame size) are buffered ahead of the reader's cursor — safe for any chunk size, including 1 byte at a time.
|
|
40
|
+
|
|
41
|
+
What that means in practice differs by version:
|
|
42
|
+
|
|
43
|
+
- **SV7** streams genuinely progressively. Its header is a fixed ~30 bytes with no forward references, so `decoder()` starts emitting frames as soon as the first chunk carries that much.
|
|
44
|
+
- **SV8** streams keep their seek table near the end of the file — `mpcenc` can only patch the header's pointer to it once encoding finishes and the final byte offset is known — and libmpcdec reads that table during `mpc_demux_init()`. In practice an SV8 `decoder()` buffers (close to) the whole stream before the first frame comes out. `decode(chunk)` never blocks or throws while this is happening; it just returns nothing until the header resolves.
|
|
45
|
+
|
|
46
|
+
Either way the input buffer is never discarded (the SV8 seek-table read can jump backward to any earlier offset), so streaming does not save memory for SV8 — only latency-to-first-decode for SV7.
|
|
47
|
+
|
|
48
|
+
## Measured
|
|
49
|
+
|
|
50
|
+
- 50,773 bytes WASM (libmpcdec `7d04739`, `-Oz -flto`, single-file ES module).
|
|
51
|
+
- ~86–89 dB SNR vs `ffmpeg -i x.mpc -f f32le -` on SV8 fixtures generated with `mpcenc`; 57–58 dB on an independent SV7 sample from the FFmpeg FATE suite (own encode vs. own decode of the exact same bits, so the higher SV8 number just reflects less inter-decoder disagreement, not different codec fidelity).
|
|
52
|
+
- ~1250× realtime (a 0.5 s clip decodes in ~0.4 ms; a 5.8 s clip in ~4.6 ms; Apple M-series, Node 25).
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
[ॐ](https://github.com/krishnized/license/) · [BSD-3-Clause](./LICENSE), matching the bundled [libmpcdec](./LICENSE.libmpcdec).
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
Part of [@audio/decode](https://github.com/audiojs/decode) — the decode family umbrella.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Generated from the audio.js manifest (params metadata is the source of truth).
|
|
2
|
+
// Regenerate: node tools/dts.js in @audio/compile. Do not edit by hand.
|
|
3
|
+
|
|
4
|
+
/** Automatable number — scalar, `t => value` fn, or breakpoint curve {t, v} */
|
|
5
|
+
type Auto = number | ((t: number) => number) | { t: number[], v: number[] }
|
|
6
|
+
/** Per-block param values as delivered by hosts (numbers arrive as 1-length Float32Array) */
|
|
7
|
+
type Live = Record<string, Float32Array | string | boolean>
|
|
8
|
+
type Ctx = { sampleRate: number, maxBlockSize: number, maxChannels: number, currentTime: number, duration?: number, events?: readonly any[], emit?: (name: string, ...args: any[]) => void, [k: string]: unknown }
|
|
9
|
+
type Process = (inputs: Float32Array[][], outputs: Float32Array[][], params: Live) => void
|
|
10
|
+
|
|
11
|
+
/** Codec plugin 'mpc' — extends audio()'s openable formats / save() targets */
|
|
12
|
+
export declare const mpc: {
|
|
13
|
+
codec: 'mpc'
|
|
14
|
+
decode(bytes: Uint8Array): { channelData: Float32Array[], sampleRate: number } | Promise<{ channelData: Float32Array[], sampleRate: number }>
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// audio.js manifest — codec atom, decode half: whole-buffer bytes → { channelData,
|
|
2
|
+
// sampleRate }. Format detection is magic-byte (audio-type) — no test() needed here.
|
|
3
|
+
|
|
4
|
+
import decodeFn from './decode-mpc.js'
|
|
5
|
+
|
|
6
|
+
export const mpc = {
|
|
7
|
+
codec: 'mpc',
|
|
8
|
+
decode: (bytes) => decodeFn(bytes),
|
|
9
|
+
}
|