@openclaw/whatsapp 2026.9.6 → 2026.9.7
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,21 @@
|
|
|
1
|
+
export interface AudioData {
|
|
2
|
+
channelData: Float32Array[];
|
|
3
|
+
sampleRate: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface AVIDecoder {
|
|
7
|
+
/**
|
|
8
|
+
* Decode an AVI chunk. Synchronous once the stream headers have been seen; the call that
|
|
9
|
+
* completes them returns a Promise while the codec module loads.
|
|
10
|
+
*/
|
|
11
|
+
decode(data: Uint8Array | ArrayBuffer): AudioData | Promise<AudioData>;
|
|
12
|
+
/** Finish the stream. Throws if no audio stream was found. */
|
|
13
|
+
flush(): AudioData | Promise<AudioData>;
|
|
14
|
+
free(): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Decode the audio stream of a complete AVI file. */
|
|
18
|
+
export default function decode(src: ArrayBuffer | Uint8Array): Promise<AudioData>;
|
|
19
|
+
|
|
20
|
+
/** Create a streaming decoder. */
|
|
21
|
+
export function decoder(): Promise<AVIDecoder>;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AVI audio decoder — RIFF/AVI demuxer (incl. OpenDML AVIX) that routes the audio stream to a codec:
|
|
3
|
+
* PCM / µ-law / A-law inline · MP3 → @audio/decode-mp3 · AAC → @audio/decode-aac · AC-3 → @audio/decode-ac3 · DTS → @audio/decode-dts.
|
|
4
|
+
*
|
|
5
|
+
* let { channelData, sampleRate } = await decode(avibuf)
|
|
6
|
+
* let dec = await decoder(); let result = await dec.decode(chunk)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const EMPTY = Object.freeze({ channelData: [], sampleRate: 0 })
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Whole-file decode
|
|
13
|
+
* @param {Uint8Array|ArrayBuffer} src
|
|
14
|
+
* @returns {Promise<{channelData: Float32Array[], sampleRate: number}>}
|
|
15
|
+
*/
|
|
16
|
+
export default async function decode(src) {
|
|
17
|
+
if (!src || typeof src === 'string' || !(src.buffer || src.byteLength != null || src.length))
|
|
18
|
+
throw TypeError('Expected ArrayBuffer or Uint8Array')
|
|
19
|
+
let buf = src instanceof Uint8Array ? src : new Uint8Array(src.buffer || src)
|
|
20
|
+
let dec = new AVIDecoder()
|
|
21
|
+
try {
|
|
22
|
+
let result = await dec.decode(buf)
|
|
23
|
+
return merge(result, await dec.flush())
|
|
24
|
+
} finally { dec.free() }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create streaming decoder instance. decode() is synchronous once the stream headers (hdrl) have
|
|
29
|
+
* been seen; the call that completes them returns a Promise while the codec module loads.
|
|
30
|
+
*/
|
|
31
|
+
export async function decoder() {
|
|
32
|
+
return new AVIDecoder()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class AVIDecoder {
|
|
36
|
+
constructor() {
|
|
37
|
+
this.left = null
|
|
38
|
+
this.pending = null
|
|
39
|
+
this.codec = null
|
|
40
|
+
this.stream = null // { index, id: 'NNwb', fmt }
|
|
41
|
+
this.streams = 0 // strl lists seen
|
|
42
|
+
this.header = false // hdrl complete
|
|
43
|
+
this.frames = [] // audio chunks queued while the codec loads
|
|
44
|
+
this.freed = false
|
|
45
|
+
this.started = false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
decode(data) {
|
|
49
|
+
if (this.freed) throw Error('Decoder already freed')
|
|
50
|
+
if (!data || !data.byteLength) return EMPTY
|
|
51
|
+
let buf = data instanceof Uint8Array ? data : new Uint8Array(data)
|
|
52
|
+
if (this.pending) return this.pending.then(() => this.decode(buf))
|
|
53
|
+
buf = append(this.left, buf); this.left = null
|
|
54
|
+
if (!this.started) {
|
|
55
|
+
if (buf.length < 12) { this.left = buf; return EMPTY }
|
|
56
|
+
if (str4(buf, 0) !== 'RIFF' || str4(buf, 8) !== 'AVI ') throw Error('Not an AVI file')
|
|
57
|
+
this.started = true
|
|
58
|
+
}
|
|
59
|
+
let frames = this.scan(buf)
|
|
60
|
+
if (this.codec) return frames.length ? this.codec.feed(frames) : EMPTY
|
|
61
|
+
this.frames.push(...frames)
|
|
62
|
+
if (!this.header) return EMPTY
|
|
63
|
+
if (!this.stream) throw Error('No audio stream found in AVI')
|
|
64
|
+
return this.pending = createCodec(this.stream.fmt).then(codec => {
|
|
65
|
+
this.pending = null
|
|
66
|
+
if (this.freed) { codec.free(); return EMPTY }
|
|
67
|
+
this.codec = codec
|
|
68
|
+
let queued = this.frames; this.frames = []
|
|
69
|
+
return queued.length ? codec.feed(queued) : EMPTY
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Chunk scanner: descends into RIFF/LIST containers, harvests the audio stream's chunks, keeps the tail.
|
|
74
|
+
scan(buf) {
|
|
75
|
+
let frames = [], pos = 0
|
|
76
|
+
while (pos + 8 <= buf.length) {
|
|
77
|
+
let id = str4(buf, pos), size = r32(buf, pos + 4)
|
|
78
|
+
if (id === 'RIFF' || id === 'LIST') {
|
|
79
|
+
if (pos + 12 > buf.length) break
|
|
80
|
+
let type = str4(buf, pos + 8)
|
|
81
|
+
if (type === 'strl') this.streams++
|
|
82
|
+
if (type === 'hdrl' || type === 'strl' || type === 'movi' || type === 'rec ' || id === 'RIFF') { pos += 12; continue } // descend
|
|
83
|
+
pos += 8 + size + (size & 1)
|
|
84
|
+
continue
|
|
85
|
+
}
|
|
86
|
+
let end = pos + 8 + size + (size & 1)
|
|
87
|
+
if (end > buf.length) {
|
|
88
|
+
if (this.stream && id === this.stream.id) break // partial audio chunk — wait
|
|
89
|
+
if (!this.header && (id === 'strh' || id === 'strf')) break // partial header
|
|
90
|
+
if (size > 0x10000000) throw Error('Corrupt AVI chunk')
|
|
91
|
+
break
|
|
92
|
+
}
|
|
93
|
+
let body = buf.subarray(pos + 8, pos + 8 + size)
|
|
94
|
+
if (!this.header) {
|
|
95
|
+
if (id === 'strh' && !this.stream && str4(body, 0) === 'auds') this.stream = { index: this.streams - 1, id: null, fmt: null }
|
|
96
|
+
else if (id === 'strf' && this.stream && this.stream.index === this.streams - 1 && !this.stream.fmt) {
|
|
97
|
+
this.stream.fmt = parseWaveFormat(body)
|
|
98
|
+
this.stream.id = String(this.stream.index).padStart(2, '0') + 'wb'
|
|
99
|
+
}
|
|
100
|
+
else if (id === 'avih') {}
|
|
101
|
+
else if (id !== 'strn' && id !== 'strd' && id !== 'indx' && id !== 'vprp' && id !== 'JUNK' && id !== 'odml' && id !== 'dmlh' && id !== 'ISFT' && this.streams && (id.endsWith('wb') || id.endsWith('dc') || id.endsWith('db') || id === 'idx1')) this.header = true
|
|
102
|
+
}
|
|
103
|
+
if (this.stream?.id && id === this.stream.id && size) { frames.push(body.slice()); this.header = true }
|
|
104
|
+
pos = end
|
|
105
|
+
}
|
|
106
|
+
if (pos < buf.length) this.left = buf.subarray(pos).slice()
|
|
107
|
+
return frames
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
flush() {
|
|
111
|
+
if (this.freed) return EMPTY
|
|
112
|
+
if (this.pending) return this.pending.then(() => this.flush())
|
|
113
|
+
this.freed = true
|
|
114
|
+
if (!this.codec) throw Error(this.started ? 'No audio stream found in AVI' : 'Not an AVI file')
|
|
115
|
+
try { return this.codec.flush() } finally { this.codec.free(); this.codec = null; this.left = null }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
free() {
|
|
119
|
+
if (this.freed) return
|
|
120
|
+
this.freed = true
|
|
121
|
+
this.codec?.free(); this.codec = null
|
|
122
|
+
this.left = null; this.frames = []
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** WAVEFORMATEX(TENSIBLE) → { tag, channels, sampleRate, bits, extra } */
|
|
127
|
+
function parseWaveFormat(b) {
|
|
128
|
+
let dv = new DataView(b.buffer, b.byteOffset, b.byteLength)
|
|
129
|
+
let f = { tag: dv.getUint16(0, true), channels: dv.getUint16(2, true), sampleRate: dv.getUint32(4, true), bits: dv.getUint16(14, true), extra: null }
|
|
130
|
+
let cb = b.length >= 18 ? dv.getUint16(16, true) : 0
|
|
131
|
+
if (f.tag === 0xFFFE && b.length >= 40) { f.tag = dv.getUint16(24, true); f.bits = dv.getUint16(18, true) || f.bits; f.extra = b.subarray(40, 18 + cb) }
|
|
132
|
+
else if (cb) f.extra = b.subarray(18, 18 + cb)
|
|
133
|
+
return f
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const NAMES = { 0x160: 'WMA v1', 0x161: 'WMA v2', 0x162: 'WMA Pro', 0x163: 'WMA Lossless', 0x50: 'MPEG-1 Layer II', 0x2: 'MS ADPCM', 0x11: 'IMA ADPCM', 0x22: 'TrueSpeech', 0x31: 'GSM 6.10', 0x8000: 'AAC' }
|
|
137
|
+
|
|
138
|
+
async function createCodec(fmt) {
|
|
139
|
+
switch (fmt.tag) {
|
|
140
|
+
case 1: return pcm({ ...fmt, float: false, signed: fmt.bits > 8 })
|
|
141
|
+
case 3: return pcm({ ...fmt, float: true, signed: true })
|
|
142
|
+
case 6: return pcm({ ...fmt, bits: 8, law: 'a' })
|
|
143
|
+
case 7: return pcm({ ...fmt, bits: 8, law: 'u' })
|
|
144
|
+
case 0x55: return frames(import('@audio/decode-mp3'))
|
|
145
|
+
case 0x2000: return frames(import('@audio/decode-ac3'))
|
|
146
|
+
case 0x2001: return frames(import('@audio/decode-dts'))
|
|
147
|
+
case 0xFF: {
|
|
148
|
+
if (!fmt.extra?.length) throw Error('AVI AAC stream has no AudioSpecificConfig')
|
|
149
|
+
let dec = await (await import('@audio/decode-aac')).decoder({ asc: fmt.extra })
|
|
150
|
+
return { feed: frames => dec.decode(frames), flush: () => dec.flush(), free: () => dec.free() }
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
throw Error('Unsupported AVI audio codec: ' + (NAMES[fmt.tag] || 'wFormatTag 0x' + fmt.tag.toString(16)))
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// self-synchronizing frame streams (MP3, AC-3, DTS): the codec resyncs on concatenated chunks
|
|
157
|
+
async function frames(load) {
|
|
158
|
+
let dec = await (await load).decoder()
|
|
159
|
+
return { feed: frames => dec.decode(concat(frames)), flush: () => dec.flush?.() ?? EMPTY, free: () => dec.free() }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// interleaved little-endian PCM → planar float. Keeps a partial frame between calls.
|
|
163
|
+
function pcm({ channels, sampleRate, bits, float, signed, law }) {
|
|
164
|
+
if (!channels || !sampleRate || !bits) throw Error('Invalid AVI PCM format')
|
|
165
|
+
let bps = bits >> 3, frame = bps * channels, left = null
|
|
166
|
+
let read = law === 'u' ? ulaw : law === 'a' ? alaw : reader(bits, float, signed)
|
|
167
|
+
return {
|
|
168
|
+
feed(frames) {
|
|
169
|
+
let buf = concat(left ? [left, ...frames] : frames)
|
|
170
|
+
let n = Math.floor(buf.length / frame)
|
|
171
|
+
left = n * frame < buf.length ? buf.slice(n * frame) : null
|
|
172
|
+
if (!n) return EMPTY
|
|
173
|
+
let dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
174
|
+
let channelData = Array.from({ length: channels }, () => new Float32Array(n))
|
|
175
|
+
for (let i = 0, off = 0; i < n; i++)
|
|
176
|
+
for (let c = 0; c < channels; c++, off += bps) channelData[c][i] = read(dv, off)
|
|
177
|
+
return { channelData, sampleRate }
|
|
178
|
+
},
|
|
179
|
+
flush: () => EMPTY,
|
|
180
|
+
free() { left = null }
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function reader(bits, float, signed) {
|
|
185
|
+
if (float) return bits === 64 ? (dv, o) => dv.getFloat64(o, true) : (dv, o) => dv.getFloat32(o, true)
|
|
186
|
+
switch (bits) {
|
|
187
|
+
case 8: return signed ? (dv, o) => dv.getInt8(o) / 128 : (dv, o) => (dv.getUint8(o) - 128) / 128
|
|
188
|
+
case 16: return (dv, o) => dv.getInt16(o, true) / 32768
|
|
189
|
+
case 24: return (dv, o) => ((dv.getUint8(o + 2) << 24 | dv.getUint8(o + 1) << 16 | dv.getUint8(o) << 8) >> 8) / 8388608
|
|
190
|
+
case 32: return (dv, o) => dv.getInt32(o, true) / 2147483648
|
|
191
|
+
}
|
|
192
|
+
throw Error('Unsupported PCM bit depth: ' + bits)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ITU-T G.711
|
|
196
|
+
function ulaw(dv, o) {
|
|
197
|
+
let u = ~dv.getUint8(o) & 0xFF
|
|
198
|
+
let t = (((u & 0x0F) << 3) + 0x84) << ((u & 0x70) >> 4)
|
|
199
|
+
return ((u & 0x80) ? 0x84 - t : t - 0x84) / 32768
|
|
200
|
+
}
|
|
201
|
+
function alaw(dv, o) {
|
|
202
|
+
let a = dv.getUint8(o) ^ 0x55
|
|
203
|
+
let t = (a & 0x0F) << 4, seg = (a & 0x70) >> 4
|
|
204
|
+
t = seg === 0 ? t + 8 : seg === 1 ? t + 0x108 : (t + 0x108) << (seg - 1)
|
|
205
|
+
return ((a & 0x80) ? t : -t) / 32768
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
// ===== helpers =====
|
|
210
|
+
|
|
211
|
+
function r32(b, o) { return (b[o] | b[o + 1] << 8 | b[o + 2] << 16 | b[o + 3] << 24) >>> 0 } // RIFF is little-endian
|
|
212
|
+
function str4(b, o) { return String.fromCharCode(b[o], b[o + 1], b[o + 2], b[o + 3]) }
|
|
213
|
+
|
|
214
|
+
function append(left, buf) {
|
|
215
|
+
if (!left?.length) return buf
|
|
216
|
+
let out = new Uint8Array(left.length + buf.length)
|
|
217
|
+
out.set(left); out.set(buf, left.length)
|
|
218
|
+
return out
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function concat(parts) {
|
|
222
|
+
if (parts.length === 1) return parts[0]
|
|
223
|
+
let total = 0
|
|
224
|
+
for (let p of parts) total += p.length
|
|
225
|
+
let out = new Uint8Array(total), off = 0
|
|
226
|
+
for (let p of parts) { out.set(p, off); off += p.length }
|
|
227
|
+
return out
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function merge(a, b) {
|
|
231
|
+
if (!b?.channelData?.length) return a
|
|
232
|
+
if (!a?.channelData?.length) return b
|
|
233
|
+
return {
|
|
234
|
+
channelData: a.channelData.map((ch, i) => {
|
|
235
|
+
let m = new Float32Array(ch.length + b.channelData[i].length)
|
|
236
|
+
m.set(ch); m.set(b.channelData[i], ch.length)
|
|
237
|
+
return m
|
|
238
|
+
}),
|
|
239
|
+
sampleRate: a.sampleRate
|
|
240
|
+
}
|
|
241
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@audio/decode-avi",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Decode the audio stream of AVI files (PCM, MP3, AAC, \u00b5-law, A-law) to PCM samples",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "decode-avi.js",
|
|
7
|
+
"types": "decode-avi.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./decode-avi.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-avi.js",
|
|
24
|
+
"decode-avi.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-dts": "^1.0.0",
|
|
33
|
+
"@audio/decode-mp3": "^1.3.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"tst": "^9.2.2"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"avi",
|
|
43
|
+
"riff",
|
|
44
|
+
"opendml",
|
|
45
|
+
"demux",
|
|
46
|
+
"video",
|
|
47
|
+
"audio",
|
|
48
|
+
"decode",
|
|
49
|
+
"decoder",
|
|
50
|
+
"pcm",
|
|
51
|
+
"mp3",
|
|
52
|
+
"aac"
|
|
53
|
+
],
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"author": "audiojs",
|
|
56
|
+
"homepage": "https://github.com/audiojs/decode/tree/main/packages/decode-avi",
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/audiojs/decode.git",
|
|
60
|
+
"directory": "packages/decode-avi"
|
|
61
|
+
},
|
|
62
|
+
"bugs": "https://github.com/audiojs/decode/issues",
|
|
63
|
+
"audio": "./audio.js",
|
|
64
|
+
"sideEffects": false,
|
|
65
|
+
"funding": "https://github.com/sponsors/audiojs"
|
|
66
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 audiojs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @audio/decode-caf
|
|
2
|
+
|
|
3
|
+
Decode Core Audio Format audio to PCM float samples.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm i @audio/decode-caf
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import decode, { decoder } from '@audio/decode-caf'
|
|
15
|
+
|
|
16
|
+
let { channelData, sampleRate } = decode(cafBytes)
|
|
17
|
+
|
|
18
|
+
let dec = decoder()
|
|
19
|
+
let result = dec.decode(chunk)
|
|
20
|
+
dec.free()
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`decode()` and `decoder()` are synchronous.
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
### `decode(src): AudioData`
|
|
28
|
+
|
|
29
|
+
Decode a complete `Uint8Array` or `ArrayBuffer`.
|
|
30
|
+
|
|
31
|
+
### `decoder(): CAFDecoder`
|
|
32
|
+
|
|
33
|
+
Create a decoder instance.
|
|
34
|
+
|
|
35
|
+
- `dec.decode(data)`: decode a chunk.
|
|
36
|
+
- `dec.flush()`: discard buffered partial data and return an empty result.
|
|
37
|
+
- `dec.free()`: release resources.
|
|
38
|
+
|
|
39
|
+
## Formats
|
|
40
|
+
|
|
41
|
+
- `lpcm`: 8, 16, 24, and 32-bit signed integer; 32 and 64-bit float; little-endian or big-endian.
|
|
42
|
+
- `alaw`: G.711 A-law.
|
|
43
|
+
- `ulaw`: G.711 µ-law.
|
|
44
|
+
- `ima4`: IMA/QuickTime ADPCM.
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
[ॐ](https://github.com/krishnized/license/) · [MIT](./LICENSE)
|
|
@@ -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 'caf' — extends audio()'s openable formats / save() targets */
|
|
12
|
+
export declare const caf: {
|
|
13
|
+
codec: 'caf'
|
|
14
|
+
decode(bytes: Uint8Array): { channelData: Float32Array[], sampleRate: number } | Promise<{ channelData: Float32Array[], sampleRate: number }>
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// audio.js manifest — codec atom, decode half: whole-buffer bytes → { channelData,
|
|
2
|
+
// sampleRate }. Hosts merge with the encode half (@audio/encode-caf) by format
|
|
3
|
+
// name. Format detection is magic-byte (audio-type) — no test() needed here.
|
|
4
|
+
|
|
5
|
+
import decodeFn from './decode-caf.js'
|
|
6
|
+
|
|
7
|
+
export const caf = {
|
|
8
|
+
codec: 'caf',
|
|
9
|
+
decode: (bytes) => decodeFn(bytes),
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface AudioData {
|
|
2
|
+
channelData: Float32Array[];
|
|
3
|
+
sampleRate: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface CAFDecoder {
|
|
7
|
+
decode(data: Uint8Array | ArrayBuffer): AudioData;
|
|
8
|
+
flush(): AudioData;
|
|
9
|
+
free(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Decode a complete CAF file synchronously. */
|
|
13
|
+
export default function decode(src: ArrayBuffer | Uint8Array): AudioData;
|
|
14
|
+
|
|
15
|
+
/** Create a synchronous decoder. */
|
|
16
|
+
export function decoder(): CAFDecoder;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CAF (Core Audio Format) decoder
|
|
3
|
+
* Decodes CAF containers with lpcm, alaw, ulaw audio to Float32 PCM
|
|
4
|
+
*
|
|
5
|
+
* let { channelData, sampleRate } = decode(cafbuf)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const EMPTY = Object.freeze({ channelData: [], sampleRate: 0 })
|
|
9
|
+
|
|
10
|
+
// IMA/QuickTime ADPCM tables
|
|
11
|
+
const IMA_STEP = new Int16Array([7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767])
|
|
12
|
+
const IMA_IDX = new Int8Array([-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8])
|
|
13
|
+
|
|
14
|
+
/** Decode a complete CAF file synchronously. */
|
|
15
|
+
export default function decode(src) {
|
|
16
|
+
let dec = decoder()
|
|
17
|
+
try { return dec.decode(src) }
|
|
18
|
+
finally { dec.free() }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Create a synchronous streaming decoder. */
|
|
22
|
+
export function decoder() {
|
|
23
|
+
let hdr = null, left = null, freed = false, dataLeft = Infinity
|
|
24
|
+
return {
|
|
25
|
+
decode(data) {
|
|
26
|
+
if (freed) throw Error('Decoder already freed')
|
|
27
|
+
if (!data || !data.byteLength) return EMPTY
|
|
28
|
+
let chunk = data instanceof Uint8Array ? data : new Uint8Array(data)
|
|
29
|
+
if (left) { chunk = catB(left, chunk); left = null }
|
|
30
|
+
if (!hdr) {
|
|
31
|
+
hdr = scanCafHdr(chunk)
|
|
32
|
+
if (!hdr) { left = chunk.slice(); return EMPTY }
|
|
33
|
+
dataLeft = hdr.dataSize
|
|
34
|
+
chunk = chunk.subarray(hdr.dataStart)
|
|
35
|
+
}
|
|
36
|
+
if (dataLeft <= 0) return EMPTY // Ignore chunks after the declared audio data.
|
|
37
|
+
let fb = hdr.frameBytes
|
|
38
|
+
let avail = Math.min(chunk.length, dataLeft) // Do not read past the declared data size.
|
|
39
|
+
let complete = Math.floor(avail / fb) * fb
|
|
40
|
+
if (!complete) { if (chunk.length && dataLeft > chunk.length) left = chunk.slice(); return EMPTY }
|
|
41
|
+
dataLeft -= complete
|
|
42
|
+
let rest = chunk.subarray(complete)
|
|
43
|
+
if (rest.length && dataLeft > 0) left = rest.subarray(0, Math.min(rest.length, dataLeft)).slice()
|
|
44
|
+
return decodeCafRaw(chunk.subarray(0, complete), hdr)
|
|
45
|
+
},
|
|
46
|
+
flush() { left = null; return EMPTY },
|
|
47
|
+
free() { freed = true; left = null; hdr = null },
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function catB(a, b) {
|
|
52
|
+
let r = new Uint8Array(a.length + b.length)
|
|
53
|
+
r.set(a); r.set(b, a.length)
|
|
54
|
+
return r
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function scanCafHdr(buf) {
|
|
58
|
+
if (buf.length < 8) return null
|
|
59
|
+
if (buf[0] !== 0x63 || buf[1] !== 0x61 || buf[2] !== 0x66 || buf[3] !== 0x66) throw Error('Not a CAF file')
|
|
60
|
+
let dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
61
|
+
if (dv.getUint16(4, false) !== 1) throw Error('Unsupported CAF version')
|
|
62
|
+
let off = 8, desc = null
|
|
63
|
+
while (off + 12 <= buf.length) {
|
|
64
|
+
let type = String.fromCharCode(buf[off], buf[off + 1], buf[off + 2], buf[off + 3])
|
|
65
|
+
let sizeHi = dv.getUint32(off + 4, false), sizeLo = dv.getUint32(off + 8, false)
|
|
66
|
+
let size = sizeHi * 0x100000000 + sizeLo
|
|
67
|
+
off += 12
|
|
68
|
+
if (type === 'desc') {
|
|
69
|
+
if (off + 32 > buf.length) return null
|
|
70
|
+
desc = {
|
|
71
|
+
sampleRate: dv.getFloat64(off, false),
|
|
72
|
+
formatID: String.fromCharCode(buf[off + 8], buf[off + 9], buf[off + 10], buf[off + 11]),
|
|
73
|
+
formatFlags: dv.getUint32(off + 12, false),
|
|
74
|
+
bytesPerPacket: dv.getUint32(off + 16, false),
|
|
75
|
+
framesPerPacket: dv.getUint32(off + 20, false),
|
|
76
|
+
channelsPerFrame: dv.getUint32(off + 24, false),
|
|
77
|
+
bitsPerChannel: dv.getUint32(off + 28, false),
|
|
78
|
+
}
|
|
79
|
+
} else if (type === 'data') {
|
|
80
|
+
if (!desc) return null
|
|
81
|
+
let dataStart = off + 4 // skip editCount
|
|
82
|
+
if (dataStart > buf.length) return null
|
|
83
|
+
// -1 (0xFFFF…) size means "until EOF" — read to end; else payload minus 4-byte editCount
|
|
84
|
+
let dataSize = (sizeHi === 0xFFFFFFFF && sizeLo === 0xFFFFFFFF) ? Infinity : Math.max(0, size - 4)
|
|
85
|
+
let { formatID, formatFlags, channelsPerFrame: ch, bitsPerChannel: bits } = desc
|
|
86
|
+
let bytesPerSample = bits >> 3
|
|
87
|
+
let frameBytes
|
|
88
|
+
if (formatID === 'alaw' || formatID === 'ulaw') frameBytes = ch
|
|
89
|
+
else if (formatID === 'ima4') frameBytes = desc.bytesPerPacket || 34 * ch // packet = 34 bytes/channel
|
|
90
|
+
else frameBytes = ch * bytesPerSample
|
|
91
|
+
if (!frameBytes) return null
|
|
92
|
+
return { ...desc, dataStart, frameBytes, dataSize }
|
|
93
|
+
}
|
|
94
|
+
if (size < 0) break
|
|
95
|
+
if (sizeHi === 0xFFFFFFFF && sizeLo === 0xFFFFFFFF) break
|
|
96
|
+
off += size
|
|
97
|
+
}
|
|
98
|
+
return null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function decodeCafRaw(raw, hdr) {
|
|
102
|
+
let { sampleRate, formatID, formatFlags, channelsPerFrame: ch, bitsPerChannel: bits, frameBytes } = hdr
|
|
103
|
+
let frames = Math.floor(raw.length / frameBytes)
|
|
104
|
+
if (!frames) return EMPTY
|
|
105
|
+
let samples
|
|
106
|
+
if (formatID === 'lpcm') samples = decodeLPCM(raw, formatFlags, bits, ch)
|
|
107
|
+
else if (formatID === 'alaw') samples = decodeAlaw(raw, ch)
|
|
108
|
+
else if (formatID === 'ulaw') samples = decodeUlaw(raw, ch)
|
|
109
|
+
else if (formatID === 'ima4') samples = decodeIma4(raw, hdr)
|
|
110
|
+
else throw Error('CAF: unsupported format ' + formatID)
|
|
111
|
+
return { channelData: samples, sampleRate }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// QuickTime IMA4 ADPCM — 34-byte packets per channel → 64 frames each.
|
|
115
|
+
// The predictor runs continuously across the whole stream; each packet's 2-byte
|
|
116
|
+
// preamble only snapshots the high 9 bits, so resetting per packet would lose up
|
|
117
|
+
// to 127 LSB. State (predictor + step index) is carried on hdr across chunks.
|
|
118
|
+
function decodeIma4(raw, hdr) {
|
|
119
|
+
let nCh = hdr.channelsPerFrame, fpp = hdr.framesPerPacket || 64
|
|
120
|
+
let pktBytes = 34 * nCh, nPk = Math.floor(raw.length / pktBytes)
|
|
121
|
+
if (!nPk) return []
|
|
122
|
+
let st = (hdr.ima ||= { pred: new Int32Array(nCh), step: new Int32Array(nCh), started: false })
|
|
123
|
+
let init = !st.started
|
|
124
|
+
let ch = Array.from({ length: nCh }, () => new Float32Array(nPk * fpp))
|
|
125
|
+
for (let pk = 0; pk < nPk; pk++) {
|
|
126
|
+
for (let c = 0; c < nCh; c++) {
|
|
127
|
+
let bp = pk * pktBytes + c * 34
|
|
128
|
+
if (init && pk === 0) {
|
|
129
|
+
let pre = (raw[bp] << 8) | raw[bp + 1]
|
|
130
|
+
let p = pre & 0xFF80; if (p > 32767) p -= 65536
|
|
131
|
+
st.pred[c] = p
|
|
132
|
+
st.step[c] = Math.min(pre & 0x7F, 88)
|
|
133
|
+
}
|
|
134
|
+
let pred = st.pred[c], ix = st.step[c], out = ch[c], base = pk * fpp
|
|
135
|
+
for (let i = 0; i < 32; i++) {
|
|
136
|
+
let byte = raw[bp + 2 + i]
|
|
137
|
+
for (let h = 0; h < 2; h++) {
|
|
138
|
+
let nib = h === 0 ? byte & 0x0F : (byte >> 4) & 0x0F
|
|
139
|
+
let step = IMA_STEP[ix], diff = step >> 3
|
|
140
|
+
if (nib & 1) diff += step >> 2
|
|
141
|
+
if (nib & 2) diff += step >> 1
|
|
142
|
+
if (nib & 4) diff += step
|
|
143
|
+
pred += (nib & 8) ? -diff : diff
|
|
144
|
+
if (pred > 32767) pred = 32767; else if (pred < -32768) pred = -32768
|
|
145
|
+
ix += IMA_IDX[nib]; if (ix < 0) ix = 0; else if (ix > 88) ix = 88
|
|
146
|
+
out[base + i * 2 + h] = pred / 32768
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
st.pred[c] = pred; st.step[c] = ix
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
st.started = true
|
|
153
|
+
return ch
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function decodeLPCM(data, flags, bits, ch) {
|
|
157
|
+
let isFloat = flags & 1, isLE = flags & 2
|
|
158
|
+
let bytesPerSample = bits >> 3
|
|
159
|
+
let totalSamples = (data.length / bytesPerSample) | 0
|
|
160
|
+
let framesCount = (totalSamples / ch) | 0
|
|
161
|
+
if (!framesCount) return []
|
|
162
|
+
|
|
163
|
+
let dv = new DataView(data.buffer, data.byteOffset, data.byteLength)
|
|
164
|
+
let channelData = Array.from({ length: ch }, () => new Float32Array(framesCount))
|
|
165
|
+
|
|
166
|
+
if (isFloat && bits === 32) {
|
|
167
|
+
for (let i = 0, off = 0; i < framesCount; i++)
|
|
168
|
+
for (let c = 0; c < ch; c++, off += 4)
|
|
169
|
+
channelData[c][i] = dv.getFloat32(off, !!isLE)
|
|
170
|
+
} else if (isFloat && bits === 64) {
|
|
171
|
+
for (let i = 0, off = 0; i < framesCount; i++)
|
|
172
|
+
for (let c = 0; c < ch; c++, off += 8)
|
|
173
|
+
channelData[c][i] = dv.getFloat64(off, !!isLE)
|
|
174
|
+
} else if (bits === 32) {
|
|
175
|
+
let norm = 1 / 2147483648
|
|
176
|
+
for (let i = 0, off = 0; i < framesCount; i++)
|
|
177
|
+
for (let c = 0; c < ch; c++, off += 4)
|
|
178
|
+
channelData[c][i] = dv.getInt32(off, !!isLE) * norm
|
|
179
|
+
} else if (bits === 24) {
|
|
180
|
+
let norm = 1 / 8388608
|
|
181
|
+
for (let i = 0, off = 0; i < framesCount; i++)
|
|
182
|
+
for (let c = 0; c < ch; c++, off += 3) {
|
|
183
|
+
let s
|
|
184
|
+
if (!isLE) s = (data[off] << 16) | (data[off + 1] << 8) | data[off + 2]
|
|
185
|
+
else s = data[off] | (data[off + 1] << 8) | (data[off + 2] << 16)
|
|
186
|
+
if (s & 0x800000) s |= ~0xFFFFFF
|
|
187
|
+
channelData[c][i] = s * norm
|
|
188
|
+
}
|
|
189
|
+
} else if (bits === 16) {
|
|
190
|
+
let norm = 1 / 32768
|
|
191
|
+
for (let i = 0, off = 0; i < framesCount; i++)
|
|
192
|
+
for (let c = 0; c < ch; c++, off += 2)
|
|
193
|
+
channelData[c][i] = dv.getInt16(off, !!isLE) * norm
|
|
194
|
+
} else if (bits === 8) {
|
|
195
|
+
let norm = 1 / 128
|
|
196
|
+
for (let i = 0, off = 0; i < framesCount; i++)
|
|
197
|
+
for (let c = 0; c < ch; c++, off++)
|
|
198
|
+
channelData[c][i] = dv.getInt8(off) * norm
|
|
199
|
+
} else {
|
|
200
|
+
throw Error('CAF: unsupported LPCM bit depth ' + bits)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return channelData
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function alawDecode(val) {
|
|
207
|
+
val ^= 0x55
|
|
208
|
+
let sign = val & 0x80, seg = (val >> 4) & 7, quant = val & 0x0F
|
|
209
|
+
let sample = seg ? ((quant << 1) | 0x21) << (seg - 1) : (quant << 1) | 1
|
|
210
|
+
return (sign ? -sample : sample) / 32768
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function ulawDecode(val) {
|
|
214
|
+
val = ~val & 0xFF
|
|
215
|
+
let sign = val & 0x80, exp = (val >> 4) & 7, mant = val & 0x0F
|
|
216
|
+
let sample = ((mant << 1) | 0x21) << exp
|
|
217
|
+
return (sign ? -(sample - 33) : (sample - 33)) / 32768
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function decodeAlaw(data, ch) {
|
|
221
|
+
let framesCount = (data.length / ch) | 0
|
|
222
|
+
if (!framesCount) return []
|
|
223
|
+
let channelData = Array.from({ length: ch }, () => new Float32Array(framesCount))
|
|
224
|
+
for (let i = 0, off = 0; i < framesCount; i++)
|
|
225
|
+
for (let c = 0; c < ch; c++, off++)
|
|
226
|
+
channelData[c][i] = alawDecode(data[off])
|
|
227
|
+
return channelData
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function decodeUlaw(data, ch) {
|
|
231
|
+
let framesCount = (data.length / ch) | 0
|
|
232
|
+
if (!framesCount) return []
|
|
233
|
+
let channelData = Array.from({ length: ch }, () => new Float32Array(framesCount))
|
|
234
|
+
for (let i = 0, off = 0; i < framesCount; i++)
|
|
235
|
+
for (let c = 0; c < ch; c++, off++)
|
|
236
|
+
channelData[c][i] = ulawDecode(data[off])
|
|
237
|
+
return channelData
|
|
238
|
+
}
|