@yume-chan/pcm-player 0.0.0-20240714132542

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/CHANGELOG.md ADDED
@@ -0,0 +1,43 @@
1
+ # Change Log - @yume-chan/pcm-player
2
+
3
+ ## 0.0.0-20240714132542
4
+
5
+ ### Patch Changes
6
+
7
+ - Switch to PNPM workspace and changesets
8
+
9
+ This log was last generated on Tue, 18 Jun 2024 02:49:43 GMT and should not be manually modified.
10
+
11
+ ## 0.0.24
12
+
13
+ Tue, 18 Jun 2024 02:49:43 GMT
14
+
15
+ ### Updates
16
+
17
+ - Expose `outputLatency` from `AudioContext`
18
+
19
+ ## 0.0.23
20
+
21
+ Thu, 21 Mar 2024 03:15:10 GMT
22
+
23
+ _Version update only_
24
+
25
+ ## 0.0.22
26
+
27
+ Wed, 13 Dec 2023 05:57:27 GMT
28
+
29
+ ### Updates
30
+
31
+ - Add basic OLA algorithm to speed up playback when buffer is too high
32
+
33
+ ## 0.0.21
34
+
35
+ Fri, 25 Aug 2023 14:05:18 GMT
36
+
37
+ _Version update only_
38
+
39
+ ## 0.0.20
40
+
41
+ Mon, 05 Jun 2023 02:51:41 GMT
42
+
43
+ _Initial release_
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2024 Simon Chan
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.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @yume-chan/pcm-player
2
+
3
+ Play raw audio sample stream using Web Audio API.
4
+
5
+ ## Features
6
+
7
+ - [x] Arbitrary channel count
8
+ - [x] Arbitrary sample rate
9
+ - [x] Basic OLA (overlap-add) resampler
10
+ - [ ] Adjustable buffer size
11
+
12
+ ## Usage
13
+
14
+ Depends on the sample format, there are multiple player classes:
15
+
16
+ - `Int16PcmPlayer` (little endian)
17
+ - `Float32PcmPlayer`
18
+ - `Float32PlanerPcmPlayer`
19
+
20
+ No `Planer`: audio samples are interleaved (left channel first).
21
+
22
+ With `Planer`: audio samples are in a two-dimensional array (left channel first).
23
+
24
+ The constructors require user activation (must be invoked in a user event handler, e.g. `onclick`), because they create `AudioContext`s.
25
+
26
+ ```ts
27
+ var player = Int16PcmPlayer(44100);
28
+ player.start();
29
+ player.feed(new Int16Array([0, 0, 0, 0, 0, 0, 0, 0]));
30
+ player.stop(); // `AudioContext` will be closed, so can't be restarted
31
+ ```
package/esm/index.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ export declare abstract class PcmPlayer<T> {
2
+ #private;
3
+ protected abstract sourceName: string;
4
+ get outputLatency(): number;
5
+ constructor(sampleRate: number, channelCount: number);
6
+ protected abstract feedCore(worklet: AudioWorkletNode, source: T): void;
7
+ /**
8
+ * Feed the samples to the player.
9
+ * @param source An array of samples. It will be transferred if it's an `ArrayBuffer`,
10
+ * or an `ArrayBufferView` that covers the whole `ArrayBuffer`. Otherwise, it will be copied.
11
+ */
12
+ feed(source: T): void;
13
+ start(): Promise<void>;
14
+ stop(): Promise<void>;
15
+ }
16
+ export declare class Int16PcmPlayer extends PcmPlayer<Int16Array> {
17
+ protected sourceName: string;
18
+ protected feedCore(worklet: AudioWorkletNode, source: Int16Array): void;
19
+ }
20
+ export declare class Float32PcmPlayer extends PcmPlayer<Float32Array> {
21
+ protected sourceName: string;
22
+ protected feedCore(worklet: AudioWorkletNode, source: Float32Array): void;
23
+ }
24
+ export declare class Float32PlanerPcmPlayer extends PcmPlayer<Float32Array[]> {
25
+ protected sourceName: string;
26
+ protected feedCore(worklet: AudioWorkletNode, source: Float32Array[]): void;
27
+ }
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8BAAsB,SAAS,CAAC,CAAC;;IAC7B,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAGtC,IAAI,aAAa,WAEhB;gBAOW,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAQpD,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAEvE;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAAE,CAAC;IAaR,KAAK;IAsBL,IAAI;CAWb;AAED,qBAAa,cAAe,SAAQ,SAAS,CAAC,UAAU,CAAC;IACrD,UAAmB,UAAU,SAA4B;cAEtC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU;CAW5E;AAED,qBAAa,gBAAiB,SAAQ,SAAS,CAAC,YAAY,CAAC;IACzD,UAAmB,UAAU,SAA8B;cAExC,QAAQ,CACvB,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,YAAY;CAY3B;AAED,qBAAa,sBAAuB,SAAQ,SAAS,CAAC,YAAY,EAAE,CAAC;IACjE,UAAmB,UAAU,SAAqC;cAE/C,QAAQ,CACvB,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,YAAY,EAAE;CAa7B"}
package/esm/index.js ADDED
@@ -0,0 +1,93 @@
1
+ export class PcmPlayer {
2
+ #context;
3
+ get outputLatency() {
4
+ return this.#context.outputLatency;
5
+ }
6
+ #channelCount;
7
+ #worklet;
8
+ #buffers = [];
9
+ #stopped = false;
10
+ constructor(sampleRate, channelCount) {
11
+ this.#context = new AudioContext({
12
+ latencyHint: "interactive",
13
+ sampleRate,
14
+ });
15
+ this.#channelCount = channelCount;
16
+ }
17
+ /**
18
+ * Feed the samples to the player.
19
+ * @param source An array of samples. It will be transferred if it's an `ArrayBuffer`,
20
+ * or an `ArrayBufferView` that covers the whole `ArrayBuffer`. Otherwise, it will be copied.
21
+ */
22
+ feed(source) {
23
+ if (this.#stopped) {
24
+ throw new Error("PcmPlayer is stopped");
25
+ }
26
+ if (this.#worklet === undefined) {
27
+ this.#buffers.push(source);
28
+ return;
29
+ }
30
+ this.feedCore(this.#worklet, source);
31
+ }
32
+ async start() {
33
+ await this.#context.audioWorklet.addModule(new URL("./worker.js", import.meta.url));
34
+ if (this.#stopped) {
35
+ return;
36
+ }
37
+ this.#worklet = new AudioWorkletNode(this.#context, this.sourceName, {
38
+ numberOfInputs: 0,
39
+ numberOfOutputs: 1,
40
+ outputChannelCount: [this.#channelCount],
41
+ });
42
+ this.#worklet.connect(this.#context.destination);
43
+ for (const source of this.#buffers) {
44
+ this.feedCore(this.#worklet, source);
45
+ }
46
+ this.#buffers.length = 0;
47
+ }
48
+ async stop() {
49
+ if (this.#stopped) {
50
+ return;
51
+ }
52
+ this.#stopped = true;
53
+ this.#worklet?.disconnect();
54
+ this.#worklet = undefined;
55
+ await this.#context.close();
56
+ }
57
+ }
58
+ export class Int16PcmPlayer extends PcmPlayer {
59
+ sourceName = "int16-source-processor";
60
+ feedCore(worklet, source) {
61
+ if (source.byteOffset !== 0 ||
62
+ source.byteLength !== source.buffer.byteLength) {
63
+ source = source.slice();
64
+ }
65
+ const { buffer } = source;
66
+ worklet.port.postMessage([buffer], [buffer]);
67
+ }
68
+ }
69
+ export class Float32PcmPlayer extends PcmPlayer {
70
+ sourceName = "float32-source-processor";
71
+ feedCore(worklet, source) {
72
+ if (source.byteOffset !== 0 ||
73
+ source.byteLength !== source.buffer.byteLength) {
74
+ source = source.slice();
75
+ }
76
+ const { buffer } = source;
77
+ worklet.port.postMessage([buffer], [buffer]);
78
+ }
79
+ }
80
+ export class Float32PlanerPcmPlayer extends PcmPlayer {
81
+ sourceName = "float32-planer-source-processor";
82
+ feedCore(worklet, source) {
83
+ const buffers = source.map((channel) => {
84
+ if (channel.byteOffset !== 0 ||
85
+ channel.byteLength !== channel.buffer.byteLength) {
86
+ channel = channel.slice();
87
+ }
88
+ return channel.buffer;
89
+ });
90
+ worklet.port.postMessage(buffers, buffers);
91
+ }
92
+ }
93
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,SAAS;IAG3B,QAAQ,CAAe;IACvB,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;IACvC,CAAC;IAED,aAAa,CAAS;IACtB,QAAQ,CAA+B;IACvC,QAAQ,GAAQ,EAAE,CAAC;IACnB,QAAQ,GAAG,KAAK,CAAC;IAEjB,YAAY,UAAkB,EAAE,YAAoB;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC;YAC7B,WAAW,EAAE,aAAa;YAC1B,UAAU;SACb,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACtC,CAAC;IAID;;;;OAIG;IACH,IAAI,CAAC,MAAS;QACV,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC5C,CAAC;Q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AAC;gBACC,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;YAC9B,CAAC;YACD,OAAO,OAAO,CAAC,MAAM,CAAC;QAC1B,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../worker/worker.ts"],"names":[],"mappings":""}
package/esm/worker.js ADDED
@@ -0,0 +1,235 @@
1
+ const INPUT_HOP_SIZE = 3000;
2
+ const SCALE = 0.9;
3
+ const OUTPUT_HOP_SIZE = (INPUT_HOP_SIZE * SCALE) | 0;
4
+ const WINDOW_SIZE = 6000;
5
+ const WINDOW_WEIGHT_TABLE = new Float32Array(WINDOW_SIZE);
6
+ for (let i = 0; i < WINDOW_SIZE / 2; i += 1) {
7
+ const value = Math.sin((i / WINDOW_SIZE) * Math.PI);
8
+ WINDOW_WEIGHT_TABLE[i] = value;
9
+ WINDOW_WEIGHT_TABLE[WINDOW_SIZE - i - 1] = value;
10
+ }
11
+ class SourceProcessor extends AudioWorkletProcessor {
12
+ channelCount;
13
+ #readBuffer;
14
+ #chunks = [];
15
+ #chunkSampleCounts = [];
16
+ #totalSampleCount = 0;
17
+ #starting = true;
18
+ #speedUp = false;
19
+ #readOffset = 0;
20
+ #inputOffset = 0;
21
+ #outputOffset = 0;
22
+ constructor(options) {
23
+ super();
24
+ this.channelCount = options.outputChannelCount[0];
25
+ this.#readBuffer = new Float32Array(this.channelCount);
26
+ this.port.onmessage = (event) => {
27
+ while (this.#totalSampleCount > 0.35 * 48000) {
28
+ this.#chunks.shift();
29
+ const count = this.#chunkSampleCounts.shift();
30
+ this.#totalSampleCount -= count;
31
+ }
32
+ const data = event.data;
33
+ const [source, length] = this.createSource(data);
34
+ this.#chunks.push(source);
35
+ this.#chunkSampleCounts.push(length);
36
+ this.#totalSampleCount += length;
37
+ if (!this.#speedUp && this.#totalSampleCount > 0.25 * 48000) {
38
+ this.#speedUp = true;
39
+ this.#readOffset = 0;
40
+ this.#inputOffset = 0;
41
+ this.#outputOffset = 0;
42
+ }
43
+ };
44
+ }
45
+ process(_inputs, [outputs]) {
46
+ if (this.#starting) {
47
+ if (this.#totalSampleCount < 0.1 * 48000) {
48
+ return true;
49
+ }
50
+ else {
51
+ this.#starting = false;
52
+ }
53
+ }
54
+ if (this.#speedUp && this.#totalSampleCount < 0.15 * 48000) {
55
+ this.#speedUp = false;
56
+ this.#starting = true;
57
+ }
58
+ const outputLength = outputs[0].length;
59
+ if (this.#speedUp) {
60
+ for (let i = 0; i < outputLength; i += 1) {
61
+ let totalWeight = 0;
62
+ const firstWindow = Math.max(0, Math.floor((this.#outputOffset - WINDOW_SIZE) / OUTPUT_HOP_SIZE) + 1);
63
+ let inWindowIndex = this.#outputOffset - firstWindow * OUTPUT_HOP_SIZE;
64
+ let inputIndex = firstWindow * INPUT_HOP_SIZE + inWindowIndex;
65
+ while (inputIndex > 0 && inWindowIndex >= 0) {
66
+ this.#read(inputIndex - this.#readOffset);
67
+ const weight = WINDOW_WEIGHT_TABLE[inWindowIndex];
68
+ for (let j = 0; j < this.channelCount; j += 1) {
69
+ outputs[j][i] += this.#readBuffer[j] * weight;
70
+ }
71
+ totalWeight += weight;
72
+ inputIndex += INPUT_HOP_SIZE - OUTPUT_HOP_SIZE;
73
+ inWindowIndex -= OUTPUT_HOP_SIZE;
74
+ }
75
+ if (totalWeight > 0) {
76
+ for (let j = 0; j < this.channelCount; j += 1) {
77
+ outputs[j][i] /= totalWeight;
78
+ }
79
+ }
80
+ this.#outputOffset += 1;
81
+ if (firstWindow > 0) {
82
+ this.#outputOffset -= OUTPUT_HOP_SIZE;
83
+ this.#readOffset -= INPUT_HOP_SIZE;
84
+ this.#inputOffset += (1 - SCALE) * INPUT_HOP_SIZE;
85
+ }
86
+ }
87
+ this.#inputOffset += outputLength;
88
+ const firstChunkSampleCount = this.#chunkSampleCounts[0];
89
+ if (firstChunkSampleCount !== undefined &&
90
+ this.#inputOffset >= firstChunkSampleCount) {
91
+ this.#chunks.shift();
92
+ this.#chunkSampleCounts.shift();
93
+ this.#totalSampleCount -= firstChunkSampleCount;
94
+ this.#readOffset += firstChunkSampleCount;
95
+ this.#inputOffset -= firstChunkSampleCount;
96
+ }
97
+ }
98
+ else {
99
+ this.#copyChunks(outputs);
100
+ }
101
+ return true;
102
+ }
103
+ #copyChunks(outputs) {
104
+ let outputIndex = 0;
105
+ const outputLength = outputs[0].length;
106
+ while (this.#chunks.length > 0 && outputIndex < outputLength) {
107
+ let source = this.#chunks[0];
108
+ let consumedSampleCount = 0;
109
+ [source, consumedSampleCount, outputIndex] = this.copyChunk(source, outputs, outputLength, outputIndex);
110
+ this.#totalSampleCount -= consumedSampleCount;
111
+ if (source) {
112
+ // Output full
113
+ this.#chunks[0] = source;
114
+ this.#chunkSampleCounts[0] -= consumedSampleCount;
115
+ return;
116
+ }
117
+ this.#chunks.shift();
118
+ this.#chunkSampleCounts.shift();
119
+ }
120
+ }
121
+ #read(offset) {
122
+ for (let i = 0; i < this.#chunks.length; i += 1) {
123
+ const length = this.#chunkSampleCounts[i];
124
+ if (offset < length) {
125
+ this.read(this.#chunks[i], offset, this.#readBuffer);
126
+ return;
127
+ }
128
+ offset -= length;
129
+ }
130
+ this.#readBuffer.fill(0);
131
+ }
132
+ }
133
+ class Int16SourceProcessor extends SourceProcessor {
134
+ createSource(data) {
135
+ const source = new Int16Array(data[0]);
136
+ return [source, source.length / this.channelCount];
137
+ }
138
+ read(source, offset, target) {
139
+ const sourceOffset = offset * this.channelCount;
140
+ for (let i = 0; i < this.channelCount; i += 1) {
141
+ target[i] = source[sourceOffset + i] / 0x8000;
142
+ }
143
+ }
144
+ copyChunk(source, outputs, outputLength, outputIndex) {
145
+ const sourceLength = source.length;
146
+ let sourceIndex = 0;
147
+ while (sourceIndex < sourceLength) {
148
+ for (let i = 0; i < this.channelCount; i += 1) {
149
+ outputs[i][outputIndex] = source[sourceIndex] / 0x8000;
150
+ sourceIndex += 1;
151
+ }
152
+ outputIndex += 1;
153
+ if (outputIndex === outputLength) {
154
+ return [
155
+ sourceIndex < sourceLength
156
+ ? source.subarray(sourceIndex)
157
+ : undefined,
158
+ sourceIndex / this.channelCount,
159
+ outputIndex,
160
+ ];
161
+ }
162
+ }
163
+ return [undefined, sourceIndex / this.channelCount, outputIndex];
164
+ }
165
+ }
166
+ class Float32SourceProcessor extends SourceProcessor {
167
+ createSource(data) {
168
+ const source = new Float32Array(data[0]);
169
+ return [source, source.length / this.channelCount];
170
+ }
171
+ read(source, offset, target) {
172
+ const sourceOffset = offset * this.channelCount;
173
+ for (let i = 0; i < this.channelCount; i += 1) {
174
+ target[i] = source[sourceOffset + i];
175
+ }
176
+ }
177
+ copyChunk(source, outputs, outputLength, outputIndex) {
178
+ const sourceLength = source.length;
179
+ let sourceIndex = 0;
180
+ while (sourceIndex < sourceLength) {
181
+ for (let i = 0; i < this.channelCount; i += 1) {
182
+ outputs[i][outputIndex] = source[sourceIndex];
183
+ sourceIndex += 1;
184
+ }
185
+ outputIndex += 1;
186
+ if (outputIndex === outputLength) {
187
+ return [
188
+ sourceIndex < sourceLength
189
+ ? source.subarray(sourceIndex)
190
+ : undefined,
191
+ sourceIndex / this.channelCount,
192
+ outputIndex,
193
+ ];
194
+ }
195
+ }
196
+ return [undefined, sourceIndex / this.channelCount, outputIndex];
197
+ }
198
+ }
199
+ class Float32PlanerSourceProcessor extends SourceProcessor {
200
+ createSource(data) {
201
+ const source = data.map((channel) => new Float32Array(channel));
202
+ return [source, source[0].length];
203
+ }
204
+ read(source, offset, target) {
205
+ for (let i = 0; i < target.length; i += 1) {
206
+ target[i] = source[i][offset];
207
+ }
208
+ }
209
+ copyChunk(source, outputs, outputLength, outputIndex) {
210
+ const sourceLength = source[0].length;
211
+ let sourceIndex = 0;
212
+ while (sourceIndex < sourceLength) {
213
+ for (let i = 0; i < this.channelCount; i += 1) {
214
+ outputs[i][outputIndex] = source[i][sourceIndex];
215
+ }
216
+ sourceIndex += 1;
217
+ outputIndex += 1;
218
+ if (outputIndex === outputLength) {
219
+ return [
220
+ sourceIndex < sourceLength
221
+ ? source.map((channel) => channel.subarray(sourceIndex))
222
+ : undefined,
223
+ sourceIndex,
224
+ outputIndex,
225
+ ];
226
+ }
227
+ }
228
+ return [undefined, sourceIndex, outputIndex];
229
+ }
230
+ }
231
+ registerProcessor("int16-source-processor", Int16SourceProcessor);
232
+ registerProcessor("float32-source-processor", Float32SourceProcessor);
233
+ registerProcessor("float32-planer-source-processor", Float32PlanerSourceProcessor);
234
+ export {};
235
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../worker/worker.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,MAAM,eAAe,GAAG,CAAC,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;AAErD,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,mBAAmB,GAAG,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;AAC1D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,mBAAmB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IAC/B,mBAAmB,CAAC,WAAW,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;AACrD,CAAC;AAED,MAAe,eACX,SAAQ,qBAAqB;IAG7B,YAAY,CAAS;IACrB,WAAW,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AM,CAAC,CAAC,CAAE,CAAC,MAAM,CAAE,CAAC;QACpC,CAAC;IACL,CAAC;IAEkB,SAAS,CACxB,MAAsB,EACtB,OAAuB,EACvB,YAAoB,EACpB,WAAmB;QAMnB,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAE,CAAC,MAAM,CAAC;QACvC,IAAI,WAAW,GAAG,CAAC,CAAC;QAEpB,OAAO,WAAW,GAAG,YAAY,EAAE,CAAC;YAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5C,OAAO,CAAC,CAAC,CAAE,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,CAAC,CAAE,CAAC,WAAW,CAAE,CAAC;YACxD,CAAC;YACD,WAAW,IAAI,CAAC,CAAC;YACjB,WAAW,IAAI,CAAC,CAAC;YAEjB,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;gBAC/B,OAAO;oBACH,WAAW,GAAG,YAAY;wBACtB,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;wBACxD,CAAC,CAAC,SAAS;oBACf,WAAW;oBACX,WAAW;iBACd,CAAC;YACN,CAAC;QACL,CAAC;QAED,OAAO,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IACjD,CAAC;CACJ;AAED,iBAAiB,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,CAAC;AAClE,iBAAiB,CAAC,0BAA0B,EAAE,sBAAsB,CAAC,CAAC;AACtE,iBAAiB,CACb,iCAAiC,EACjC,4BAA4B,CAC/B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@yume-chan/pcm-player",
3
+ "version": "0.0.0-20240714132542",
4
+ "description": "Play raw audio sample stream using Web Audio API",
5
+ "keywords": [
6
+ "audio"
7
+ ],
8
+ "license": "MIT",
9
+ "author": {
10
+ "name": "Simon Chan",
11
+ "email": "cnsimonchan@live.com",
12
+ "url": "https://chensi.moe/blog"
13
+ },
14
+ "homepage": "https://github.com/yume-chan/ya-webadb/tree/main/packages/pcm-player#readme",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/yume-chan/ya-webadb.git",
18
+ "directory": "packages/pcm-player"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/yume-chan/ya-webadb/issues"
22
+ },
23
+ "type": "module",
24
+ "main": "esm/index.js",
25
+ "types": "esm/index.d.ts",
26
+ "sideEffects": false,
27
+ "devDependencies": {
28
+ "@jest/globals": "^30.0.0-alpha.4",
29
+ "@types/audioworklet": "^0.0.57",
30
+ "@yume-chan/eslint-config": "^1.0.0",
31
+ "@yume-chan/tsconfig": "^1.0.0",
32
+ "cross-env": "^7.0.3",
33
+ "jest": "^30.0.0-alpha.4",
34
+ "prettier": "^3.3.3",
35
+ "ts-jest": "^29.2.2",
36
+ "typescript": "^5.5.3"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc -b tsconfig.dom.json && tsc -b tsconfig.worker.json",
40
+ "build:watch": "tsc -b tsconfig.dom.json && tsc -b tsconfig.worker.json",
41
+ "lint": "run-eslint && prettier src/**/*.ts --write --tab-width 4"
42
+ }
43
+ }
package/src/index.ts ADDED
@@ -0,0 +1,130 @@
1
+ export abstract class PcmPlayer<T> {
2
+ protected abstract sourceName: string;
3
+
4
+ #context: AudioContext;
5
+ get outputLatency() {
6
+ return this.#context.outputLatency;
7
+ }
8
+
9
+ #channelCount: number;
10
+ #worklet: AudioWorkletNode | undefined;
11
+ #buffers: T[] = [];
12
+ #stopped = false;
13
+
14
+ constructor(sampleRate: number, channelCount: number) {
15
+ this.#context = new AudioContext({
16
+ latencyHint: "interactive",
17
+ sampleRate,
18
+ });
19
+ this.#channelCount = channelCount;
20
+ }
21
+
22
+ protected abstract feedCore(worklet: AudioWorkletNode, source: T): void;
23
+
24
+ /**
25
+ * Feed the samples to the player.
26
+ * @param source An array of samples. It will be transferred if it's an `ArrayBuffer`,
27
+ * or an `ArrayBufferView` that covers the whole `ArrayBuffer`. Otherwise, it will be copied.
28
+ */
29
+ feed(source: T) {
30
+ if (this.#stopped) {
31
+ throw new Error("PcmPlayer is stopped");
32
+ }
33
+
34
+ if (this.#worklet === undefined) {
35
+ this.#buffers.push(source);
36
+ return;
37
+ }
38
+
39
+ this.feedCore(this.#worklet, source);
40
+ }
41
+
42
+ async start() {
43
+ await this.#context.audioWorklet.addModule(
44
+ new URL("./worker.js", import.meta.url),
45
+ );
46
+
47
+ if (this.#stopped) {
48
+ return;
49
+ }
50
+
51
+ this.#worklet = new AudioWorkletNode(this.#context, this.sourceName, {
52
+ numberOfInputs: 0,
53
+ numberOfOutputs: 1,
54
+ outputChannelCount: [this.#channelCount],
55
+ });
56
+ this.#worklet.connect(this.#context.destination);
57
+
58
+ for (const source of this.#buffers) {
59
+ this.feedCore(this.#worklet, source);
60
+ }
61
+ this.#buffers.length = 0;
62
+ }
63
+
64
+ async stop() {
65
+ if (this.#stopped) {
66
+ return;
67
+ }
68
+ this.#stopped = true;
69
+
70
+ this.#worklet?.disconnect();
71
+ this.#worklet = undefined;
72
+
73
+ await this.#context.close();
74
+ }
75
+ }
76
+
77
+ export class Int16PcmPlayer extends PcmPlayer<Int16Array> {
78
+ protected override sourceName = "int16-source-processor";
79
+
80
+ protected override feedCore(worklet: AudioWorkletNode, source: Int16Array) {
81
+ if (
82
+ source.byteOffset !== 0 ||
83
+ source.byteLength !== source.buffer.byteLength
84
+ ) {
85
+ source = source.slice();
86
+ }
87
+
88
+ const { buffer } = source;
89
+ worklet.port.postMessage([buffer], [buffer]);
90
+ }
91
+ }
92
+
93
+ export class Float32PcmPlayer extends PcmPlayer<Float32Array> {
94
+ protected override sourceName = "float32-source-processor";
95
+
96
+ protected override feedCore(
97
+ worklet: AudioWorkletNode,
98
+ source: Float32Array,
99
+ ) {
100
+ if (
101
+ source.byteOffset !== 0 ||
102
+ source.byteLength !== source.buffer.byteLength
103
+ ) {
104
+ source = source.slice();
105
+ }
106
+
107
+ const { buffer } = source;
108
+ worklet.port.postMessage([buffer], [buffer]);
109
+ }
110
+ }
111
+
112
+ export class Float32PlanerPcmPlayer extends PcmPlayer<Float32Array[]> {
113
+ protected override sourceName = "float32-planer-source-processor";
114
+
115
+ protected override feedCore(
116
+ worklet: AudioWorkletNode,
117
+ source: Float32Array[],
118
+ ) {
119
+ const buffers = source.map((channel) => {
120
+ if (
121
+ channel.byteOffset !== 0 ||
122
+ channel.byteLength !== channel.buffer.byteLength
123
+ ) {
124
+ channel = channel.slice();
125
+ }
126
+ return channel.buffer;
127
+ });
128
+ worklet.port.postMessage(buffers, buffers);
129
+ }
130
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "./node_modules/@yume-chan/tsconfig/tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "lib": [
5
+ "ESNext",
6
+ "DOM",
7
+ "DOM.Iterable"
8
+ ],
9
+ "types": []
10
+ }
11
+ }
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2023.collection.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2023.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.array.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.collection.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.promise.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.object.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.regexp.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","./src/index.ts"],"fileInfos":[{"version":"44e584d4f6444f58791784f1d530875970993129442a847597db702a073ca68c","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","impliedFormat":1},{"version":"27bdc30a0e32783366a5abeda841bc22757c1797de8681bbe81fbc735eeb1c10","impliedFormat":1},{"version":"17edc026abf73c5c2dd508652d63f68ec4efd9d4856e3469890d27598209feb5","impliedFormat":1},{"version":"4af6b0c727b7a2896463d512fafd23634229adf69ac7c00e2ae15a09cb084fad","affectsGlobalScope":true,"impliedFormat":1},{"version":"9c00a480825408b6a24c63c1b71362232927247595d7c97659bc24dc68ae0757","affectsGlobalScope":true,"impliedFormat":1},{"version":"6920e1448680767498a0b77c6a00a8e77d14d62c3da8967b171f1ddffa3c18e4","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true,"impliedFormat":1},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true,"impliedFormat":1},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true,"impliedFormat":1},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true,"impliedFormat":1},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"ae37d6ccd1560b0203ab88d46987393adaaa78c919e51acf32fb82c86502e98c","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true,"impliedFormat":1},{"version":"5e07ed3809d48205d5b985642a59f2eba47c402374a7cf8006b686f79efadcbd","affectsGlobalScope":true,"impliedFormat":1},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true,"impliedFormat":1},{"version":"479553e3779be7d4f68e9f40cdb82d038e5ef7592010100410723ceced22a0f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"d3d7b04b45033f57351c8434f60b6be1ea71a2dfec2d0a0c3c83badbb0e3e693","affectsGlobalScope":true,"impliedFormat":1},{"version":"956d27abdea9652e8368ce029bb1e0b9174e9678a273529f426df4b3d90abd60","affectsGlobalScope":true,"impliedFormat":1},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true,"impliedFormat":1},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true,"impliedFormat":1},{"version":"d8670852241d4c6e03f2b89d67497a4bbefe29ecaa5a444e2c11a9b05e6fccc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true,"impliedFormat":1},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e3c06ea092138bf9fa5e874a1fdbc9d54805d074bee1de31b99a11e2fec239d","affectsGlobalScope":true,"impliedFormat":1},{"version":"0b11f3ca66aa33124202c80b70cd203219c3d4460cfc165e0707aa9ec710fc53","affectsGlobalScope":true,"impliedFormat":1},{"version":"6a3f5a0129cc80cf439ab71164334d649b47059a4f5afca90282362407d0c87f","affectsGlobalScope":true,"impliedFormat":1},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"15b98a533864d324e5f57cd3cfc0579b231df58c1c0f6063ea0fcb13c3c74ff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a6282c8827e4b9a95f4bf4f5c205673ada31b982f50572d27103df8ceb8013c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true,"impliedFormat":1},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true,"impliedFormat":1},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true,"impliedFormat":1},{"version":"56e4ed5aab5f5920980066a9409bfaf53e6d21d3f8d020c17e4de584d29600ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"d97c21d6180706cf9e33bdf88607ac65eaa50e847fc410696459055abcd672da","signature":"0e6df35cb84df7974221ba6e529a474fe0fe35918647ef21393f96cc94ce6579","impliedFormat":99}],"root":[74],"options":{"composite":true,"declaration":true,"declarationDir":"./esm","declarationMap":true,"esModuleInterop":true,"exactOptionalPropertyTypes":true,"module":199,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitOverride":true,"noImplicitReturns":true,"noImplicitThis":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./esm","rootDir":"./src","skipLibCheck":true,"sourceMap":true,"strict":true,"stripInternal":true,"target":99,"verbatimModuleSyntax":true},"latestChangedDtsFile":"./esm/index.d.ts"},"version":"5.5.3"}
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "./node_modules/@yume-chan/tsconfig/tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "lib": [
5
+ "ESNext"
6
+ ],
7
+ "types": [
8
+ "audioworklet"
9
+ ],
10
+ "rootDir": "worker"
11
+ },
12
+ "include": [
13
+ "worker"
14
+ ]
15
+ }
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2023.collection.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.es2023.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.array.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.collection.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.string.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.promise.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.object.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.esnext.regexp.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/.pnpm/typescript@5.5.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","./worker/worker.ts","../../node_modules/.pnpm/@types+audioworklet@0.0.57/node_modules/@types/audioworklet/iterable.d.ts","../../node_modules/.pnpm/@types+audioworklet@0.0.57/node_modules/@types/audioworklet/index.d.ts"],"fileInfos":[{"version":"44e584d4f6444f58791784f1d530875970993129442a847597db702a073ca68c","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","impliedFormat":1},{"version":"27bdc30a0e32783366a5abeda841bc22757c1797de8681bbe81fbc735eeb1c10","impliedFormat":1},{"version":"17edc026abf73c5c2dd508652d63f68ec4efd9d4856e3469890d27598209feb5","impliedFormat":1},{"version":"6920e1448680767498a0b77c6a00a8e77d14d62c3da8967b171f1ddffa3c18e4","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true,"impliedFormat":1},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true,"impliedFormat":1},{"version":"ea011c76963fb15ef1cdd7ce6a6808b46322c527de2077b6cfdf23ae6f5f9ec7","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true,"impliedFormat":1},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true,"impliedFormat":1},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"ae37d6ccd1560b0203ab88d46987393adaaa78c919e51acf32fb82c86502e98c","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true,"impliedFormat":1},{"version":"5e07ed3809d48205d5b985642a59f2eba47c402374a7cf8006b686f79efadcbd","affectsGlobalScope":true,"impliedFormat":1},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true,"impliedFormat":1},{"version":"479553e3779be7d4f68e9f40cdb82d038e5ef7592010100410723ceced22a0f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"d3d7b04b45033f57351c8434f60b6be1ea71a2dfec2d0a0c3c83badbb0e3e693","affectsGlobalScope":true,"impliedFormat":1},{"version":"956d27abdea9652e8368ce029bb1e0b9174e9678a273529f426df4b3d90abd60","affectsGlobalScope":true,"impliedFormat":1},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true,"impliedFormat":1},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true,"impliedFormat":1},{"version":"d8670852241d4c6e03f2b89d67497a4bbefe29ecaa5a444e2c11a9b05e6fccc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true,"impliedFormat":1},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e3c06ea092138bf9fa5e874a1fdbc9d54805d074bee1de31b99a11e2fec239d","affectsGlobalScope":true,"impliedFormat":1},{"version":"0b11f3ca66aa33124202c80b70cd203219c3d4460cfc165e0707aa9ec710fc53","affectsGlobalScope":true,"impliedFormat":1},{"version":"6a3f5a0129cc80cf439ab71164334d649b47059a4f5afca90282362407d0c87f","affectsGlobalScope":true,"impliedFormat":1},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"15b98a533864d324e5f57cd3cfc0579b231df58c1c0f6063ea0fcb13c3c74ff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a6282c8827e4b9a95f4bf4f5c205673ada31b982f50572d27103df8ceb8013c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true,"impliedFormat":1},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true,"impliedFormat":1},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true,"impliedFormat":1},{"version":"56e4ed5aab5f5920980066a9409bfaf53e6d21d3f8d020c17e4de584d29600ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"08a32c2484ea5bf40df125146f38784f59353ce4ee29850a3c2e32044c6e44e2","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedFormat":99},{"version":"73e2e30e5548c0c78fe23446df2b3064253f5298bc9353472ae4efc9257a0e3e","affectsGlobalScope":true,"impliedFormat":1},{"version":"c357e3e5784932472935646f2d207ee0574ab9122d85d55ca10a33b0757d0614","affectsGlobalScope":true,"impliedFormat":1}],"root":[72],"options":{"composite":true,"declaration":true,"declarationDir":"./esm","declarationMap":true,"esModuleInterop":true,"exactOptionalPropertyTypes":true,"module":199,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitOverride":true,"noImplicitReturns":true,"noImplicitThis":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./esm","rootDir":"./worker","skipLibCheck":true,"sourceMap":true,"strict":true,"stripInternal":true,"target":99,"verbatimModuleSyntax":true},"fileIdsList":[[73]],"referencedMap":[[74,1]],"latestChangedDtsFile":"./esm/worker.d.ts"},"version":"5.5.3"}
@@ -0,0 +1,360 @@
1
+ const INPUT_HOP_SIZE = 3000;
2
+ const SCALE = 0.9;
3
+ const OUTPUT_HOP_SIZE = (INPUT_HOP_SIZE * SCALE) | 0;
4
+
5
+ const WINDOW_SIZE = 6000;
6
+ const WINDOW_WEIGHT_TABLE = new Float32Array(WINDOW_SIZE);
7
+ for (let i = 0; i < WINDOW_SIZE / 2; i += 1) {
8
+ const value = Math.sin((i / WINDOW_SIZE) * Math.PI);
9
+ WINDOW_WEIGHT_TABLE[i] = value;
10
+ WINDOW_WEIGHT_TABLE[WINDOW_SIZE - i - 1] = value;
11
+ }
12
+
13
+ abstract class SourceProcessor<T>
14
+ extends AudioWorkletProcessor
15
+ implements AudioWorkletProcessorImpl
16
+ {
17
+ channelCount: number;
18
+ #readBuffer: Float32Array;
19
+
20
+ #chunks: T[] = [];
21
+ #chunkSampleCounts: number[] = [];
22
+ #totalSampleCount = 0;
23
+
24
+ #starting = true;
25
+ #speedUp = false;
26
+ #readOffset = 0;
27
+ #inputOffset = 0;
28
+ #outputOffset = 0;
29
+
30
+ constructor(options: { outputChannelCount?: number[] }) {
31
+ super();
32
+
33
+ this.channelCount = options.outputChannelCount![0]!;
34
+ this.#readBuffer = new Float32Array(this.channelCount);
35
+
36
+ this.port.onmessage = (event) => {
37
+ while (this.#totalSampleCount > 0.35 * 48000) {
38
+ this.#chunks.shift();
39
+ const count = this.#chunkSampleCounts.shift()!;
40
+ this.#totalSampleCount -= count;
41
+ }
42
+
43
+ const data = event.data as ArrayBuffer[];
44
+ const [source, length] = this.createSource(data);
45
+ this.#chunks.push(source);
46
+ this.#chunkSampleCounts.push(length);
47
+ this.#totalSampleCount += length;
48
+
49
+ if (!this.#speedUp && this.#totalSampleCount > 0.25 * 48000) {
50
+ this.#speedUp = true;
51
+ this.#readOffset = 0;
52
+ this.#inputOffset = 0;
53
+ this.#outputOffset = 0;
54
+ }
55
+ };
56
+ }
57
+
58
+ protected abstract createSource(data: ArrayBuffer[]): [T, number];
59
+
60
+ process(_inputs: Float32Array[][], [outputs]: [Float32Array[]]) {
61
+ if (this.#starting) {
62
+ if (this.#totalSampleCount < 0.1 * 48000) {
63
+ return true;
64
+ } else {
65
+ this.#starting = false;
66
+ }
67
+ }
68
+
69
+ if (this.#speedUp && this.#totalSampleCount < 0.15 * 48000) {
70
+ this.#speedUp = false;
71
+ this.#starting = true;
72
+ }
73
+
74
+ const outputLength = outputs[0]!.length;
75
+
76
+ if (this.#speedUp) {
77
+ for (let i = 0; i < outputLength; i += 1) {
78
+ let totalWeight = 0;
79
+
80
+ const firstWindow = Math.max(
81
+ 0,
82
+ Math.floor(
83
+ (this.#outputOffset - WINDOW_SIZE) / OUTPUT_HOP_SIZE,
84
+ ) + 1,
85
+ );
86
+
87
+ let inWindowIndex =
88
+ this.#outputOffset - firstWindow * OUTPUT_HOP_SIZE;
89
+ let inputIndex = firstWindow * INPUT_HOP_SIZE + inWindowIndex;
90
+
91
+ while (inputIndex > 0 && inWindowIndex >= 0) {
92
+ this.#read(inputIndex - this.#readOffset);
93
+ const weight = WINDOW_WEIGHT_TABLE[inWindowIndex]!;
94
+ for (let j = 0; j < this.channelCount; j += 1) {
95
+ outputs[j]![i]! += this.#readBuffer[j]! * weight;
96
+ }
97
+ totalWeight += weight;
98
+
99
+ inputIndex += INPUT_HOP_SIZE - OUTPUT_HOP_SIZE;
100
+ inWindowIndex -= OUTPUT_HOP_SIZE;
101
+ }
102
+
103
+ if (totalWeight > 0) {
104
+ for (let j = 0; j < this.channelCount; j += 1) {
105
+ outputs[j]![i]! /= totalWeight;
106
+ }
107
+ }
108
+
109
+ this.#outputOffset += 1;
110
+ if (firstWindow > 0) {
111
+ this.#outputOffset -= OUTPUT_HOP_SIZE;
112
+ this.#readOffset -= INPUT_HOP_SIZE;
113
+ this.#inputOffset += (1 - SCALE) * INPUT_HOP_SIZE;
114
+ }
115
+ }
116
+
117
+ this.#inputOffset += outputLength;
118
+ const firstChunkSampleCount = this.#chunkSampleCounts[0]!;
119
+ if (
120
+ firstChunkSampleCount !== undefined &&
121
+ this.#inputOffset >= firstChunkSampleCount
122
+ ) {
123
+ this.#chunks.shift();
124
+ this.#chunkSampleCounts.shift();
125
+ this.#totalSampleCount -= firstChunkSampleCount;
126
+ this.#readOffset += firstChunkSampleCount;
127
+ this.#inputOffset -= firstChunkSampleCount;
128
+ }
129
+ } else {
130
+ this.#copyChunks(outputs);
131
+ }
132
+
133
+ return true;
134
+ }
135
+
136
+ #copyChunks(outputs: Float32Array[]) {
137
+ let outputIndex = 0;
138
+ const outputLength = outputs[0]!.length;
139
+
140
+ while (this.#chunks.length > 0 && outputIndex < outputLength) {
141
+ let source: T | undefined = this.#chunks[0];
142
+ let consumedSampleCount = 0;
143
+ [source, consumedSampleCount, outputIndex] = this.copyChunk(
144
+ source!,
145
+ outputs,
146
+ outputLength,
147
+ outputIndex,
148
+ );
149
+
150
+ this.#totalSampleCount -= consumedSampleCount;
151
+
152
+ if (source) {
153
+ // Output full
154
+ this.#chunks[0] = source;
155
+ this.#chunkSampleCounts[0]! -= consumedSampleCount;
156
+ return;
157
+ }
158
+
159
+ this.#chunks.shift();
160
+ this.#chunkSampleCounts.shift();
161
+ }
162
+ }
163
+
164
+ #read(offset: number) {
165
+ for (let i = 0; i < this.#chunks.length; i += 1) {
166
+ const length = this.#chunkSampleCounts[i]!;
167
+
168
+ if (offset < length) {
169
+ this.read(this.#chunks[i]!, offset, this.#readBuffer);
170
+ return;
171
+ }
172
+
173
+ offset -= length;
174
+ }
175
+
176
+ this.#readBuffer.fill(0);
177
+ }
178
+
179
+ protected abstract read(
180
+ source: T,
181
+ offset: number,
182
+ target: Float32Array,
183
+ ): void;
184
+
185
+ protected abstract copyChunk(
186
+ source: T,
187
+ outputs: Float32Array[],
188
+ outputLength: number,
189
+ outputIndex: number,
190
+ ): [source: T | undefined, sourceIndex: number, outputIndex: number];
191
+ }
192
+
193
+ class Int16SourceProcessor
194
+ extends SourceProcessor<Int16Array>
195
+ implements AudioWorkletProcessorImpl
196
+ {
197
+ protected override createSource(data: ArrayBuffer[]): [Int16Array, number] {
198
+ const source = new Int16Array(data[0]!);
199
+ return [source, source.length / this.channelCount];
200
+ }
201
+
202
+ protected override read(
203
+ source: Int16Array,
204
+ offset: number,
205
+ target: Float32Array,
206
+ ) {
207
+ const sourceOffset = offset * this.channelCount;
208
+ for (let i = 0; i < this.channelCount; i += 1) {
209
+ target[i] = source[sourceOffset + i]! / 0x8000;
210
+ }
211
+ }
212
+
213
+ protected override copyChunk(
214
+ source: Int16Array,
215
+ outputs: Float32Array[],
216
+ outputLength: number,
217
+ outputIndex: number,
218
+ ): [
219
+ source: Int16Array | undefined,
220
+ sourceIndex: number,
221
+ outputIndex: number,
222
+ ] {
223
+ const sourceLength = source.length;
224
+ let sourceIndex = 0;
225
+
226
+ while (sourceIndex < sourceLength) {
227
+ for (let i = 0; i < this.channelCount; i += 1) {
228
+ outputs[i]![outputIndex] = source[sourceIndex]! / 0x8000;
229
+ sourceIndex += 1;
230
+ }
231
+ outputIndex += 1;
232
+
233
+ if (outputIndex === outputLength) {
234
+ return [
235
+ sourceIndex < sourceLength
236
+ ? source.subarray(sourceIndex)
237
+ : undefined,
238
+ sourceIndex / this.channelCount,
239
+ outputIndex,
240
+ ];
241
+ }
242
+ }
243
+
244
+ return [undefined, sourceIndex / this.channelCount, outputIndex];
245
+ }
246
+ }
247
+
248
+ class Float32SourceProcessor extends SourceProcessor<Float32Array> {
249
+ protected override createSource(
250
+ data: ArrayBuffer[],
251
+ ): [Float32Array, number] {
252
+ const source = new Float32Array(data[0]!);
253
+ return [source, source.length / this.channelCount];
254
+ }
255
+
256
+ protected override read(
257
+ source: Float32Array,
258
+ offset: number,
259
+ target: Float32Array,
260
+ ) {
261
+ const sourceOffset = offset * this.channelCount;
262
+ for (let i = 0; i < this.channelCount; i += 1) {
263
+ target[i] = source[sourceOffset + i]!;
264
+ }
265
+ }
266
+
267
+ protected override copyChunk(
268
+ source: Float32Array,
269
+ outputs: Float32Array[],
270
+ outputLength: number,
271
+ outputIndex: number,
272
+ ): [
273
+ source: Float32Array | undefined,
274
+ sourceIndex: number,
275
+ outputIndex: number,
276
+ ] {
277
+ const sourceLength = source.length;
278
+ let sourceIndex = 0;
279
+
280
+ while (sourceIndex < sourceLength) {
281
+ for (let i = 0; i < this.channelCount; i += 1) {
282
+ outputs[i]![outputIndex] = source[sourceIndex]!;
283
+ sourceIndex += 1;
284
+ }
285
+ outputIndex += 1;
286
+
287
+ if (outputIndex === outputLength) {
288
+ return [
289
+ sourceIndex < sourceLength
290
+ ? source.subarray(sourceIndex)
291
+ : undefined,
292
+ sourceIndex / this.channelCount,
293
+ outputIndex,
294
+ ];
295
+ }
296
+ }
297
+
298
+ return [undefined, sourceIndex / this.channelCount, outputIndex];
299
+ }
300
+ }
301
+
302
+ class Float32PlanerSourceProcessor extends SourceProcessor<Float32Array[]> {
303
+ protected override createSource(
304
+ data: ArrayBuffer[],
305
+ ): [Float32Array[], number] {
306
+ const source = data.map((channel) => new Float32Array(channel));
307
+ return [source, source[0]!.length];
308
+ }
309
+
310
+ protected override read(
311
+ source: Float32Array[],
312
+ offset: number,
313
+ target: Float32Array,
314
+ ) {
315
+ for (let i = 0; i < target.length; i += 1) {
316
+ target[i] = source[i]![offset]!;
317
+ }
318
+ }
319
+
320
+ protected override copyChunk(
321
+ source: Float32Array[],
322
+ outputs: Float32Array[],
323
+ outputLength: number,
324
+ outputIndex: number,
325
+ ): [
326
+ source: Float32Array[] | undefined,
327
+ sourceIndex: number,
328
+ outputIndex: number,
329
+ ] {
330
+ const sourceLength = source[0]!.length;
331
+ let sourceIndex = 0;
332
+
333
+ while (sourceIndex < sourceLength) {
334
+ for (let i = 0; i < this.channelCount; i += 1) {
335
+ outputs[i]![outputIndex] = source[i]![sourceIndex]!;
336
+ }
337
+ sourceIndex += 1;
338
+ outputIndex += 1;
339
+
340
+ if (outputIndex === outputLength) {
341
+ return [
342
+ sourceIndex < sourceLength
343
+ ? source.map((channel) => channel.subarray(sourceIndex))
344
+ : undefined,
345
+ sourceIndex,
346
+ outputIndex,
347
+ ];
348
+ }
349
+ }
350
+
351
+ return [undefined, sourceIndex, outputIndex];
352
+ }
353
+ }
354
+
355
+ registerProcessor("int16-source-processor", Int16SourceProcessor);
356
+ registerProcessor("float32-source-processor", Float32SourceProcessor);
357
+ registerProcessor(
358
+ "float32-planer-source-processor",
359
+ Float32PlanerSourceProcessor,
360
+ );