@openclaw/whatsapp 2026.5.28 → 2026.5.31-beta.1
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/dist/{access-control-Z0fYaWrx.js → access-control-C53zKYSN.js} +1 -1
- package/dist/{accounts-BMGM1RtF.js → accounts-DgViSyJx.js} +1 -0
- package/dist/{action-runtime-BdhkGtaP.js → action-runtime-Cyp5GNIT.js} +2 -2
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/api.js +9 -9
- package/dist/{approval-handler.runtime-C25wPeBf.js → approval-handler.runtime-BVmOu6x1.js} +1 -2
- package/dist/{auth-store-BrKb0mwT.js → auth-store-CZ22aNcV.js} +4 -2
- package/dist/{channel-D3y4A5Dd.js → channel-DA2BAIo5.js} +17 -64
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-Cd2qkLqp.js → channel-react-action-zvbaCnGe.js} +3 -3
- package/dist/{channel.runtime-C228XUjs.js → channel.runtime-Q1LZDB5s.js} +4 -4
- package/dist/{channel.setup-BJQyTUUP.js → channel.setup-DHXOo4h5.js} +2 -3
- package/dist/{config-schema-CsNDlDpL.js → config-schema-CROZuhT-.js} +16 -0
- package/dist/{connection-controller-mpPGmqGq.js → connection-controller-Bnm4INld.js} +2 -2
- package/dist/contract-api.js +1 -1
- package/dist/light-runtime-api.js +1 -1
- package/dist/{login-CE4UYnyO.js → login-2fuBM7Je.js} +4 -4
- package/dist/{login-qr-LBvhEes5.js → login-qr-B1o7GFy8.js} +10 -6
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-Ccph7Y8M.js → monitor-BVRq04Dt.js} +36 -18
- package/dist/runtime-api.js +7 -7
- package/dist/{send-C4LG-Cl6.js → send-DSlVXKL_.js} +53 -41
- package/dist/{send-api-C66vkRl9.js → send-api-Bjn-h80j.js} +3 -2
- package/dist/{session-D8UW2Vbn.js → session-DyGWNClj.js} +1 -1
- package/dist/{setup-core-DpfT4K-2.js → setup-core-OvPMaAsx.js} +4 -4
- package/dist/{setup-finalize-CFnxX7la.js → setup-finalize-Dk23pfKc.js} +3 -3
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-DRsmp0ZS.js → setup-surface-F-jVrH8u.js} +3 -3
- package/node_modules/@audio/decode-aac/LICENSE +9 -0
- package/node_modules/@audio/decode-aac/README.md +60 -0
- package/node_modules/@audio/decode-aac/decode-aac.d.ts +16 -0
- package/node_modules/@audio/decode-aac/decode-aac.js +391 -0
- package/node_modules/@audio/decode-aac/package.json +47 -0
- package/node_modules/@audio/decode-aac/src/aac.wasm.cjs +0 -0
- package/node_modules/@audio/decode-aiff/LICENSE +21 -0
- package/node_modules/@audio/decode-aiff/README.md +53 -0
- package/node_modules/@audio/decode-aiff/decode-aiff.d.ts +16 -0
- package/node_modules/@audio/decode-aiff/decode-aiff.js +583 -0
- package/node_modules/@audio/decode-aiff/package.json +42 -0
- package/node_modules/@audio/decode-amr/LICENSE +191 -0
- package/node_modules/@audio/decode-amr/README.md +65 -0
- package/node_modules/@audio/decode-amr/decode-amr.d.ts +16 -0
- package/node_modules/@audio/decode-amr/decode-amr.js +159 -0
- package/node_modules/@audio/decode-amr/package.json +48 -0
- package/node_modules/@audio/decode-amr/src/amr.wasm.cjs +0 -0
- package/node_modules/@audio/decode-caf/LICENSE +21 -0
- package/node_modules/@audio/decode-caf/README.md +55 -0
- package/node_modules/@audio/decode-caf/decode-caf.d.ts +16 -0
- package/node_modules/@audio/decode-caf/decode-caf.js +190 -0
- package/node_modules/@audio/decode-caf/package.json +43 -0
- package/node_modules/{audio-buffer → @audio/decode-flac}/LICENSE +5 -2
- package/node_modules/@audio/decode-flac/README.md +23 -0
- package/node_modules/@audio/decode-flac/decode-flac.d.ts +16 -0
- package/node_modules/@audio/decode-flac/decode-flac.js +2994 -0
- package/node_modules/@audio/decode-flac/meta.js +115 -0
- package/node_modules/@audio/decode-flac/package.json +49 -0
- package/node_modules/@audio/decode-mp3/LICENSE +25 -0
- package/node_modules/@audio/decode-mp3/README.md +23 -0
- package/node_modules/@audio/decode-mp3/decode-mp3.d.ts +16 -0
- package/node_modules/@audio/decode-mp3/decode-mp3.js +868 -0
- package/node_modules/@audio/decode-mp3/meta.js +143 -0
- package/node_modules/@audio/decode-mp3/package.json +50 -0
- package/node_modules/@audio/decode-opus/LICENSE +25 -0
- package/node_modules/@audio/decode-opus/README.md +23 -0
- package/node_modules/@audio/decode-opus/decode-opus.d.ts +16 -0
- package/node_modules/@audio/decode-opus/decode-opus.js +3179 -0
- package/node_modules/@audio/decode-opus/package.json +47 -0
- package/node_modules/@audio/decode-qoa/LICENSE +25 -0
- package/node_modules/@audio/decode-qoa/README.md +21 -0
- package/node_modules/@audio/decode-qoa/decode-qoa.d.ts +16 -0
- package/node_modules/@audio/decode-qoa/decode-qoa.js +278 -0
- package/node_modules/@audio/decode-qoa/package.json +46 -0
- package/node_modules/@audio/decode-vorbis/LICENSE +25 -0
- package/node_modules/@audio/decode-vorbis/README.md +23 -0
- package/node_modules/@audio/decode-vorbis/decode-vorbis.d.ts +16 -0
- package/node_modules/@audio/decode-vorbis/decode-vorbis.js +2984 -0
- package/node_modules/@audio/decode-vorbis/package.json +47 -0
- package/node_modules/@audio/decode-wav/decode-wav.js +104 -0
- package/node_modules/@audio/decode-wav/meta.js +114 -0
- package/node_modules/@audio/decode-wav/package.json +27 -0
- package/node_modules/@audio/decode-webm/LICENSE +21 -0
- package/node_modules/@audio/decode-webm/README.md +57 -0
- package/node_modules/@audio/decode-webm/decode-webm.d.ts +16 -0
- package/node_modules/@audio/decode-webm/decode-webm.js +3964 -0
- package/node_modules/@audio/decode-webm/package.json +51 -0
- package/node_modules/@audio/decode-wma/LICENSE +12 -0
- package/node_modules/@audio/decode-wma/README.md +76 -0
- package/node_modules/@audio/decode-wma/decode-wma.d.ts +33 -0
- package/node_modules/@audio/decode-wma/decode-wma.js +525 -0
- package/node_modules/@audio/decode-wma/package.json +47 -0
- package/node_modules/@audio/decode-wma/src/wma.wasm.cjs +0 -0
- package/node_modules/audio-decode/.claude/settings.json +204 -0
- package/node_modules/audio-decode/.github/workflows/test.js.yml +11 -20
- package/node_modules/audio-decode/.gitmodules +9 -0
- package/node_modules/audio-decode/audio-decode.d.ts +48 -10
- package/node_modules/audio-decode/audio-decode.js +193 -77
- package/node_modules/audio-decode/meta.js +11 -0
- package/node_modules/audio-decode/package.json +49 -21
- package/node_modules/audio-decode/readme.md +129 -29
- package/node_modules/audio-decode/stream.d.ts +15 -0
- package/node_modules/audio-decode/stream.js +1 -0
- package/node_modules/audio-decode/test.html +29 -10
- package/node_modules/lru-cache/dist/commonjs/browser/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.min.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.min.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/index.min.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.d.ts +2 -2
- package/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.min.js.map +1 -1
- package/node_modules/lru-cache/package.json +1 -1
- package/node_modules/typebox/build/type/script/mapping.d.mts +5 -2
- package/node_modules/typebox/build/type/script/mapping.mjs +15 -8
- package/node_modules/typebox/build/type/script/parser.d.mts +3 -1
- package/node_modules/typebox/build/type/script/parser.mjs +2 -1
- package/node_modules/typebox/package.json +29 -29
- package/npm-shrinkwrap.json +156 -39
- package/openclaw.plugin.json +76 -0
- package/package.json +6 -6
- package/node_modules/audio-buffer/.eslintrc.json +0 -44
- package/node_modules/audio-buffer/.github/workflows/node.js.yml +0 -31
- package/node_modules/audio-buffer/.travis.yml +0 -7
- package/node_modules/audio-buffer/index.js +0 -76
- package/node_modules/audio-buffer/package.json +0 -37
- package/node_modules/audio-buffer/readme.md +0 -56
- package/node_modules/audio-decode/.eslintrc.json +0 -43
- package/node_modules/audio-decode/.travis.yml +0 -13
- 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.js +0 -107
- package/node_modules/node-wav/README.md +0 -35
- package/node_modules/node-wav/file.wav +0 -0
- package/node_modules/node-wav/index.js +0 -291
- package/node_modules/node-wav/package.json +0 -29
- package/node_modules/node-wav/tests/file1.wav +0 -0
- package/node_modules/node-wav/tests/test.js +0 -66
- package/node_modules/node-wav/x.js +0 -12
- package/node_modules/node-wav/x.json +0 -86702
- package/node_modules/node-wav/x.js~ +0 -13
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
-
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
|
3
|
-
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
const data_decoders = {
|
|
7
|
-
pcm8: (buffer, offset, output, channels, samples) => {
|
|
8
|
-
let input = new Uint8Array(buffer, offset);
|
|
9
|
-
let pos = 0;
|
|
10
|
-
for (let i = 0; i < samples; ++i) {
|
|
11
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
12
|
-
let data = input[pos++] - 128;
|
|
13
|
-
output[ch][i] = data < 0 ? data / 128 : data / 127;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
pcm16: (buffer, offset, output, channels, samples) => {
|
|
18
|
-
let input = new Int16Array(buffer, offset);
|
|
19
|
-
let pos = 0;
|
|
20
|
-
for (let i = 0; i < samples; ++i) {
|
|
21
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
22
|
-
let data = input[pos++];
|
|
23
|
-
output[ch][i] = data < 0 ? data / 32768 : data / 32767;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
pcm24: (buffer, offset, output, channels, samples) => {
|
|
28
|
-
let input = new Uint8Array(buffer, offset);
|
|
29
|
-
let pos = 0;
|
|
30
|
-
for (let i = 0; i < samples; ++i) {
|
|
31
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
32
|
-
let x0 = input[pos++];
|
|
33
|
-
let x1 = input[pos++];
|
|
34
|
-
let x2 = input[pos++];
|
|
35
|
-
let xx = (x0 + (x1 << 8) + (x2 << 16));
|
|
36
|
-
let data = xx > 0x800000 ? xx - 0x1000000 : xx;
|
|
37
|
-
output[ch][i] = data < 0 ? data / 8388608 : data / 8388607;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
pcm32: (buffer, offset, output, channels, samples) => {
|
|
42
|
-
let input = new Int32Array(buffer, offset);
|
|
43
|
-
let pos = 0;
|
|
44
|
-
for (let i = 0; i < samples; ++i) {
|
|
45
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
46
|
-
let data = input[pos++];
|
|
47
|
-
output[ch][i] = data < 0 ? data / 2147483648 : data / 2147483647;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
pcm32f: (buffer, offset, output, channels, samples) => {
|
|
52
|
-
let input = new Float32Array(buffer, offset);
|
|
53
|
-
let pos = 0;
|
|
54
|
-
for (let i = 0; i < samples; ++i) {
|
|
55
|
-
for (let ch = 0; ch < channels; ++ch)
|
|
56
|
-
output[ch][i] = input[pos++];
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
pcm64f: (buffer, offset, output, channels, samples) => {
|
|
60
|
-
let input = new Float64Array(buffer, offset);
|
|
61
|
-
let pos = 0;
|
|
62
|
-
for (let i = 0; i < samples; ++i) {
|
|
63
|
-
for (let ch = 0; ch < channels; ++ch)
|
|
64
|
-
output[ch][i] = input[pos++];
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const data_encoders = {
|
|
70
|
-
pcm8: (buffer, offset, input, channels, samples) => {
|
|
71
|
-
let output = new Uint8Array(buffer, offset);
|
|
72
|
-
let pos = 0;
|
|
73
|
-
for (let i = 0; i < samples; ++i) {
|
|
74
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
75
|
-
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
76
|
-
v = ((v * 0.5 + 0.5) * 255) | 0;
|
|
77
|
-
output[pos++] = v;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
pcm16: (buffer, offset, input, channels, samples) => {
|
|
82
|
-
let output = new Int16Array(buffer, offset);
|
|
83
|
-
let pos = 0;
|
|
84
|
-
for (let i = 0; i < samples; ++i) {
|
|
85
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
86
|
-
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
87
|
-
v = ((v < 0) ? v * 32768 : v * 32767) | 0;
|
|
88
|
-
output[pos++] = v;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
pcm24: (buffer, offset, input, channels, samples) => {
|
|
93
|
-
let output = new Uint8Array(buffer, offset);
|
|
94
|
-
let pos = 0;
|
|
95
|
-
for (let i = 0; i < samples; ++i) {
|
|
96
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
97
|
-
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
98
|
-
v = ((v < 0) ? 0x1000000 + v * 8388608 : v * 8388607) | 0;
|
|
99
|
-
output[pos++] = (v >> 0) & 0xff;
|
|
100
|
-
output[pos++] = (v >> 8) & 0xff;
|
|
101
|
-
output[pos++] = (v >> 16) & 0xff;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
pcm32: (buffer, offset, input, channels, samples) => {
|
|
106
|
-
let output = new Int32Array(buffer, offset);
|
|
107
|
-
let pos = 0;
|
|
108
|
-
for (let i = 0; i < samples; ++i) {
|
|
109
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
110
|
-
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
111
|
-
v = ((v < 0) ? v * 2147483648 : v * 2147483647) | 0;
|
|
112
|
-
output[pos++] = v;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
pcm32f: (buffer, offset, input, channels, samples) => {
|
|
117
|
-
let output = new Float32Array(buffer, offset);
|
|
118
|
-
let pos = 0;
|
|
119
|
-
for (let i = 0; i < samples; ++i) {
|
|
120
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
121
|
-
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
122
|
-
output[pos++] = v;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
pcm64f: (buffer, offset, input, channels, samples) => {
|
|
127
|
-
let output = new Float64Array(buffer, offset);
|
|
128
|
-
let pos = 0;
|
|
129
|
-
for (let i = 0; i < samples; ++i) {
|
|
130
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
131
|
-
let v = Math.max(-1, Math.min(input[ch][i], 1));
|
|
132
|
-
output[pos++] = v;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
function lookup(table, bitDepth, floatingPoint) {
|
|
139
|
-
let name = 'pcm' + bitDepth + (floatingPoint ? 'f' : '');
|
|
140
|
-
let fn = table[name];
|
|
141
|
-
if (!fn)
|
|
142
|
-
throw new TypeError('Unsupported data format: ' + name);
|
|
143
|
-
return fn;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function decode(buffer) {
|
|
147
|
-
let pos = 0, end = 0;
|
|
148
|
-
if (buffer.buffer) {
|
|
149
|
-
// If we are handed a typed array or a buffer, then we have to consider the
|
|
150
|
-
// offset and length into the underlying array buffer.
|
|
151
|
-
pos = buffer.byteOffset;
|
|
152
|
-
end = buffer.length;
|
|
153
|
-
buffer = buffer.buffer;
|
|
154
|
-
} else {
|
|
155
|
-
// If we are handed a straight up array buffer, start at offset 0 and use
|
|
156
|
-
// the full length of the buffer.
|
|
157
|
-
pos = 0;
|
|
158
|
-
end = buffer.byteLength;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
let v = new DataView(buffer);
|
|
162
|
-
|
|
163
|
-
function u8() {
|
|
164
|
-
let x = v.getUint8(pos);
|
|
165
|
-
pos++;
|
|
166
|
-
return x;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function u16() {
|
|
170
|
-
let x = v.getUint16(pos, true);
|
|
171
|
-
pos += 2;
|
|
172
|
-
return x;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function u32() {
|
|
176
|
-
let x = v.getUint32(pos, true);
|
|
177
|
-
pos += 4;
|
|
178
|
-
return x;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function string(len) {
|
|
182
|
-
let str = '';
|
|
183
|
-
for (let i = 0; i < len; ++i)
|
|
184
|
-
str += String.fromCharCode(u8());
|
|
185
|
-
return str;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (string(4) !== 'RIFF')
|
|
189
|
-
throw new TypeError('Invalid WAV file');
|
|
190
|
-
u32();
|
|
191
|
-
if (string(4) !== 'WAVE')
|
|
192
|
-
throw new TypeError('Invalid WAV file');
|
|
193
|
-
|
|
194
|
-
let fmt;
|
|
195
|
-
|
|
196
|
-
while (pos < end) {
|
|
197
|
-
let type = string(4);
|
|
198
|
-
let size = u32();
|
|
199
|
-
let next = pos + size;
|
|
200
|
-
switch (type) {
|
|
201
|
-
case 'fmt ':
|
|
202
|
-
let formatId = u16();
|
|
203
|
-
if (formatId !== 0x0001 && formatId !== 0x0003)
|
|
204
|
-
throw new TypeError('Unsupported format in WAV file: ' + formatId.toString(16));
|
|
205
|
-
fmt = {
|
|
206
|
-
format: 'lpcm',
|
|
207
|
-
floatingPoint: formatId === 0x0003,
|
|
208
|
-
channels: u16(),
|
|
209
|
-
sampleRate: u32(),
|
|
210
|
-
byteRate: u32(),
|
|
211
|
-
blockSize: u16(),
|
|
212
|
-
bitDepth: u16(),
|
|
213
|
-
};
|
|
214
|
-
break;
|
|
215
|
-
case 'data':
|
|
216
|
-
if (!fmt)
|
|
217
|
-
throw new TypeError('Missing "fmt " chunk.');
|
|
218
|
-
let samples = Math.floor(size / fmt.blockSize);
|
|
219
|
-
let channels = fmt.channels;
|
|
220
|
-
let sampleRate = fmt.sampleRate;
|
|
221
|
-
let channelData = [];
|
|
222
|
-
for (let ch = 0; ch < channels; ++ch)
|
|
223
|
-
channelData[ch] = new Float32Array(samples);
|
|
224
|
-
lookup(data_decoders, fmt.bitDepth, fmt.floatingPoint)(buffer, pos, channelData, channels, samples);
|
|
225
|
-
return {
|
|
226
|
-
sampleRate: sampleRate,
|
|
227
|
-
channelData: channelData
|
|
228
|
-
};
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
pos = next;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function encode(channelData, opts) {
|
|
236
|
-
let sampleRate = opts.sampleRate || 16000;
|
|
237
|
-
let floatingPoint = !!(opts.float || opts.floatingPoint);
|
|
238
|
-
let bitDepth = floatingPoint ? 32 : ((opts.bitDepth | 0) || 16);
|
|
239
|
-
let channels = channelData.length;
|
|
240
|
-
let samples = channelData[0].length;
|
|
241
|
-
let buffer = new ArrayBuffer(44 + (samples * channels * (bitDepth >> 3)));
|
|
242
|
-
|
|
243
|
-
let v = new DataView(buffer);
|
|
244
|
-
let pos = 0;
|
|
245
|
-
|
|
246
|
-
function u8(x) {
|
|
247
|
-
v.setUint8(pos++, x);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function u16(x) {
|
|
251
|
-
v.setUint16(pos, x, true);
|
|
252
|
-
pos += 2;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function u32(x) {
|
|
256
|
-
v.setUint32(pos, x, true);
|
|
257
|
-
pos += 4;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function string(s) {
|
|
261
|
-
for (var i = 0; i < s.length; ++i)
|
|
262
|
-
u8(s.charCodeAt(i));
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// write header
|
|
266
|
-
string('RIFF');
|
|
267
|
-
u32(buffer.byteLength - 8);
|
|
268
|
-
string('WAVE');
|
|
269
|
-
|
|
270
|
-
// write 'fmt ' chunk
|
|
271
|
-
string('fmt ');
|
|
272
|
-
u32(16);
|
|
273
|
-
u16(floatingPoint ? 0x0003 : 0x0001);
|
|
274
|
-
u16(channels);
|
|
275
|
-
u32(sampleRate);
|
|
276
|
-
u32(sampleRate * channels * (bitDepth >> 3));
|
|
277
|
-
u16(channels * (bitDepth >> 3));
|
|
278
|
-
u16(bitDepth);
|
|
279
|
-
|
|
280
|
-
// write 'data' chunk
|
|
281
|
-
string('data');
|
|
282
|
-
u32(buffer.byteLength - 44);
|
|
283
|
-
lookup(data_encoders, bitDepth, floatingPoint)(buffer, pos, channelData, channels, samples);
|
|
284
|
-
|
|
285
|
-
return Buffer(buffer);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
module.exports = {
|
|
289
|
-
decode: decode,
|
|
290
|
-
encode: encode,
|
|
291
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "node-wav",
|
|
3
|
-
"version": "0.0.2",
|
|
4
|
-
"description": "High performance WAV file decoder and encoder",
|
|
5
|
-
"main": "./index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "./node_modules/nodeunit/bin/nodeunit ./tests/test.js"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/andreasgal/node-wav.git"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"wav",
|
|
15
|
-
"decode"
|
|
16
|
-
],
|
|
17
|
-
"author": "Andreas Gal",
|
|
18
|
-
"license": "MIT",
|
|
19
|
-
"homepage": "https://github.com/andreasgal/node-wav",
|
|
20
|
-
"engines": {
|
|
21
|
-
"node": ">=4.4.0"
|
|
22
|
-
},
|
|
23
|
-
"dependencies": {},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"nodeunit": "^0.9.1",
|
|
26
|
-
"wav-decoder": "^1.1.0",
|
|
27
|
-
"wav-encoder": "^1.1.0"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
Binary file
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
-
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
|
3
|
-
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
const encoder = require('wav-encoder');
|
|
8
|
-
const decoder = require('wav-decoder');
|
|
9
|
-
const wav = require('../index');
|
|
10
|
-
|
|
11
|
-
function make_test_data(channels, samples) {
|
|
12
|
-
let data = [];
|
|
13
|
-
for (let ch = 0; ch < channels; ++ch) {
|
|
14
|
-
data[ch] = new Float32Array(samples);
|
|
15
|
-
for (let n = 0; n < samples; ++n)
|
|
16
|
-
data[ch][n] = Math.random();
|
|
17
|
-
}
|
|
18
|
-
return data;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.test_wav = test => {
|
|
22
|
-
test.expect(25);
|
|
23
|
-
let samples = 10;
|
|
24
|
-
let channels = 2;
|
|
25
|
-
let data = make_test_data(channels, samples);
|
|
26
|
-
Promise.all([8, 16, 24, 32, '32f'].map(bitDepth => new Promise((resolve, reject) => {
|
|
27
|
-
let floatingPoint = false;
|
|
28
|
-
if (bitDepth == '32f') {
|
|
29
|
-
bitDepth = 32;
|
|
30
|
-
floatingPoint = true;
|
|
31
|
-
}
|
|
32
|
-
let audioData = {
|
|
33
|
-
length: samples,
|
|
34
|
-
numberOfChannels: channels,
|
|
35
|
-
sampleRate: 16000,
|
|
36
|
-
channelData: data
|
|
37
|
-
};
|
|
38
|
-
let opts = {
|
|
39
|
-
floatingPoint: floatingPoint,
|
|
40
|
-
bitDepth: bitDepth,
|
|
41
|
-
};
|
|
42
|
-
encoder.encode(audioData, opts).then(buffer => {
|
|
43
|
-
let encoded = wav.encode(audioData.channelData, opts);
|
|
44
|
-
test.equal(new Buffer(buffer).toString('hex'), encoded.toString('hex'), 'our encoder should match wav-encoder');
|
|
45
|
-
let decoded = wav.decode(buffer);
|
|
46
|
-
decoder.decode(buffer).then(reference => {
|
|
47
|
-
test.equal(reference.length, decoded.channelData[0].length, 'number of samples should match');
|
|
48
|
-
test.equal(reference.numberOfChannels, decoded.channelData.length, 'number of channels should match');
|
|
49
|
-
test.equal(reference.sampleRate, decoded.sampleRate, 'sample rate should match');
|
|
50
|
-
test.deepEqual(reference.channelData, decoded.channelData, 'data should match');
|
|
51
|
-
resolve();
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
}))).then(() => test.done());
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
exports.test_buffer_offset = test => {
|
|
58
|
-
test.expect(1);
|
|
59
|
-
let files = ["./tests/file1.wav"];
|
|
60
|
-
files.forEach(file => {
|
|
61
|
-
let buffer = fs.readFileSync(file);
|
|
62
|
-
let decoded = wav.decode(buffer);
|
|
63
|
-
test.equal(decoded.sampleRate, 16000);
|
|
64
|
-
test.done();
|
|
65
|
-
});
|
|
66
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
let fs = require('fs');
|
|
2
|
-
let wav = require('./index');
|
|
3
|
-
|
|
4
|
-
//let files = JSON.parse(fs.readFileSync('x.json'));
|
|
5
|
-
|
|
6
|
-
let files = ["../train/data//other/0005932e-db17-4a21-b99f-5e10f84a9e74.wav"];
|
|
7
|
-
|
|
8
|
-
files.forEach(file => {
|
|
9
|
-
console.log(file);
|
|
10
|
-
let buffer = fs.readFileSync(file);
|
|
11
|
-
let w = wav.decode(buffer);
|
|
12
|
-
});
|