@yume-chan/pcm-player 0.0.20
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.json +11 -0
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/esm/index.d.ts +24 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +72 -0
- package/esm/index.js.map +1 -0
- package/esm/worker.d.ts +2 -0
- package/esm/worker.d.ts.map +1 -0
- package/esm/worker.js +130 -0
- package/esm/worker.js.map +1 -0
- package/package.json +47 -0
- package/src/index.ts +105 -0
- package/tsconfig.dom.json +10 -0
- package/tsconfig.dom.tsbuildinfo +1 -0
- package/tsconfig.worker.json +15 -0
- package/tsconfig.worker.tsbuildinfo +1 -0
- package/worker/worker.ts +232 -0
package/CHANGELOG.json
ADDED
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2023 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,30 @@
|
|
|
1
|
+
# @yume-chan/pcm-player
|
|
2
|
+
|
|
3
|
+
Play raw audio sample stream using Web Audio API.
|
|
4
|
+
|
|
5
|
+
Only support stereo audio.
|
|
6
|
+
|
|
7
|
+
TODO:
|
|
8
|
+
|
|
9
|
+
- [ ] resample audio to compensate for audio buffer underrun
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Depends on the sample format, there are multiple player classes:
|
|
14
|
+
|
|
15
|
+
- `Int16PcmPlayer` (little endian)
|
|
16
|
+
- `Float32PcmPlayer`
|
|
17
|
+
- `Float32PlanerPcmPlayer`
|
|
18
|
+
|
|
19
|
+
No `Planer`: audio samples are interleaved (left channel first).
|
|
20
|
+
|
|
21
|
+
With `Planer`: audio samples are in a two-dimensional array (left channel first).
|
|
22
|
+
|
|
23
|
+
The constructors require user activation (must be invoked in a user event handler, e.g. `onclick`), because they create `AudioContext`s.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
var player = Int16PcmPlayer(44100);
|
|
27
|
+
player.start();
|
|
28
|
+
player.feed(new Int16Array([0, 0, 0, 0, 0, 0, 0, 0]));
|
|
29
|
+
player.stop(); // `AudioContext` will be closed, so can't be restarted
|
|
30
|
+
```
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare abstract class PcmPlayer<T> {
|
|
2
|
+
protected abstract sourceName: string;
|
|
3
|
+
private _context;
|
|
4
|
+
private _worklet;
|
|
5
|
+
private _buffer;
|
|
6
|
+
constructor(sampleRate: number);
|
|
7
|
+
protected abstract feedCore(worklet: AudioWorkletNode, source: T): void;
|
|
8
|
+
feed(source: T): void;
|
|
9
|
+
start(): Promise<void>;
|
|
10
|
+
stop(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare class Int16PcmPlayer extends PcmPlayer<Int16Array> {
|
|
13
|
+
protected sourceName: string;
|
|
14
|
+
protected feedCore(worklet: AudioWorkletNode, source: Int16Array): void;
|
|
15
|
+
}
|
|
16
|
+
export declare class Float32PcmPlayer extends PcmPlayer<Float32Array> {
|
|
17
|
+
protected sourceName: string;
|
|
18
|
+
protected feedCore(worklet: AudioWorkletNode, source: Float32Array): void;
|
|
19
|
+
}
|
|
20
|
+
export declare class Float32PlanerPcmPlayer extends PcmPlayer<Float32Array[]> {
|
|
21
|
+
protected sourceName: string;
|
|
22
|
+
protected feedCore(worklet: AudioWorkletNode, source: Float32Array[]): void;
|
|
23
|
+
}
|
|
24
|
+
//# 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;IAEtC,OAAO,CAAC,QAAQ,CAAe;IAC/B,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,OAAO,CAAW;gBAEd,UAAU,EAAE,MAAM;IAO9B,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAEhE,IAAI,CAAC,MAAM,EAAE,CAAC;IASR,KAAK;IAkBZ,IAAI;CAMb;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,72 @@
|
|
|
1
|
+
export class PcmPlayer {
|
|
2
|
+
_context;
|
|
3
|
+
_worklet;
|
|
4
|
+
_buffer = [];
|
|
5
|
+
constructor(sampleRate) {
|
|
6
|
+
this._context = new AudioContext({
|
|
7
|
+
latencyHint: "interactive",
|
|
8
|
+
sampleRate,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
feed(source) {
|
|
12
|
+
if (this._worklet === undefined) {
|
|
13
|
+
this._buffer.push(source);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this.feedCore(this._worklet, source);
|
|
17
|
+
}
|
|
18
|
+
async start() {
|
|
19
|
+
await this._context.audioWorklet.addModule(new URL("./worker.js", import.meta.url));
|
|
20
|
+
this._worklet = new AudioWorkletNode(this._context, this.sourceName, {
|
|
21
|
+
numberOfInputs: 0,
|
|
22
|
+
numberOfOutputs: 1,
|
|
23
|
+
outputChannelCount: [2],
|
|
24
|
+
});
|
|
25
|
+
this._worklet.connect(this._context.destination);
|
|
26
|
+
for (const source of this._buffer) {
|
|
27
|
+
this.feedCore(this._worklet, source);
|
|
28
|
+
}
|
|
29
|
+
this._buffer.length = 0;
|
|
30
|
+
}
|
|
31
|
+
async stop() {
|
|
32
|
+
this._worklet?.disconnect();
|
|
33
|
+
this._worklet = undefined;
|
|
34
|
+
await this._context.close();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class Int16PcmPlayer extends PcmPlayer {
|
|
38
|
+
sourceName = "int16-source-processor";
|
|
39
|
+
feedCore(worklet, source) {
|
|
40
|
+
if (source.byteOffset !== 0 ||
|
|
41
|
+
source.byteLength !== source.buffer.byteLength) {
|
|
42
|
+
source = source.slice();
|
|
43
|
+
}
|
|
44
|
+
const { buffer } = source;
|
|
45
|
+
worklet.port.postMessage([buffer], [buffer]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class Float32PcmPlayer extends PcmPlayer {
|
|
49
|
+
sourceName = "float32-source-processor";
|
|
50
|
+
feedCore(worklet, source) {
|
|
51
|
+
if (source.byteOffset !== 0 ||
|
|
52
|
+
source.byteLength !== source.buffer.byteLength) {
|
|
53
|
+
source = source.slice();
|
|
54
|
+
}
|
|
55
|
+
const { buffer } = source;
|
|
56
|
+
worklet.port.postMessage([buffer], [buffer]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export class Float32PlanerPcmPlayer extends PcmPlayer {
|
|
60
|
+
sourceName = "float32-planer-source-processor";
|
|
61
|
+
feedCore(worklet, source) {
|
|
62
|
+
const buffers = source.map((channel) => {
|
|
63
|
+
if (channel.byteOffset !== 0 ||
|
|
64
|
+
channel.byteLength !== channel.buffer.byteLength) {
|
|
65
|
+
channel = channel.slice();
|
|
66
|
+
}
|
|
67
|
+
return channel.buffer;
|
|
68
|
+
});
|
|
69
|
+
worklet.port.postMessage(buffers, buffers);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,SAAS;IAGnB,QAAQ,CAAe;IACvB,QAAQ,CAA+B;IACvC,OAAO,GAAQ,EAAE,CAAC;IAE1B,YAAY,UAAkB;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC;YAC7B,WAAW,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OAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;CACJ"}
|
package/esm/worker.d.ts
ADDED
|
@@ -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,130 @@
|
|
|
1
|
+
class SourceProcessor extends AudioWorkletProcessor {
|
|
2
|
+
_sources = [];
|
|
3
|
+
_sourceSampleCount = 0;
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.port.onmessage = (event) => {
|
|
7
|
+
const data = event.data;
|
|
8
|
+
const [source, length] = this.createSource(data);
|
|
9
|
+
this._sources.push(source);
|
|
10
|
+
this._sourceSampleCount += length;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
process(_inputs, outputs) {
|
|
14
|
+
const outputLeft = outputs[0][0];
|
|
15
|
+
const outputRight = outputs[0][1];
|
|
16
|
+
const outputLength = outputLeft.length;
|
|
17
|
+
let outputIndex = 0;
|
|
18
|
+
// Resample source catch up with output
|
|
19
|
+
// TODO: should we limit the minimum and maximum speed?
|
|
20
|
+
// TODO: this simple resample method changes pitch
|
|
21
|
+
const sourceIndexStep = this._sourceSampleCount > 48000 ? 1.02 : 1;
|
|
22
|
+
let sourceIndex = 0;
|
|
23
|
+
while (this._sources.length > 0 && outputIndex < outputLength) {
|
|
24
|
+
const beginSourceIndex = sourceIndex | 0;
|
|
25
|
+
let source = this._sources[0];
|
|
26
|
+
[source, sourceIndex, outputIndex] = this.copyChunk(sourceIndex, sourceIndexStep, source, outputLeft, outputRight, outputLength, outputIndex);
|
|
27
|
+
const consumedSampleCount = (sourceIndex | 0) - beginSourceIndex;
|
|
28
|
+
this._sourceSampleCount -= consumedSampleCount;
|
|
29
|
+
sourceIndex -= consumedSampleCount;
|
|
30
|
+
if (source) {
|
|
31
|
+
// Output full
|
|
32
|
+
this._sources[0] = source;
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
this._sources.shift();
|
|
36
|
+
}
|
|
37
|
+
if (outputIndex < outputLength) {
|
|
38
|
+
console.log(`[Audio] Buffer underflow, inserting silence: ${outputLength - outputIndex} samples`);
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
class Int16SourceProcessor extends SourceProcessor {
|
|
44
|
+
createSource(data) {
|
|
45
|
+
const source = new Int16Array(data[0]);
|
|
46
|
+
return [source, source.length / 2];
|
|
47
|
+
}
|
|
48
|
+
copyChunk(sourceIndex, sourceIndexStep, source, outputLeft, outputRight, outputLength, outputIndex) {
|
|
49
|
+
const sourceLength = source.length;
|
|
50
|
+
let sourceSampleIndex = sourceIndex << 1;
|
|
51
|
+
while (sourceSampleIndex < sourceLength) {
|
|
52
|
+
outputLeft[outputIndex] = source[sourceSampleIndex] / 0x8000;
|
|
53
|
+
outputRight[outputIndex] = source[sourceSampleIndex + 1] / 0x8000;
|
|
54
|
+
sourceIndex += sourceIndexStep;
|
|
55
|
+
sourceSampleIndex = sourceIndex << 1;
|
|
56
|
+
outputIndex += 1;
|
|
57
|
+
if (outputIndex === outputLength) {
|
|
58
|
+
return [
|
|
59
|
+
sourceSampleIndex < sourceLength
|
|
60
|
+
? source.subarray(sourceSampleIndex)
|
|
61
|
+
: undefined,
|
|
62
|
+
sourceIndex,
|
|
63
|
+
outputIndex,
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return [undefined, sourceIndex, outputIndex];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
class Float32SourceProcessor extends SourceProcessor {
|
|
71
|
+
createSource(data) {
|
|
72
|
+
const source = new Float32Array(data[0]);
|
|
73
|
+
return [source, source.length / 2];
|
|
74
|
+
}
|
|
75
|
+
copyChunk(sourceIndex, sourceIndexStep, source, outputLeft, outputRight, outputLength, outputIndex) {
|
|
76
|
+
const sourceLength = source.length;
|
|
77
|
+
let sourceSampleIndex = sourceIndex << 1;
|
|
78
|
+
while (sourceSampleIndex < sourceLength) {
|
|
79
|
+
outputLeft[outputIndex] = source[sourceSampleIndex];
|
|
80
|
+
outputRight[outputIndex] = source[sourceSampleIndex + 1];
|
|
81
|
+
sourceIndex += sourceIndexStep;
|
|
82
|
+
sourceSampleIndex = sourceIndex << 1;
|
|
83
|
+
outputIndex += 1;
|
|
84
|
+
if (outputIndex === outputLength) {
|
|
85
|
+
return [
|
|
86
|
+
sourceSampleIndex < sourceLength
|
|
87
|
+
? source.subarray(sourceSampleIndex)
|
|
88
|
+
: undefined,
|
|
89
|
+
sourceIndex,
|
|
90
|
+
outputIndex,
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return [undefined, sourceIndex, outputIndex];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
class Float32PlanerSourceProcessor extends SourceProcessor {
|
|
98
|
+
createSource(data) {
|
|
99
|
+
const source = data.map((channel) => new Float32Array(channel));
|
|
100
|
+
return [source, source[0].length];
|
|
101
|
+
}
|
|
102
|
+
copyChunk(sourceIndex, sourceIndexStep, source, outputLeft, outputRight, outputLength, outputIndex) {
|
|
103
|
+
const sourceLeft = source[0];
|
|
104
|
+
const sourceRight = source[1];
|
|
105
|
+
const sourceLength = sourceLeft.length;
|
|
106
|
+
let sourceSampleIndex = sourceIndex | 0;
|
|
107
|
+
while (sourceSampleIndex < sourceLength) {
|
|
108
|
+
outputLeft[outputIndex] = sourceLeft[sourceSampleIndex];
|
|
109
|
+
outputRight[outputIndex] = sourceRight[sourceSampleIndex];
|
|
110
|
+
sourceIndex += sourceIndexStep;
|
|
111
|
+
sourceSampleIndex = sourceIndex | 0;
|
|
112
|
+
outputIndex += 1;
|
|
113
|
+
if (outputIndex === outputLength) {
|
|
114
|
+
return [
|
|
115
|
+
sourceSampleIndex < sourceLength
|
|
116
|
+
? source.map((channel) => channel.subarray(sourceSampleIndex))
|
|
117
|
+
: undefined,
|
|
118
|
+
sourceIndex,
|
|
119
|
+
outputIndex,
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return [undefined, sourceIndex, outputIndex];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
registerProcessor("int16-source-processor", Int16SourceProcessor);
|
|
127
|
+
registerProcessor("float32-source-processor", Float32SourceProcessor);
|
|
128
|
+
registerProcessor("float32-planer-source-processor", Float32PlanerSourceProcessor);
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../worker/worker.ts"],"names":[],"mappings":"AAAA,MAAe,eACX,SAAQ,qBAAqB;IAGrB,QAAQ,GAAQ,EAAE,CAAC;IACnB,kBAAkB,GAAG,CAAC,CAAC;IAE/B;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE;YAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAqB,CAAC;YACzC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3B,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC;QACtC,CAAC,CAAC;IACN,CAAC;IAID,OAAO,CAAC,OAAyB,EAAE,OAAyB;QACxD,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,CAAC;QACnC,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,CAAC;QACpC,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC;QACvC,IAAI,WAAW,GAAG,CAAC,CAAC;QAEpB,uCAAuC;QACvC,uDAAuD;QACvD,kDAAkD;QAClD,MAAM,eAAe,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,CAAC,GAAG,UAAU,CAAC,iBAAiB,CAAE,CAAC;YACzD,WAAW,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,iBAAiB,CAAE,CAAC;YAE3D,WAAW,IAAI,eAAe,CAAC;YAC/B,iBAAiB,GAAG,WAAW,GAAG,CAAC,CAAC;YACpC,WAAW,IAAI,CAAC,CAAC;YAEjB,IAAI,WAAW,KAAK,YAAY,EAAE;gBAC9B,OAAO;oBACH,iBAAiB,GAAG,YAAY;wBAC5B,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACnB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CACtC;wBACH,CAAC,CAAC,SAAS;oBACf,WAAW;oBACX,WAAW;iBACd,CAAC;aACL;SACJ;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,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yume-chan/pcm-player",
|
|
3
|
+
"version": "0.0.20",
|
|
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
|
+
"dependencies": {
|
|
27
|
+
"tslib": "^2.5.2"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@jest/globals": "^29.5.0",
|
|
31
|
+
"@types/audioworklet": "^0.0.46",
|
|
32
|
+
"@yume-chan/eslint-config": "^1.0.0",
|
|
33
|
+
"@yume-chan/tsconfig": "^1.0.0",
|
|
34
|
+
"cross-env": "^7.0.3",
|
|
35
|
+
"eslint": "^8.41.0",
|
|
36
|
+
"jest": "^29.5.0",
|
|
37
|
+
"prettier": "^2.8.8",
|
|
38
|
+
"ts-jest": "^29.0.4",
|
|
39
|
+
"typescript": "^5.0.3"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc -b tsconfig.dom.json && tsc -b tsconfig.worker.json",
|
|
43
|
+
"build:watch": "tsc -b tsconfig.dom.json && tsc -b tsconfig.worker.json",
|
|
44
|
+
"//test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
|
|
45
|
+
"lint": "eslint src/**/*.ts --fix && prettier src/**/*.ts --write --tab-width 4"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export abstract class PcmPlayer<T> {
|
|
2
|
+
protected abstract sourceName: string;
|
|
3
|
+
|
|
4
|
+
private _context: AudioContext;
|
|
5
|
+
private _worklet: AudioWorkletNode | undefined;
|
|
6
|
+
private _buffer: T[] = [];
|
|
7
|
+
|
|
8
|
+
constructor(sampleRate: number) {
|
|
9
|
+
this._context = new AudioContext({
|
|
10
|
+
latencyHint: "interactive",
|
|
11
|
+
sampleRate,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected abstract feedCore(worklet: AudioWorkletNode, source: T): void;
|
|
16
|
+
|
|
17
|
+
public feed(source: T) {
|
|
18
|
+
if (this._worklet === undefined) {
|
|
19
|
+
this._buffer.push(source);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
this.feedCore(this._worklet, source);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public async start() {
|
|
27
|
+
await this._context.audioWorklet.addModule(
|
|
28
|
+
new URL("./worker.js", import.meta.url)
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
this._worklet = new AudioWorkletNode(this._context, this.sourceName, {
|
|
32
|
+
numberOfInputs: 0,
|
|
33
|
+
numberOfOutputs: 1,
|
|
34
|
+
outputChannelCount: [2],
|
|
35
|
+
});
|
|
36
|
+
this._worklet.connect(this._context.destination);
|
|
37
|
+
|
|
38
|
+
for (const source of this._buffer) {
|
|
39
|
+
this.feedCore(this._worklet, source);
|
|
40
|
+
}
|
|
41
|
+
this._buffer.length = 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async stop() {
|
|
45
|
+
this._worklet?.disconnect();
|
|
46
|
+
this._worklet = undefined;
|
|
47
|
+
|
|
48
|
+
await this._context.close();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class Int16PcmPlayer extends PcmPlayer<Int16Array> {
|
|
53
|
+
protected override sourceName = "int16-source-processor";
|
|
54
|
+
|
|
55
|
+
protected override feedCore(worklet: AudioWorkletNode, source: Int16Array) {
|
|
56
|
+
if (
|
|
57
|
+
source.byteOffset !== 0 ||
|
|
58
|
+
source.byteLength !== source.buffer.byteLength
|
|
59
|
+
) {
|
|
60
|
+
source = source.slice();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const { buffer } = source;
|
|
64
|
+
worklet.port.postMessage([buffer], [buffer]);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class Float32PcmPlayer extends PcmPlayer<Float32Array> {
|
|
69
|
+
protected override sourceName = "float32-source-processor";
|
|
70
|
+
|
|
71
|
+
protected override feedCore(
|
|
72
|
+
worklet: AudioWorkletNode,
|
|
73
|
+
source: Float32Array
|
|
74
|
+
) {
|
|
75
|
+
if (
|
|
76
|
+
source.byteOffset !== 0 ||
|
|
77
|
+
source.byteLength !== source.buffer.byteLength
|
|
78
|
+
) {
|
|
79
|
+
source = source.slice();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const { buffer } = source;
|
|
83
|
+
worklet.port.postMessage([buffer], [buffer]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export class Float32PlanerPcmPlayer extends PcmPlayer<Float32Array[]> {
|
|
88
|
+
protected override sourceName = "float32-planer-source-processor";
|
|
89
|
+
|
|
90
|
+
protected override feedCore(
|
|
91
|
+
worklet: AudioWorkletNode,
|
|
92
|
+
source: Float32Array[]
|
|
93
|
+
) {
|
|
94
|
+
const buffers = source.map((channel) => {
|
|
95
|
+
if (
|
|
96
|
+
channel.byteOffset !== 0 ||
|
|
97
|
+
channel.byteLength !== channel.buffer.byteLength
|
|
98
|
+
) {
|
|
99
|
+
channel = channel.slice();
|
|
100
|
+
}
|
|
101
|
+
return channel.buffer;
|
|
102
|
+
});
|
|
103
|
+
worklet.port.postMessage(buffers, buffers);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es5.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2016.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2021.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2023.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.esnext.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.dom.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.core.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.array.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.date.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.number.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2021.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.array.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.error.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2023.array.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.decorators.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../common/temp/node_modules/.pnpm/tslib@2.5.2/node_modules/tslib/tslib.d.ts","../../common/temp/node_modules/.pnpm/tslib@2.5.2/node_modules/tslib/modules/index.d.ts","./src/index.ts"],"fileInfos":[{"version":"6a6b471e7e43e15ef6f8fe617a22ce4ecb0e34efa6c3dfcfe7cebd392bcca9d2","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","impliedFormat":1},{"version":"27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","impliedFormat":1},{"version":"f4e736d6c8d69ae5b3ab0ddfcaa3dc365c3e76909d6660af5b4e979b3934ac20","impliedFormat":1},{"version":"eeeb3aca31fbadef8b82502484499dfd1757204799a6f5b33116201c810676ec","impliedFormat":1},{"version":"fcd3ecc9f764f06f4d5c467677f4f117f6abf49dee6716283aa204ff1162498b","affectsGlobalScope":true,"impliedFormat":1},{"version":"f296963760430fb65b4e5d91f0ed770a91c6e77455bacf8fa23a1501654ede0e","affectsGlobalScope":true,"impliedFormat":1},{"version":"5114a95689b63f96b957e00216bc04baf9e1a1782aa4d8ee7e5e9acbf768e301","affectsGlobalScope":true,"impliedFormat":1},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true,"impliedFormat":1},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true,"impliedFormat":1},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true,"impliedFormat":1},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true,"impliedFormat":1},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true,"impliedFormat":1},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true,"impliedFormat":1},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true,"impliedFormat":1},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true,"impliedFormat":1},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true,"impliedFormat":1},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true,"impliedFormat":1},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7e9f95a7387e3f66be0ed6db43600c49cec33a3900437ce2fd350d9b7cb16f2","affectsGlobalScope":true,"impliedFormat":1},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true,"impliedFormat":1},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true,"impliedFormat":1},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true,"impliedFormat":1},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true,"impliedFormat":1},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"709efdae0cb5df5f49376cde61daacc95cdd44ae4671da13a540da5088bf3f30","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"61ed9b6d07af959e745fb11f9593ecd743b279418cc8a99448ea3cd5f3b3eb22","affectsGlobalScope":true,"impliedFormat":1},{"version":"038a2f66a34ee7a9c2fbc3584c8ab43dff2995f8c68e3f566f4c300d2175e31e","affectsGlobalScope":true,"impliedFormat":1},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c92f2c27b06c1a41b88f6db8299205aee52c2a2943f7ed29bd585977f254e8","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7feb7967c6c6003e11f49efa8f5de989484e0a6ba2e5a6c41b55f8b8bd85dba","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"b9ea5778ff8b50d7c04c9890170db34c26a5358cccba36844fe319f50a43a61a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true,"impliedFormat":1},{"version":"25de46552b782d43cb7284df22fe2a265de387cf0248b747a7a1b647d81861f6","affectsGlobalScope":true,"impliedFormat":1},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true,"impliedFormat":1},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"f1c9fe42b65437a61104e601eb298c5c859fb522b483f1bdb700eed67a16f980","impliedFormat":1},{"version":"0734467ebd328b91af92eff2af9c97f6079bc4736c4992f8a5e47123680cf21b","impliedFormat":99},{"version":"f5821eb961389032e64f92c0f24f76090538f6fed2a3b8e5882c32d8840699a0","signature":"35d641c7371c27612b40007e4f7d21bd7b76caf0d3c903f61b217dd4ce44db52","impliedFormat":99}],"root":[63],"options":{"composite":true,"declaration":true,"declarationDir":"./esm","declarationMap":true,"esModuleInterop":true,"exactOptionalPropertyTypes":true,"importHelpers":true,"module":199,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitOverride":true,"noImplicitReturns":true,"noImplicitThis":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"outDir":"./esm","rootDir":"./src","skipLibCheck":true,"sourceMap":true,"strict":true,"stripInternal":true,"target":99},"fileIdsList":[[61],[62]],"referencedMap":[[62,1],[63,2]],"exportedModulesMap":[[62,1]],"semanticDiagnosticsPerFile":[62,61,59,60,12,14,13,2,15,16,17,18,19,20,21,22,3,4,26,23,24,25,27,28,29,5,30,31,32,33,6,37,34,35,36,38,7,39,44,45,40,41,42,43,8,49,46,47,48,50,9,51,52,53,56,54,55,57,10,1,11,58,63],"latestChangedDtsFile":"./esm/index.d.ts"},"version":"5.0.4"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es5.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2016.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2021.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2023.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.esnext.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.core.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.array.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.date.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2020.number.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2021.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.array.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.error.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.es2023.array.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.decorators.d.ts","../../common/temp/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../common/temp/node_modules/.pnpm/tslib@2.5.2/node_modules/tslib/tslib.d.ts","../../common/temp/node_modules/.pnpm/tslib@2.5.2/node_modules/tslib/modules/index.d.ts","./worker/worker.ts","../../common/temp/node_modules/.pnpm/@types+audioworklet@0.0.46/node_modules/@types/audioworklet/iterable.d.ts","../../common/temp/node_modules/.pnpm/@types+audioworklet@0.0.46/node_modules/@types/audioworklet/index.d.ts"],"fileInfos":[{"version":"6a6b471e7e43e15ef6f8fe617a22ce4ecb0e34efa6c3dfcfe7cebd392bcca9d2","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","impliedFormat":1},{"version":"27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","impliedFormat":1},{"version":"f4e736d6c8d69ae5b3ab0ddfcaa3dc365c3e76909d6660af5b4e979b3934ac20","impliedFormat":1},{"version":"eeeb3aca31fbadef8b82502484499dfd1757204799a6f5b33116201c810676ec","impliedFormat":1},{"version":"f296963760430fb65b4e5d91f0ed770a91c6e77455bacf8fa23a1501654ede0e","affectsGlobalScope":true,"impliedFormat":1},{"version":"5114a95689b63f96b957e00216bc04baf9e1a1782aa4d8ee7e5e9acbf768e301","affectsGlobalScope":true,"impliedFormat":1},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true,"impliedFormat":1},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true,"impliedFormat":1},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true,"impliedFormat":1},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true,"impliedFormat":1},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true,"impliedFormat":1},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true,"impliedFormat":1},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true,"impliedFormat":1},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true,"impliedFormat":1},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true,"impliedFormat":1},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true,"impliedFormat":1},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7e9f95a7387e3f66be0ed6db43600c49cec33a3900437ce2fd350d9b7cb16f2","affectsGlobalScope":true,"impliedFormat":1},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true,"impliedFormat":1},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true,"impliedFormat":1},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true,"impliedFormat":1},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true,"impliedFormat":1},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"709efdae0cb5df5f49376cde61daacc95cdd44ae4671da13a540da5088bf3f30","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"61ed9b6d07af959e745fb11f9593ecd743b279418cc8a99448ea3cd5f3b3eb22","affectsGlobalScope":true,"impliedFormat":1},{"version":"038a2f66a34ee7a9c2fbc3584c8ab43dff2995f8c68e3f566f4c300d2175e31e","affectsGlobalScope":true,"impliedFormat":1},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c92f2c27b06c1a41b88f6db8299205aee52c2a2943f7ed29bd585977f254e8","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7feb7967c6c6003e11f49efa8f5de989484e0a6ba2e5a6c41b55f8b8bd85dba","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"b9ea5778ff8b50d7c04c9890170db34c26a5358cccba36844fe319f50a43a61a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true,"impliedFormat":1},{"version":"25de46552b782d43cb7284df22fe2a265de387cf0248b747a7a1b647d81861f6","affectsGlobalScope":true,"impliedFormat":1},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true,"impliedFormat":1},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"f1c9fe42b65437a61104e601eb298c5c859fb522b483f1bdb700eed67a16f980","impliedFormat":1},{"version":"0734467ebd328b91af92eff2af9c97f6079bc4736c4992f8a5e47123680cf21b","impliedFormat":99},{"version":"aa5cd8cb95e1c0d87c2d4fed89d0ca20a8fe1a03ff6c2160eba8999f52cb35c7","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","impliedFormat":99},{"version":"b38d0bfd2d1c1536d40fc5941fab5c5dd2749fb874fb57c451211ab806a3be8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"98946e52823abc46bd68de999a99d6cbaec5b8a17381f415008f1bd4b4c97101","affectsGlobalScope":true,"impliedFormat":1}],"root":[62],"options":{"composite":true,"declaration":true,"declarationDir":"./esm","declarationMap":true,"esModuleInterop":true,"exactOptionalPropertyTypes":true,"importHelpers":true,"module":199,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitOverride":true,"noImplicitReturns":true,"noImplicitThis":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"outDir":"./esm","rootDir":"./worker","skipLibCheck":true,"sourceMap":true,"strict":true,"stripInternal":true,"target":99},"fileIdsList":[[63],[60],[61]],"referencedMap":[[64,1],[61,2],[62,3]],"exportedModulesMap":[[64,1],[61,2]],"semanticDiagnosticsPerFile":[64,63,61,60,58,59,13,12,2,14,15,16,17,18,19,20,21,3,4,25,22,23,24,26,27,28,5,29,30,31,32,6,36,33,34,35,37,7,38,43,44,39,40,41,42,8,48,45,46,47,49,9,50,51,52,55,53,54,56,10,1,11,57,62],"latestChangedDtsFile":"./esm/worker.d.ts"},"version":"5.0.4"}
|
package/worker/worker.ts
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
abstract class SourceProcessor<T>
|
|
2
|
+
extends AudioWorkletProcessor
|
|
3
|
+
implements AudioWorkletProcessorImpl
|
|
4
|
+
{
|
|
5
|
+
private _sources: T[] = [];
|
|
6
|
+
private _sourceSampleCount = 0;
|
|
7
|
+
|
|
8
|
+
public constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.port.onmessage = (event) => {
|
|
11
|
+
const data = event.data as ArrayBuffer[];
|
|
12
|
+
const [source, length] = this.createSource(data);
|
|
13
|
+
this._sources.push(source);
|
|
14
|
+
this._sourceSampleCount += length;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
protected abstract createSource(data: ArrayBuffer[]): [T, number];
|
|
19
|
+
|
|
20
|
+
process(_inputs: Float32Array[][], outputs: Float32Array[][]) {
|
|
21
|
+
const outputLeft = outputs[0]![0]!;
|
|
22
|
+
const outputRight = outputs[0]![1]!;
|
|
23
|
+
const outputLength = outputLeft.length;
|
|
24
|
+
let outputIndex = 0;
|
|
25
|
+
|
|
26
|
+
// Resample source catch up with output
|
|
27
|
+
// TODO: should we limit the minimum and maximum speed?
|
|
28
|
+
// TODO: this simple resample method changes pitch
|
|
29
|
+
const sourceIndexStep = this._sourceSampleCount > 48000 ? 1.02 : 1;
|
|
30
|
+
let sourceIndex = 0;
|
|
31
|
+
|
|
32
|
+
while (this._sources.length > 0 && outputIndex < outputLength) {
|
|
33
|
+
const beginSourceIndex = sourceIndex | 0;
|
|
34
|
+
|
|
35
|
+
let source: T | undefined = this._sources[0];
|
|
36
|
+
[source, sourceIndex, outputIndex] = this.copyChunk(
|
|
37
|
+
sourceIndex,
|
|
38
|
+
sourceIndexStep,
|
|
39
|
+
source!,
|
|
40
|
+
outputLeft,
|
|
41
|
+
outputRight,
|
|
42
|
+
outputLength,
|
|
43
|
+
outputIndex
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const consumedSampleCount = (sourceIndex | 0) - beginSourceIndex;
|
|
47
|
+
this._sourceSampleCount -= consumedSampleCount;
|
|
48
|
+
sourceIndex -= consumedSampleCount;
|
|
49
|
+
|
|
50
|
+
if (source) {
|
|
51
|
+
// Output full
|
|
52
|
+
this._sources[0] = source;
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this._sources.shift();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (outputIndex < outputLength) {
|
|
60
|
+
console.log(
|
|
61
|
+
`[Audio] Buffer underflow, inserting silence: ${
|
|
62
|
+
outputLength - outputIndex
|
|
63
|
+
} samples`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected abstract copyChunk(
|
|
71
|
+
sourceIndex: number,
|
|
72
|
+
sourceIndexStep: number,
|
|
73
|
+
source: T,
|
|
74
|
+
outputLeft: Float32Array,
|
|
75
|
+
outputRight: Float32Array,
|
|
76
|
+
outputLength: number,
|
|
77
|
+
outputIndex: number
|
|
78
|
+
): [source: T | undefined, sourceIndex: number, outputIndex: number];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
class Int16SourceProcessor
|
|
82
|
+
extends SourceProcessor<Int16Array>
|
|
83
|
+
implements AudioWorkletProcessorImpl
|
|
84
|
+
{
|
|
85
|
+
protected override createSource(data: ArrayBuffer[]): [Int16Array, number] {
|
|
86
|
+
const source = new Int16Array(data[0]!);
|
|
87
|
+
return [source, source.length / 2];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
protected override copyChunk(
|
|
91
|
+
sourceIndex: number,
|
|
92
|
+
sourceIndexStep: number,
|
|
93
|
+
source: Int16Array,
|
|
94
|
+
outputLeft: Float32Array,
|
|
95
|
+
outputRight: Float32Array,
|
|
96
|
+
outputLength: number,
|
|
97
|
+
outputIndex: number
|
|
98
|
+
): [
|
|
99
|
+
source: Int16Array | undefined,
|
|
100
|
+
sourceIndex: number,
|
|
101
|
+
outputIndex: number
|
|
102
|
+
] {
|
|
103
|
+
const sourceLength = source.length;
|
|
104
|
+
let sourceSampleIndex = sourceIndex << 1;
|
|
105
|
+
|
|
106
|
+
while (sourceSampleIndex < sourceLength) {
|
|
107
|
+
outputLeft[outputIndex] = source[sourceSampleIndex]! / 0x8000;
|
|
108
|
+
outputRight[outputIndex] = source[sourceSampleIndex + 1]! / 0x8000;
|
|
109
|
+
|
|
110
|
+
sourceIndex += sourceIndexStep;
|
|
111
|
+
sourceSampleIndex = sourceIndex << 1;
|
|
112
|
+
outputIndex += 1;
|
|
113
|
+
|
|
114
|
+
if (outputIndex === outputLength) {
|
|
115
|
+
return [
|
|
116
|
+
sourceSampleIndex < sourceLength
|
|
117
|
+
? source.subarray(sourceSampleIndex)
|
|
118
|
+
: undefined,
|
|
119
|
+
sourceIndex,
|
|
120
|
+
outputIndex,
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return [undefined, sourceIndex, outputIndex];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
class Float32SourceProcessor extends SourceProcessor<Float32Array> {
|
|
130
|
+
protected override createSource(
|
|
131
|
+
data: ArrayBuffer[]
|
|
132
|
+
): [Float32Array, number] {
|
|
133
|
+
const source = new Float32Array(data[0]!);
|
|
134
|
+
return [source, source.length / 2];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected override copyChunk(
|
|
138
|
+
sourceIndex: number,
|
|
139
|
+
sourceIndexStep: number,
|
|
140
|
+
source: Float32Array,
|
|
141
|
+
outputLeft: Float32Array,
|
|
142
|
+
outputRight: Float32Array,
|
|
143
|
+
outputLength: number,
|
|
144
|
+
outputIndex: number
|
|
145
|
+
): [
|
|
146
|
+
source: Float32Array | undefined,
|
|
147
|
+
sourceIndex: number,
|
|
148
|
+
outputIndex: number
|
|
149
|
+
] {
|
|
150
|
+
const sourceLength = source.length;
|
|
151
|
+
let sourceSampleIndex = sourceIndex << 1;
|
|
152
|
+
|
|
153
|
+
while (sourceSampleIndex < sourceLength) {
|
|
154
|
+
outputLeft[outputIndex] = source[sourceSampleIndex]!;
|
|
155
|
+
outputRight[outputIndex] = source[sourceSampleIndex + 1]!;
|
|
156
|
+
|
|
157
|
+
sourceIndex += sourceIndexStep;
|
|
158
|
+
sourceSampleIndex = sourceIndex << 1;
|
|
159
|
+
outputIndex += 1;
|
|
160
|
+
|
|
161
|
+
if (outputIndex === outputLength) {
|
|
162
|
+
return [
|
|
163
|
+
sourceSampleIndex < sourceLength
|
|
164
|
+
? source.subarray(sourceSampleIndex)
|
|
165
|
+
: undefined,
|
|
166
|
+
sourceIndex,
|
|
167
|
+
outputIndex,
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return [undefined, sourceIndex, outputIndex];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
class Float32PlanerSourceProcessor extends SourceProcessor<Float32Array[]> {
|
|
177
|
+
protected override createSource(
|
|
178
|
+
data: ArrayBuffer[]
|
|
179
|
+
): [Float32Array[], number] {
|
|
180
|
+
const source = data.map((channel) => new Float32Array(channel));
|
|
181
|
+
return [source, source[0]!.length];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
protected override copyChunk(
|
|
185
|
+
sourceIndex: number,
|
|
186
|
+
sourceIndexStep: number,
|
|
187
|
+
source: Float32Array[],
|
|
188
|
+
outputLeft: Float32Array,
|
|
189
|
+
outputRight: Float32Array,
|
|
190
|
+
outputLength: number,
|
|
191
|
+
outputIndex: number
|
|
192
|
+
): [
|
|
193
|
+
source: Float32Array[] | undefined,
|
|
194
|
+
sourceIndex: number,
|
|
195
|
+
outputIndex: number
|
|
196
|
+
] {
|
|
197
|
+
const sourceLeft = source[0]!;
|
|
198
|
+
const sourceRight = source[1]!;
|
|
199
|
+
const sourceLength = sourceLeft.length;
|
|
200
|
+
let sourceSampleIndex = sourceIndex | 0;
|
|
201
|
+
|
|
202
|
+
while (sourceSampleIndex < sourceLength) {
|
|
203
|
+
outputLeft[outputIndex] = sourceLeft[sourceSampleIndex]!;
|
|
204
|
+
outputRight[outputIndex] = sourceRight[sourceSampleIndex]!;
|
|
205
|
+
|
|
206
|
+
sourceIndex += sourceIndexStep;
|
|
207
|
+
sourceSampleIndex = sourceIndex | 0;
|
|
208
|
+
outputIndex += 1;
|
|
209
|
+
|
|
210
|
+
if (outputIndex === outputLength) {
|
|
211
|
+
return [
|
|
212
|
+
sourceSampleIndex < sourceLength
|
|
213
|
+
? source.map((channel) =>
|
|
214
|
+
channel.subarray(sourceSampleIndex)
|
|
215
|
+
)
|
|
216
|
+
: undefined,
|
|
217
|
+
sourceIndex,
|
|
218
|
+
outputIndex,
|
|
219
|
+
];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return [undefined, sourceIndex, outputIndex];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
registerProcessor("int16-source-processor", Int16SourceProcessor);
|
|
228
|
+
registerProcessor("float32-source-processor", Float32SourceProcessor);
|
|
229
|
+
registerProcessor(
|
|
230
|
+
"float32-planer-source-processor",
|
|
231
|
+
Float32PlanerSourceProcessor
|
|
232
|
+
);
|