@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,46 @@
|
|
|
1
|
+
# @audio/decode-aiff
|
|
2
|
+
|
|
3
|
+
Decode AIFF and AIFF-C audio to PCM float samples.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm i @audio/decode-aiff
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import decode, { decoder } from '@audio/decode-aiff'
|
|
15
|
+
|
|
16
|
+
let { channelData, sampleRate } = decode(aiffBytes)
|
|
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(): AIFFDecoder`
|
|
32
|
+
|
|
33
|
+
Create a decoder instance.
|
|
34
|
+
|
|
35
|
+
- `dec.decode(data)`: decode a chunk.
|
|
36
|
+
- `dec.flush()`: decode buffered `ima4` or `GSM` data; otherwise return an empty result.
|
|
37
|
+
- `dec.free()`: release resources.
|
|
38
|
+
|
|
39
|
+
## Formats
|
|
40
|
+
|
|
41
|
+
- AIFF: 8, 16, 24, and 32-bit signed big-endian PCM.
|
|
42
|
+
- AIFF-C: `NONE`/`twos`, `sowt`, `fl32`, `fl64`, `alaw`, `ulaw`, `ima4`, and `GSM`.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
[ॐ](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 'aiff' — extends audio()'s openable formats / save() targets */
|
|
12
|
+
export declare const aiff: {
|
|
13
|
+
codec: 'aiff'
|
|
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-aiff) by format
|
|
3
|
+
// name. Format detection is magic-byte (audio-type) — no test() needed here.
|
|
4
|
+
|
|
5
|
+
import decodeFn from './decode-aiff.js'
|
|
6
|
+
|
|
7
|
+
export const aiff = {
|
|
8
|
+
codec: 'aiff',
|
|
9
|
+
decode: (bytes) => decodeFn(bytes),
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface AudioData {
|
|
2
|
+
channelData: Float32Array[];
|
|
3
|
+
sampleRate: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface AIFFDecoder {
|
|
7
|
+
decode(data: Uint8Array | ArrayBuffer): AudioData;
|
|
8
|
+
flush(): AudioData;
|
|
9
|
+
free(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Decode a complete AIFF or AIFF-C file synchronously. */
|
|
13
|
+
export default function decode(src: ArrayBuffer | Uint8Array): AudioData;
|
|
14
|
+
|
|
15
|
+
/** Create a synchronous decoder. */
|
|
16
|
+
export function decoder(): AIFFDecoder;
|
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AIFF/AIFF-C decoder — pure JS
|
|
3
|
+
* Decodes AIFF and AIFF-C audio to Float32Array PCM samples
|
|
4
|
+
*
|
|
5
|
+
* let { channelData, sampleRate } = await decode(aiffbuf)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const EMPTY = Object.freeze({ channelData: [], sampleRate: 0 })
|
|
9
|
+
|
|
10
|
+
// A-law expansion table (ITU-T G.711)
|
|
11
|
+
const ALAW_TBL = new Int16Array(256)
|
|
12
|
+
// mu-law expansion table (ITU-T G.711)
|
|
13
|
+
const ULAW_TBL = new Int16Array(256)
|
|
14
|
+
|
|
15
|
+
;(function buildTables() {
|
|
16
|
+
for (let i = 0; i < 256; i++) {
|
|
17
|
+
// A-law
|
|
18
|
+
let ax = i ^ 0x55, seg = (ax >> 4) & 7, val = ((ax & 0x0F) << 4) + 8
|
|
19
|
+
if (seg) val = (val + 256) << (seg - 1)
|
|
20
|
+
ALAW_TBL[i] = (ax & 0x80) ? val : -val
|
|
21
|
+
|
|
22
|
+
// mu-law (ITU-T G.711) — sign bit set ⇒ negative
|
|
23
|
+
let ux = ~i & 0xFF
|
|
24
|
+
seg = (ux >> 4) & 7
|
|
25
|
+
val = ((ux & 0x0F) << 3) + 132
|
|
26
|
+
val <<= seg
|
|
27
|
+
ULAW_TBL[i] = (ux & 0x80) ? (132 - val) : (val - 132)
|
|
28
|
+
}
|
|
29
|
+
})()
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Read 80-bit IEEE 754 extended precision float
|
|
33
|
+
*/
|
|
34
|
+
function readF80(b, o) {
|
|
35
|
+
let sign = (b[o] >> 7) & 1
|
|
36
|
+
let exp = ((b[o] & 0x7F) << 8) | b[o + 1]
|
|
37
|
+
let hi = ((b[o + 2] << 24) | (b[o + 3] << 16) | (b[o + 4] << 8) | b[o + 5]) >>> 0
|
|
38
|
+
let lo = ((b[o + 6] << 24) | (b[o + 7] << 16) | (b[o + 8] << 8) | b[o + 9]) >>> 0
|
|
39
|
+
if (exp === 0 && hi === 0 && lo === 0) return 0
|
|
40
|
+
if (exp === 0x7FFF) return sign ? -Infinity : Infinity
|
|
41
|
+
let f = (hi * 4294967296 + lo) / 9223372036854775808 // / 2^63
|
|
42
|
+
return (sign ? -1 : 1) * f * Math.pow(2, exp - 16383)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function str4(b, o) {
|
|
46
|
+
return String.fromCharCode(b[o], b[o + 1], b[o + 2], b[o + 3])
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function r32(b, o) {
|
|
50
|
+
return ((b[o] << 24) | (b[o + 1] << 16) | (b[o + 2] << 8) | b[o + 3]) >>> 0
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function r16(b, o) {
|
|
54
|
+
return (b[o] << 8) | b[o + 1]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Parse AIFF/AIFF-C and decode to Float32Array channels
|
|
59
|
+
*/
|
|
60
|
+
function parseAiff(buf) {
|
|
61
|
+
if (!buf || buf.length < 12) return EMPTY
|
|
62
|
+
|
|
63
|
+
let b = buf instanceof Uint8Array ? buf : new Uint8Array(buf)
|
|
64
|
+
if (b.length < 12) return EMPTY
|
|
65
|
+
|
|
66
|
+
// Validate FORM header
|
|
67
|
+
if (str4(b, 0) !== 'FORM') throw Error('Not an AIFF file')
|
|
68
|
+
let form = str4(b, 8)
|
|
69
|
+
if (form !== 'AIFF' && form !== 'AIFC') throw Error('Not an AIFF file')
|
|
70
|
+
let isAIFC = form === 'AIFC'
|
|
71
|
+
|
|
72
|
+
let nCh = 0, nFrames = 0, bps = 0, sr = 0, comp = 'NONE'
|
|
73
|
+
let ssndOff = -1, ssndSize = 0
|
|
74
|
+
|
|
75
|
+
// Parse chunks
|
|
76
|
+
let pos = 12, end = Math.min(8 + r32(b, 4), b.length)
|
|
77
|
+
while (pos + 8 <= end) {
|
|
78
|
+
let ckId = str4(b, pos)
|
|
79
|
+
let ckSize = r32(b, pos + 4)
|
|
80
|
+
let ckData = pos + 8
|
|
81
|
+
|
|
82
|
+
if (ckId === 'COMM') {
|
|
83
|
+
if (ckData + 18 > b.length) throw Error('Truncated COMM chunk')
|
|
84
|
+
nCh = r16(b, ckData)
|
|
85
|
+
nFrames = r32(b, ckData + 2)
|
|
86
|
+
bps = r16(b, ckData + 6)
|
|
87
|
+
sr = readF80(b, ckData + 8)
|
|
88
|
+
if (isAIFC && ckSize >= 22 && ckData + 22 <= b.length) {
|
|
89
|
+
comp = str4(b, ckData + 18)
|
|
90
|
+
}
|
|
91
|
+
} else if (ckId === 'SSND') {
|
|
92
|
+
if (ckData + 8 > b.length) throw Error('Truncated SSND chunk')
|
|
93
|
+
let dataOff = r32(b, ckData)
|
|
94
|
+
ssndOff = ckData + 8 + dataOff
|
|
95
|
+
ssndSize = ckSize - 8 - dataOff
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
pos = ckData + ckSize + (ckSize & 1) // pad to even
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!nCh || !nFrames || !sr || ssndOff < 0) return EMPTY
|
|
102
|
+
|
|
103
|
+
// Determine byte depth and decode strategy
|
|
104
|
+
let byteDepth = Math.ceil(bps / 8)
|
|
105
|
+
let frameBytes = byteDepth * nCh
|
|
106
|
+
let actualFrames = Math.min(nFrames, Math.floor(Math.min(ssndSize, b.length - ssndOff) / frameBytes))
|
|
107
|
+
if (actualFrames <= 0) return EMPTY
|
|
108
|
+
|
|
109
|
+
let channelData = Array.from({ length: nCh }, () => new Float32Array(actualFrames))
|
|
110
|
+
let p = ssndOff
|
|
111
|
+
|
|
112
|
+
// Compression-aware decode
|
|
113
|
+
let cUpper = comp.toUpperCase()
|
|
114
|
+
if (cUpper === 'NONE' || cUpper === 'TWOS' || comp === 'twos') {
|
|
115
|
+
// Big-endian signed integer PCM
|
|
116
|
+
decodePCM_BE(b, p, channelData, actualFrames, nCh, bps, byteDepth)
|
|
117
|
+
} else if (comp === 'sowt') {
|
|
118
|
+
// Little-endian signed integer PCM
|
|
119
|
+
decodePCM_LE(b, p, channelData, actualFrames, nCh, bps, byteDepth)
|
|
120
|
+
} else if (comp === 'fl32' || comp === 'FL32') {
|
|
121
|
+
decodeFloat32_BE(b, p, channelData, actualFrames, nCh)
|
|
122
|
+
} else if (comp === 'fl64' || comp === 'FL64') {
|
|
123
|
+
decodeFloat64_BE(b, p, channelData, actualFrames, nCh)
|
|
124
|
+
} else if (comp === 'alaw') {
|
|
125
|
+
decodeLaw(b, p, channelData, actualFrames, nCh, ALAW_TBL)
|
|
126
|
+
} else if (comp === 'ulaw' || comp === 'ULAW') {
|
|
127
|
+
decodeLaw(b, p, channelData, actualFrames, nCh, ULAW_TBL)
|
|
128
|
+
} else if (comp === 'ima4') {
|
|
129
|
+
return decodeIMA4(b, ssndOff, ssndSize, nCh, nFrames, sr)
|
|
130
|
+
} else if (comp === 'GSM ' || comp === 'gsm ') {
|
|
131
|
+
return decodeGSM(b, ssndOff, ssndSize, nCh, nFrames, sr)
|
|
132
|
+
} else {
|
|
133
|
+
throw Error('Unsupported AIFF-C compression: ' + comp)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return { channelData, sampleRate: sr }
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function decodePCM_BE(b, p, channels, frames, nCh, bps, byteDepth) {
|
|
140
|
+
if (bps === 8) {
|
|
141
|
+
// 8-bit: unsigned, center at 128
|
|
142
|
+
for (let i = 0; i < frames; i++)
|
|
143
|
+
for (let c = 0; c < nCh; c++)
|
|
144
|
+
channels[c][i] = (b[p++] - 128) / 128
|
|
145
|
+
} else if (bps === 16) {
|
|
146
|
+
for (let i = 0; i < frames; i++)
|
|
147
|
+
for (let c = 0; c < nCh; c++) {
|
|
148
|
+
let v = (b[p] << 8) | b[p + 1]; p += 2
|
|
149
|
+
channels[c][i] = (v > 32767 ? v - 65536 : v) / 32768
|
|
150
|
+
}
|
|
151
|
+
} else if (bps === 24) {
|
|
152
|
+
for (let i = 0; i < frames; i++)
|
|
153
|
+
for (let c = 0; c < nCh; c++) {
|
|
154
|
+
let v = (b[p] << 16) | (b[p + 1] << 8) | b[p + 2]; p += 3
|
|
155
|
+
channels[c][i] = (v > 8388607 ? v - 16777216 : v) / 8388608
|
|
156
|
+
}
|
|
157
|
+
} else if (bps === 32) {
|
|
158
|
+
for (let i = 0; i < frames; i++)
|
|
159
|
+
for (let c = 0; c < nCh; c++) {
|
|
160
|
+
let v = ((b[p] << 24) | (b[p + 1] << 16) | (b[p + 2] << 8) | b[p + 3]); p += 4
|
|
161
|
+
channels[c][i] = v / 2147483648
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
throw Error('Unsupported bit depth: ' + bps)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function decodePCM_LE(b, p, channels, frames, nCh, bps, byteDepth) {
|
|
169
|
+
if (bps === 8) {
|
|
170
|
+
for (let i = 0; i < frames; i++)
|
|
171
|
+
for (let c = 0; c < nCh; c++)
|
|
172
|
+
channels[c][i] = (b[p++] - 128) / 128
|
|
173
|
+
} else if (bps === 16) {
|
|
174
|
+
for (let i = 0; i < frames; i++)
|
|
175
|
+
for (let c = 0; c < nCh; c++) {
|
|
176
|
+
let v = b[p] | (b[p + 1] << 8); p += 2
|
|
177
|
+
channels[c][i] = (v > 32767 ? v - 65536 : v) / 32768
|
|
178
|
+
}
|
|
179
|
+
} else if (bps === 24) {
|
|
180
|
+
for (let i = 0; i < frames; i++)
|
|
181
|
+
for (let c = 0; c < nCh; c++) {
|
|
182
|
+
let v = b[p] | (b[p + 1] << 8) | (b[p + 2] << 16); p += 3
|
|
183
|
+
channels[c][i] = (v > 8388607 ? v - 16777216 : v) / 8388608
|
|
184
|
+
}
|
|
185
|
+
} else if (bps === 32) {
|
|
186
|
+
for (let i = 0; i < frames; i++)
|
|
187
|
+
for (let c = 0; c < nCh; c++) {
|
|
188
|
+
let v = b[p] | (b[p + 1] << 8) | (b[p + 2] << 16) | (b[p + 3] << 24); p += 4
|
|
189
|
+
channels[c][i] = v / 2147483648
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
throw Error('Unsupported bit depth: ' + bps)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function decodeFloat32_BE(b, p, channels, frames, nCh) {
|
|
197
|
+
let dv = new DataView(b.buffer, b.byteOffset, b.byteLength)
|
|
198
|
+
for (let i = 0; i < frames; i++)
|
|
199
|
+
for (let c = 0; c < nCh; c++) {
|
|
200
|
+
channels[c][i] = dv.getFloat32(p, false); p += 4
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function decodeFloat64_BE(b, p, channels, frames, nCh) {
|
|
205
|
+
let dv = new DataView(b.buffer, b.byteOffset, b.byteLength)
|
|
206
|
+
for (let i = 0; i < frames; i++)
|
|
207
|
+
for (let c = 0; c < nCh; c++) {
|
|
208
|
+
channels[c][i] = dv.getFloat64(p, false); p += 8
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function decodeLaw(b, p, channels, frames, nCh, tbl) {
|
|
213
|
+
for (let i = 0; i < frames; i++)
|
|
214
|
+
for (let c = 0; c < nCh; c++)
|
|
215
|
+
channels[c][i] = tbl[b[p++]] / 32768
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ===== IMA4 ADPCM (Apple IMA ADPCM) =====
|
|
219
|
+
// 34 bytes/block/channel → 64 samples. COMM nFrames = number of blocks.
|
|
220
|
+
|
|
221
|
+
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])
|
|
222
|
+
const IMA_IDX = new Int8Array([-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8])
|
|
223
|
+
|
|
224
|
+
function decodeIMA4(b, ssndOff, ssndSize, nCh, nBlocks, sr) {
|
|
225
|
+
let blockBytes = 34 * nCh
|
|
226
|
+
let totalSamples = nBlocks * 64
|
|
227
|
+
let channelData = Array.from({ length: nCh }, () => new Float32Array(totalSamples))
|
|
228
|
+
let p = ssndOff, sample = 0
|
|
229
|
+
|
|
230
|
+
for (let blk = 0; blk < nBlocks && p + blockBytes <= ssndOff + ssndSize; blk++) {
|
|
231
|
+
for (let c = 0; c < nCh; c++) {
|
|
232
|
+
let bp = p + c * 34
|
|
233
|
+
// Preamble: 16-bit BE — high 9 bits = predictor, low 7 bits = step index
|
|
234
|
+
let preamble = (b[bp] << 8) | b[bp + 1]
|
|
235
|
+
let predictor = preamble & 0xFF80 // top 9 bits, sign-extended via int16
|
|
236
|
+
if (predictor > 32767) predictor -= 65536
|
|
237
|
+
let stepIdx = preamble & 0x7F
|
|
238
|
+
if (stepIdx > 88) stepIdx = 88
|
|
239
|
+
|
|
240
|
+
let out = channelData[c]
|
|
241
|
+
for (let i = 0; i < 32; i++) {
|
|
242
|
+
let byte = b[bp + 2 + i]
|
|
243
|
+
// High nibble first, then low nibble
|
|
244
|
+
for (let nibbleIdx = 0; nibbleIdx < 2; nibbleIdx++) {
|
|
245
|
+
let nibble = nibbleIdx === 0 ? (byte >> 4) & 0xF : byte & 0xF
|
|
246
|
+
let step = IMA_STEP[stepIdx]
|
|
247
|
+
let diff = step >> 3
|
|
248
|
+
if (nibble & 1) diff += step >> 2
|
|
249
|
+
if (nibble & 2) diff += step >> 1
|
|
250
|
+
if (nibble & 4) diff += step
|
|
251
|
+
if (nibble & 8) diff = -diff
|
|
252
|
+
predictor += diff
|
|
253
|
+
if (predictor > 32767) predictor = 32767
|
|
254
|
+
if (predictor < -32768) predictor = -32768
|
|
255
|
+
stepIdx += IMA_IDX[nibble]
|
|
256
|
+
if (stepIdx < 0) stepIdx = 0
|
|
257
|
+
if (stepIdx > 88) stepIdx = 88
|
|
258
|
+
out[sample + i * 2 + nibbleIdx] = predictor / 32768
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
p += blockBytes
|
|
263
|
+
sample += 64
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return { channelData, sampleRate: sr }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ===== GSM 6.10 (Full Rate) =====
|
|
270
|
+
// 33 bytes/frame → 160 samples. RPE-LTP speech codec.
|
|
271
|
+
// Ported from libgsm by Jutta Degener and Carsten Bormann, TU Berlin.
|
|
272
|
+
|
|
273
|
+
// Table 4.3b: Quantization levels of the LTP gain quantizer
|
|
274
|
+
const GSM_QLB = [3277, 11469, 21299, 32767]
|
|
275
|
+
// Table 4.6: Normalized direct mantissa used to compute xM/xmax
|
|
276
|
+
const GSM_FAC = [18431, 20479, 22527, 24575, 26623, 28671, 30719, 32767]
|
|
277
|
+
|
|
278
|
+
// Saturating 16-bit add/sub
|
|
279
|
+
function sadd(a, b) { let s = a + b; return s > 32767 ? 32767 : s < -32768 ? -32768 : s }
|
|
280
|
+
function ssub(a, b) { let s = a - b; return s > 32767 ? 32767 : s < -32768 ? -32768 : s }
|
|
281
|
+
// GSM_MULT_R(a,b): (a*b + 16384) >> 15, with saturation for MIN_WORD*MIN_WORD
|
|
282
|
+
function multr(a, b) {
|
|
283
|
+
if (a === -32768 && b === -32768) return 32767
|
|
284
|
+
return ((a * b + 16384) >> 15) | 0
|
|
285
|
+
}
|
|
286
|
+
// Arithmetic shift right (sign-preserving)
|
|
287
|
+
function asr(x, n) {
|
|
288
|
+
if (n >= 16) return x < 0 ? -1 : 0
|
|
289
|
+
if (n <= -16) return 0
|
|
290
|
+
if (n < 0) return x << -n
|
|
291
|
+
return x >> n // JS >> is always arithmetic
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function decodeGSM(b, ssndOff, ssndSize, nCh, nFrames, sr) {
|
|
295
|
+
let totalFrames = Math.min(nFrames, Math.floor(ssndSize / 33))
|
|
296
|
+
let channelData = [new Float32Array(totalFrames * 160)]
|
|
297
|
+
let out = channelData[0], p = ssndOff
|
|
298
|
+
|
|
299
|
+
// Decoder state (mirrors struct gsm_state)
|
|
300
|
+
let dp0 = new Int32Array(280) // int32 to avoid overflow in intermediate calcs
|
|
301
|
+
let v = new Int32Array(9)
|
|
302
|
+
let LARpp = [new Int32Array(8), new Int32Array(8)]
|
|
303
|
+
let j = 0, nrp = 40, msr = 0
|
|
304
|
+
|
|
305
|
+
for (let f = 0; f < totalFrames; f++) {
|
|
306
|
+
let { LARc, sub } = gsmBits(b, p)
|
|
307
|
+
let wt = new Int32Array(160)
|
|
308
|
+
|
|
309
|
+
// Process 4 subframes: RPE decode + long-term synthesis
|
|
310
|
+
for (let s = 0; s < 4; s++) {
|
|
311
|
+
let sf = sub[s]
|
|
312
|
+
let erp = new Int32Array(40)
|
|
313
|
+
gsmRpeDecode(sf.xmaxc, sf.Mc, sf.xmc, erp)
|
|
314
|
+
|
|
315
|
+
// Long-term synthesis filtering (4.3.2)
|
|
316
|
+
let Nr = (sf.Nc < 40 || sf.Nc > 120) ? nrp : sf.Nc
|
|
317
|
+
nrp = Nr
|
|
318
|
+
let brp = GSM_QLB[sf.bc]
|
|
319
|
+
// drp is dp0 offset by 120; drp[k] = dp0[120+k], drp[k-Nr] = dp0[120+k-Nr]
|
|
320
|
+
for (let k = 0; k < 40; k++) {
|
|
321
|
+
let drpp = multr(brp, dp0[120 + k - Nr])
|
|
322
|
+
dp0[120 + k] = sadd(erp[k], drpp)
|
|
323
|
+
}
|
|
324
|
+
for (let k = 0; k < 40; k++) wt[s * 40 + k] = dp0[120 + k]
|
|
325
|
+
|
|
326
|
+
// Shift dp0: drp[-120+k] = drp[-80+k] for k=0..119
|
|
327
|
+
for (let k = 0; k < 120; k++) dp0[k] = dp0[k + 40]
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Short-term synthesis filter with LARp interpolation (4.2.8-4.2.9)
|
|
331
|
+
let LARpp_j = LARpp[j]
|
|
332
|
+
let LARpp_j_1 = LARpp[j ^ 1]
|
|
333
|
+
j ^= 1 // toggle for next frame
|
|
334
|
+
|
|
335
|
+
gsmDecodeLAR(LARc, LARpp_j)
|
|
336
|
+
|
|
337
|
+
let sr_out = new Int32Array(160)
|
|
338
|
+
let LARp = new Int32Array(8)
|
|
339
|
+
|
|
340
|
+
// Coefficients_0_12: LARp = 3/4 * prev + 1/4 * curr
|
|
341
|
+
for (let i = 0; i < 8; i++)
|
|
342
|
+
LARp[i] = sadd(sadd(LARpp_j_1[i] >> 2, LARpp_j[i] >> 2), LARpp_j_1[i] >> 1)
|
|
343
|
+
gsmLARpToRp(LARp)
|
|
344
|
+
gsmSynthFilter(v, LARp, 13, wt, 0, sr_out, 0)
|
|
345
|
+
|
|
346
|
+
// Coefficients_13_26: LARp = 1/2 * prev + 1/2 * curr
|
|
347
|
+
for (let i = 0; i < 8; i++)
|
|
348
|
+
LARp[i] = sadd(LARpp_j_1[i] >> 1, LARpp_j[i] >> 1)
|
|
349
|
+
gsmLARpToRp(LARp)
|
|
350
|
+
gsmSynthFilter(v, LARp, 14, wt, 13, sr_out, 13)
|
|
351
|
+
|
|
352
|
+
// Coefficients_27_39: LARp = 1/4 * prev + 3/4 * curr
|
|
353
|
+
for (let i = 0; i < 8; i++)
|
|
354
|
+
LARp[i] = sadd(sadd(LARpp_j_1[i] >> 2, LARpp_j[i] >> 2), LARpp_j[i] >> 1)
|
|
355
|
+
gsmLARpToRp(LARp)
|
|
356
|
+
gsmSynthFilter(v, LARp, 13, wt, 27, sr_out, 27)
|
|
357
|
+
|
|
358
|
+
// Coefficients_40_159: LARp = curr
|
|
359
|
+
for (let i = 0; i < 8; i++) LARp[i] = LARpp_j[i]
|
|
360
|
+
gsmLARpToRp(LARp)
|
|
361
|
+
gsmSynthFilter(v, LARp, 120, wt, 40, sr_out, 40)
|
|
362
|
+
|
|
363
|
+
// Postprocessing: de-emphasis + truncation/upscaling
|
|
364
|
+
for (let k = 0; k < 160; k++) {
|
|
365
|
+
msr = sadd(sr_out[k], multr(msr, 28180))
|
|
366
|
+
let s = sadd(msr, msr) & 0xFFF8
|
|
367
|
+
out[f * 160 + k] = (s > 32767 ? s - 65536 : s) / 32768
|
|
368
|
+
}
|
|
369
|
+
p += 33
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return { channelData, sampleRate: sr }
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// GSM 6.10 bit unpacking: 33 bytes → LARc[8] + 4 subframes
|
|
376
|
+
function gsmBits(buf, off) {
|
|
377
|
+
let bc = 0
|
|
378
|
+
function r(n) {
|
|
379
|
+
let val = 0
|
|
380
|
+
for (let i = 0; i < n; i++) {
|
|
381
|
+
val = (val << 1) | ((buf[off + (bc >> 3)] >> (7 - (bc & 7))) & 1)
|
|
382
|
+
bc++
|
|
383
|
+
}
|
|
384
|
+
return val
|
|
385
|
+
}
|
|
386
|
+
let LARc = [r(6),r(6),r(5),r(5),r(4),r(4),r(3),r(3)]
|
|
387
|
+
let sub = []
|
|
388
|
+
for (let s = 0; s < 4; s++)
|
|
389
|
+
sub.push({ Nc: r(7), bc: r(2), Mc: r(2), xmaxc: r(6), xmc: [r(3),r(3),r(3),r(3),r(3),r(3),r(3),r(3),r(3),r(3),r(3),r(3),r(3)] })
|
|
390
|
+
return { LARc, sub }
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// 4.2.8: Decoding of the coded Log-Area Ratios
|
|
394
|
+
function gsmDecodeLAR(LARc, LARpp) {
|
|
395
|
+
// B*2, MIC, INVA from tables 4.1 and 4.2
|
|
396
|
+
const B2 = [0, 0, 4096, -5120, 188, -3584, -682, -2288]
|
|
397
|
+
const MIC = [-32, -32, -16, -16, -8, -8, -4, -4]
|
|
398
|
+
const INVA = [13107, 13107, 13107, 13107, 19223, 17476, 31454, 29708]
|
|
399
|
+
for (let i = 0; i < 8; i++) {
|
|
400
|
+
let t = sadd(LARc[i], MIC[i]) << 10
|
|
401
|
+
t = ssub(t, B2[i])
|
|
402
|
+
t = multr(INVA[i], t)
|
|
403
|
+
LARpp[i] = sadd(t, t)
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// 4.2.9.2: LARp to reflection coefficients (in-place)
|
|
408
|
+
function gsmLARpToRp(LARp) {
|
|
409
|
+
for (let i = 0; i < 8; i++) {
|
|
410
|
+
if (LARp[i] < 0) {
|
|
411
|
+
let t = LARp[i] === -32768 ? 32767 : -LARp[i]
|
|
412
|
+
LARp[i] = -(t < 11059 ? t << 1 : t < 20070 ? t + 11059 : sadd(t >> 2, 26112))
|
|
413
|
+
} else {
|
|
414
|
+
let t = LARp[i]
|
|
415
|
+
LARp[i] = t < 11059 ? t << 1 : t < 20070 ? t + 11059 : sadd(t >> 2, 26112)
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Short-term synthesis filter (4.2.10, synthesis direction)
|
|
421
|
+
function gsmSynthFilter(v, rrp, k, wt, wtOff, sr, srOff) {
|
|
422
|
+
for (let n = 0; n < k; n++) {
|
|
423
|
+
let sri = wt[wtOff + n]
|
|
424
|
+
for (let i = 7; i >= 0; i--) {
|
|
425
|
+
sri = ssub(sri, multr(rrp[i], v[i]))
|
|
426
|
+
v[i + 1] = sadd(v[i], multr(rrp[i], sri))
|
|
427
|
+
}
|
|
428
|
+
sr[srOff + n] = v[0] = sri
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// 4.2.16-4.2.17: RPE decoding (inverse quantization + grid positioning)
|
|
433
|
+
function gsmRpeDecode(xmaxc, Mc, xMc, erp) {
|
|
434
|
+
// 4.2.15: Compute exp and mant from xmaxc
|
|
435
|
+
let exp = 0, mant
|
|
436
|
+
if (xmaxc > 15) exp = (xmaxc >> 3) - 1
|
|
437
|
+
mant = xmaxc - (exp << 3)
|
|
438
|
+
if (mant === 0) { exp = -4; mant = 7 }
|
|
439
|
+
else { while (mant <= 7) { mant = (mant << 1) | 1; exp-- }; mant -= 8 }
|
|
440
|
+
|
|
441
|
+
// 4.2.16: APCM inverse quantization
|
|
442
|
+
let fac = GSM_FAC[mant]
|
|
443
|
+
let shift = 6 - exp
|
|
444
|
+
let round = shift > 1 ? 1 << (shift - 1) : 0 // gsm_asl(1, shift-1)
|
|
445
|
+
|
|
446
|
+
let xMp = new Int32Array(13)
|
|
447
|
+
for (let i = 0; i < 13; i++) {
|
|
448
|
+
let t = ((xMc[i] << 1) - 7) << 12
|
|
449
|
+
t = multr(fac, t)
|
|
450
|
+
t = sadd(t, round)
|
|
451
|
+
xMp[i] = asr(t, shift)
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// 4.2.17: RPE grid positioning
|
|
455
|
+
for (let k = 0; k < 40; k++) erp[k] = 0
|
|
456
|
+
for (let i = 0; i < 13; i++) erp[Mc + 3 * i] = xMp[i]
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/** Decode a complete AIFF file synchronously. */
|
|
460
|
+
export default function decode(src) {
|
|
461
|
+
let buf = src instanceof Uint8Array ? src : src instanceof ArrayBuffer ? new Uint8Array(src) : src
|
|
462
|
+
let dec = decoder()
|
|
463
|
+
try {
|
|
464
|
+
let result = dec.decode(buf)
|
|
465
|
+
if (!result.channelData.length) result = dec.flush()
|
|
466
|
+
return result
|
|
467
|
+
} finally {
|
|
468
|
+
dec.free()
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/** Create a synchronous decoder. */
|
|
473
|
+
export function decoder() {
|
|
474
|
+
let hdr = null, left = null, deferredChunks = null, deferredLength = 0, freed = false
|
|
475
|
+
return {
|
|
476
|
+
decode(data) {
|
|
477
|
+
if (freed) throw Error('Decoder already freed')
|
|
478
|
+
if (!data || !data.byteLength) return EMPTY
|
|
479
|
+
let chunk = data instanceof Uint8Array ? data : new Uint8Array(data)
|
|
480
|
+
if (left) { chunk = cat(left, chunk); left = null }
|
|
481
|
+
if (!hdr) {
|
|
482
|
+
hdr = scanAiffHdr(chunk)
|
|
483
|
+
if (!hdr) { left = chunk.slice(); return EMPTY }
|
|
484
|
+
deferredChunks = hdr.comp === 'ima4' || hdr.comp === 'GSM ' || hdr.comp === 'gsm ' ? [] : null
|
|
485
|
+
if (!deferredChunks) chunk = chunk.subarray(hdr.dataStart)
|
|
486
|
+
}
|
|
487
|
+
// IMA4 and GSM need the complete container.
|
|
488
|
+
if (deferredChunks) {
|
|
489
|
+
deferredChunks.push(new Uint8Array(chunk))
|
|
490
|
+
deferredLength += chunk.length
|
|
491
|
+
return EMPTY
|
|
492
|
+
}
|
|
493
|
+
let fb = hdr.frameBytes
|
|
494
|
+
let complete = Math.floor(chunk.length / fb) * fb
|
|
495
|
+
if (!complete) { if (chunk.length) left = chunk.slice(); return EMPTY }
|
|
496
|
+
if (chunk.length > complete) left = chunk.subarray(complete).slice()
|
|
497
|
+
return decodeAiffRaw(chunk.subarray(0, complete), hdr)
|
|
498
|
+
},
|
|
499
|
+
flush() {
|
|
500
|
+
if (deferredChunks && deferredLength) {
|
|
501
|
+
let input = new Uint8Array(deferredLength), offset = 0
|
|
502
|
+
for (let chunk of deferredChunks) { input.set(chunk, offset); offset += chunk.length }
|
|
503
|
+
deferredChunks = []; deferredLength = 0
|
|
504
|
+
return parseAiff(input)
|
|
505
|
+
}
|
|
506
|
+
left = null
|
|
507
|
+
return EMPTY
|
|
508
|
+
},
|
|
509
|
+
free() { freed = true; left = null; hdr = null; deferredChunks = null; deferredLength = 0 },
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function cat(a, b) {
|
|
514
|
+
let r = new Uint8Array(a.length + b.length)
|
|
515
|
+
r.set(a); r.set(b, a.length)
|
|
516
|
+
return r
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function scanAiffHdr(b) {
|
|
520
|
+
if (!b || b.length < 12) return null
|
|
521
|
+
if (str4(b, 0) !== 'FORM') throw Error('Not an AIFF file')
|
|
522
|
+
let form = str4(b, 8)
|
|
523
|
+
if (form !== 'AIFF' && form !== 'AIFC') throw Error('Not an AIFF file')
|
|
524
|
+
let isAIFC = form === 'AIFC'
|
|
525
|
+
let nCh = 0, bps = 0, sr = 0, comp = 'NONE', commFound = false, numSampleFrames = 0
|
|
526
|
+
let pos = 12, end = Math.min(8 + r32(b, 4), b.length)
|
|
527
|
+
while (pos + 8 <= end) {
|
|
528
|
+
let ckId = str4(b, pos), ckSize = r32(b, pos + 4), ckData = pos + 8
|
|
529
|
+
if (ckId === 'COMM') {
|
|
530
|
+
if (ckData + 18 > b.length) return null
|
|
531
|
+
nCh = r16(b, ckData)
|
|
532
|
+
numSampleFrames = r32(b, ckData + 2)
|
|
533
|
+
bps = r16(b, ckData + 6)
|
|
534
|
+
sr = readF80(b, ckData + 8)
|
|
535
|
+
if (isAIFC && ckSize >= 22 && ckData + 22 <= b.length) comp = str4(b, ckData + 18)
|
|
536
|
+
commFound = true
|
|
537
|
+
} else if (ckId === 'SSND') {
|
|
538
|
+
if (!commFound) return null
|
|
539
|
+
if (ckData + 8 > b.length) return null
|
|
540
|
+
let dataOff = r32(b, ckData)
|
|
541
|
+
let dataStart = ckData + 8 + dataOff
|
|
542
|
+
let ssndDataSize = ckSize - 8 - dataOff
|
|
543
|
+
let cUpper = comp.toUpperCase()
|
|
544
|
+
let byteDepth = Math.ceil(bps / 8)
|
|
545
|
+
let frameBytes
|
|
546
|
+
if (comp === 'fl32' || comp === 'FL32') frameBytes = nCh * 4
|
|
547
|
+
else if (comp === 'fl64' || comp === 'FL64') frameBytes = nCh * 8
|
|
548
|
+
else if (comp === 'alaw' || comp === 'ulaw' || comp === 'ULAW') frameBytes = nCh
|
|
549
|
+
else if (comp === 'ima4' || comp === 'GSM ' || comp === 'gsm ') frameBytes = 1 // block-based, handled via flush
|
|
550
|
+
else frameBytes = nCh * byteDepth
|
|
551
|
+
let maxFrames = numSampleFrames ? Math.min(numSampleFrames, Math.floor(ssndDataSize / frameBytes)) : 0
|
|
552
|
+
return { nCh, bps, sr, comp, byteDepth, frameBytes, dataStart, isAIFC, maxFrames, ssndDataSize }
|
|
553
|
+
}
|
|
554
|
+
pos = ckData + ckSize + (ckSize & 1)
|
|
555
|
+
}
|
|
556
|
+
return null
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function decodeAiffRaw(raw, hdr) {
|
|
560
|
+
let { nCh, bps, sr, comp, byteDepth, frameBytes, maxFrames } = hdr
|
|
561
|
+
let frames = Math.floor(raw.length / frameBytes)
|
|
562
|
+
if (maxFrames) frames = Math.min(frames, maxFrames)
|
|
563
|
+
if (!frames) return EMPTY
|
|
564
|
+
let channelData = Array.from({ length: nCh }, () => new Float32Array(frames))
|
|
565
|
+
let cUpper = comp.toUpperCase()
|
|
566
|
+
let p = 0
|
|
567
|
+
if (cUpper === 'NONE' || cUpper === 'TWOS' || comp === 'twos') {
|
|
568
|
+
decodePCM_BE(raw, 0, channelData, frames, nCh, bps, byteDepth)
|
|
569
|
+
} else if (comp === 'sowt') {
|
|
570
|
+
decodePCM_LE(raw, 0, channelData, frames, nCh, bps, byteDepth)
|
|
571
|
+
} else if (comp === 'fl32' || comp === 'FL32') {
|
|
572
|
+
decodeFloat32_BE(raw, 0, channelData, frames, nCh)
|
|
573
|
+
} else if (comp === 'fl64' || comp === 'FL64') {
|
|
574
|
+
decodeFloat64_BE(raw, 0, channelData, frames, nCh)
|
|
575
|
+
} else if (comp === 'alaw') {
|
|
576
|
+
decodeLaw(raw, 0, channelData, frames, nCh, ALAW_TBL)
|
|
577
|
+
} else if (comp === 'ulaw' || comp === 'ULAW') {
|
|
578
|
+
decodeLaw(raw, 0, channelData, frames, nCh, ULAW_TBL)
|
|
579
|
+
} else {
|
|
580
|
+
throw Error('Unsupported AIFF-C compression: ' + comp)
|
|
581
|
+
}
|
|
582
|
+
return { channelData, sampleRate: sr }
|
|
583
|
+
}
|