@ain1084/audio-worklet-stream 1.0.0 → 1.0.2
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/README.md +15 -13
- package/dist/frame-buffer/buffer-reader.d.ts +1 -0
- package/dist/frame-buffer/buffer-reader.js +1 -0
- package/dist/frame-buffer/buffer-reader.js.map +1 -1
- package/dist/frame-buffer/buffer-writer.d.ts +1 -0
- package/dist/frame-buffer/buffer-writer.js +1 -0
- package/dist/frame-buffer/buffer-writer.js.map +1 -1
- package/package.json +1 -1
- package/src/frame-buffer/buffer-reader.ts +1 -0
- package/src/frame-buffer/buffer-writer.ts +1 -0
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ npm install @ain1084/audio-worklet-stream
|
|
|
60
60
|
<details>
|
|
61
61
|
<summary>Click to view configuration details</summary>
|
|
62
62
|
|
|
63
|
-
You need to add `@ain1084/audio-worklet-stream` to the optimizeDeps.exclude section in `vite.config.ts`. Furthermore, include the necessary
|
|
63
|
+
You need to add `@ain1084/audio-worklet-stream` to the optimizeDeps.exclude section in `vite.config.ts`. Furthermore, include the necessary **COOP (Cross-Origin Opener Policy)** and **COEP (Cross-Origin Embedder Policy)** settings to enable the use of `SharedArrayBuffer`.
|
|
64
64
|
|
|
65
65
|
### vite.config.ts
|
|
66
66
|
|
|
@@ -115,7 +115,6 @@ export default defineNuxtConfig({
|
|
|
115
115
|
},
|
|
116
116
|
routeRules: {
|
|
117
117
|
'/**': {
|
|
118
|
-
cors: true,
|
|
119
118
|
headers: {
|
|
120
119
|
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
121
120
|
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
@@ -237,22 +236,26 @@ The actual values may slightly differ from the above because they are rounded up
|
|
|
237
236
|
|
|
238
237
|
</details>
|
|
239
238
|
|
|
239
|
+
## API Documentation
|
|
240
|
+
|
|
241
|
+
You can find the full API documentation [here](https://ain1084.github.io/audio-worklet-stream/).
|
|
242
|
+
|
|
240
243
|
## Example
|
|
241
244
|
|
|
242
245
|
<details>
|
|
243
246
|
<summary>Click to view example details</summary>
|
|
244
247
|
|
|
245
|
-
The example can be found at [
|
|
248
|
+
The example can be found at [example](https://github.com/ain1084/audio-worklet-stream/tree/main/example).
|
|
246
249
|
|
|
247
250
|
The provided example demonstrates how to use the library to manually write audio frames to a buffer. It includes:
|
|
248
251
|
|
|
249
|
-
- **Main Application** (
|
|
250
|
-
- **Sine Wave Filler** (
|
|
251
|
-
- **Sine Wave Generator** (
|
|
252
|
-
- **Worker** (
|
|
253
|
-
- **HTML Entry Point** (
|
|
252
|
+
- **Main Application** ([example/src/main.ts](https://github.com/ain1084/audio-worklet-stream/blob/main/example/src/main.ts)): Sets up and starts the audio stream using different buffer writing strategies.
|
|
253
|
+
- **Sine Wave Filler** ([example/src/sine-wave-frame-buffer-filler.ts](https://github.com/ain1084/audio-worklet-stream/blob/main/example/src/sine-wave-frame-buffer-filler.ts)): Implements a frame buffer filler that generates a sine wave.
|
|
254
|
+
- **Sine Wave Generator** ([example/src/sine-wave-generator.ts](https://github.com/ain1084/audio-worklet-stream/blob/main/example/src/sine-wave-generator.ts)): Generates sine wave values for the buffer filler.
|
|
255
|
+
- **Worker** ([example/src/worker.ts](https://github.com/ain1084/audio-worklet-stream/blob/main/example/src/worker.ts)): Sets up a worker to handle buffer filling tasks.
|
|
256
|
+
- **HTML Entry Point** ([example/index.html](https://github.com/ain1084/audio-worklet-stream/blob/main/example/index.html)): Provides the HTML structure and buttons to control the audio stream.
|
|
254
257
|
|
|
255
|
-
For more details, refer to the [example/README.md](https://github.com/ain1084/audio-worklet-stream/
|
|
258
|
+
For more details, refer to the [example/README.md](https://github.com/ain1084/audio-worklet-stream/blob/main/example/README.md).
|
|
256
259
|
|
|
257
260
|
</details>
|
|
258
261
|
|
|
@@ -400,9 +403,9 @@ If you're experiencing frequent UnderrunEvents:
|
|
|
400
403
|
1. Ensure `@ain1084/audio-worklet-stream` is properly installed.
|
|
401
404
|
2. Check your bundler configuration, especially the `optimizeDeps.exclude` setting in Vite.
|
|
402
405
|
|
|
403
|
-
####
|
|
406
|
+
#### Browser Errors
|
|
404
407
|
|
|
405
|
-
1. Verify that you've set the correct
|
|
408
|
+
1. Verify that you've set the correct **COOP (Cross-Origin Opener Policy)** and **COEP (Cross-Origin Embedder Policy)** headers as described in the installation instructions.
|
|
406
409
|
2. If using a development server, ensure it's configured to send the required headers.
|
|
407
410
|
|
|
408
411
|
### Performance Issues
|
|
@@ -492,10 +495,9 @@ export default defineNuxtConfig({
|
|
|
492
495
|
rollupConfig: {
|
|
493
496
|
external: '@ain1084/audio-worklet-stream',
|
|
494
497
|
},
|
|
495
|
-
// Ensure
|
|
498
|
+
// Ensure COEP and COOP settings for SharedArrayBuffer
|
|
496
499
|
routeRules: {
|
|
497
500
|
'/**': {
|
|
498
|
-
cors: true,
|
|
499
501
|
headers: {
|
|
500
502
|
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
501
503
|
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
@@ -37,6 +37,7 @@ export declare class FrameBufferReader {
|
|
|
37
37
|
* 1. `buffer`: A Float32Array representing the readable segment of the buffer.
|
|
38
38
|
* 2. `offset`: The cumulative number of frames processed so far, used as the starting index
|
|
39
39
|
* for the current segment relative to the entire data.
|
|
40
|
+
*
|
|
40
41
|
* The callback must return the number of frames it successfully processed.
|
|
41
42
|
* If the callback processes fewer frames than available in the current segment,
|
|
42
43
|
* processing will stop early.
|
|
@@ -46,6 +46,7 @@ export class FrameBufferReader {
|
|
|
46
46
|
* 1. `buffer`: A Float32Array representing the readable segment of the buffer.
|
|
47
47
|
* 2. `offset`: The cumulative number of frames processed so far, used as the starting index
|
|
48
48
|
* for the current segment relative to the entire data.
|
|
49
|
+
*
|
|
49
50
|
* The callback must return the number of frames it successfully processed.
|
|
50
51
|
* If the callback processes fewer frames than available in the current segment,
|
|
51
52
|
* processing will stop early.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-reader.js","sourceRoot":"","sources":["../../src/frame-buffer/buffer-reader.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACX,YAAY,CAAa;IACzB,mBAAmB,CAAa;IAChC,YAAY,CAAgB;IACrC,MAAM,GAAW,CAAC,CAAA;IAE1B;;;;;OAKG;IACH,YAAY,WAAwB,EAAE,kBAA+B,EAAE,WAA2B;QAChG,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;QAC/B,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAC7C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;IACjC,CAAC;IAED;;;OAGG;IACH,IAAW,eAAe;QACxB,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAA;IAClD,CAAC;IAED;;;;OAIG;IACH,IAAW,WAAW;QACpB,2DAA2D;QAC3D,4DAA4D;QAC5D,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"buffer-reader.js","sourceRoot":"","sources":["../../src/frame-buffer/buffer-reader.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACX,YAAY,CAAa;IACzB,mBAAmB,CAAa;IAChC,YAAY,CAAgB;IACrC,MAAM,GAAW,CAAC,CAAA;IAE1B;;;;;OAKG;IACH,YAAY,WAAwB,EAAE,kBAA+B,EAAE,WAA2B;QAChG,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;QAC/B,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAC7C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;IACjC,CAAC;IAED;;;OAGG;IACH,IAAW,eAAe;QACxB,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAA;IAClD,CAAC;IAED;;;;OAIG;IACH,IAAW,WAAW;QACpB,2DAA2D;QAC3D,4DAA4D;QAC5D,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACI,IAAI,CAAC,mBAAqE;QAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAA;QAC1G,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAA;QAC9B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAA;QACrE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAA;QACtE,OAAO,MAAM,CAAC,oBAAoB,CAAA;IACpC,CAAC;CACF"}
|
|
@@ -38,6 +38,7 @@ export declare class FrameBufferWriter {
|
|
|
38
38
|
* 1. `buffer`: A Float32Array representing the writable segment of the buffer.
|
|
39
39
|
* 2. `offset`: The cumulative number of frames processed so far, used as the starting index
|
|
40
40
|
* for the current segment relative to the entire data.
|
|
41
|
+
*
|
|
41
42
|
* The callback must return the number of frames it successfully wrote.
|
|
42
43
|
* If the callback writes fewer frames than available in the current segment,
|
|
43
44
|
* processing will stop early.
|
|
@@ -47,6 +47,7 @@ export class FrameBufferWriter {
|
|
|
47
47
|
* 1. `buffer`: A Float32Array representing the writable segment of the buffer.
|
|
48
48
|
* 2. `offset`: The cumulative number of frames processed so far, used as the starting index
|
|
49
49
|
* for the current segment relative to the entire data.
|
|
50
|
+
*
|
|
50
51
|
* The callback must return the number of frames it successfully wrote.
|
|
51
52
|
* If the callback writes fewer frames than available in the current segment,
|
|
52
53
|
* processing will stop early.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-writer.js","sourceRoot":"","sources":["../../src/frame-buffer/buffer-writer.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACX,YAAY,CAAa;IACzB,mBAAmB,CAAa;IAChC,YAAY,CAAgB;IACrC,MAAM,GAAW,CAAC,CAAA;IAE1B;;;;;OAKG;IACH,YAAY,WAAwB,EAAE,kBAA+B,EAAE,WAA2B;QAChG,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;QAC/B,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAC7C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;IACjC,CAAC;IAED;;;;OAIG;IACH,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAA;IACjF,CAAC;IAED;;;;OAIG;IACH,IAAW,WAAW;QACpB,2DAA2D;QAC3D,4DAA4D;QAC5D,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"buffer-writer.js","sourceRoot":"","sources":["../../src/frame-buffer/buffer-writer.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACX,YAAY,CAAa;IACzB,mBAAmB,CAAa;IAChC,YAAY,CAAgB;IACrC,MAAM,GAAW,CAAC,CAAA;IAE1B;;;;;OAKG;IACH,YAAY,WAAwB,EAAE,kBAA+B,EAAE,WAA2B;QAChG,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;QAC/B,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAC7C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;IACjC,CAAC;IAED;;;;OAIG;IACH,IAAW,eAAe;QACxB,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAA;IACjF,CAAC;IAED;;;;OAIG;IACH,IAAW,WAAW;QACpB,2DAA2D;QAC3D,4DAA4D;QAC5D,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACI,KAAK,CAAC,mBAAqE;QAChF,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAA;QAC1G,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAA;QAC9B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAA;QACrE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAA;QACtE,OAAO,MAAM,CAAC,oBAAoB,CAAA;IACpC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -52,6 +52,7 @@ export class FrameBufferReader {
|
|
|
52
52
|
* 1. `buffer`: A Float32Array representing the readable segment of the buffer.
|
|
53
53
|
* 2. `offset`: The cumulative number of frames processed so far, used as the starting index
|
|
54
54
|
* for the current segment relative to the entire data.
|
|
55
|
+
*
|
|
55
56
|
* The callback must return the number of frames it successfully processed.
|
|
56
57
|
* If the callback processes fewer frames than available in the current segment,
|
|
57
58
|
* processing will stop early.
|
|
@@ -53,6 +53,7 @@ export class FrameBufferWriter {
|
|
|
53
53
|
* 1. `buffer`: A Float32Array representing the writable segment of the buffer.
|
|
54
54
|
* 2. `offset`: The cumulative number of frames processed so far, used as the starting index
|
|
55
55
|
* for the current segment relative to the entire data.
|
|
56
|
+
*
|
|
56
57
|
* The callback must return the number of frames it successfully wrote.
|
|
57
58
|
* If the callback writes fewer frames than available in the current segment,
|
|
58
59
|
* processing will stop early.
|