playout-audio-worklet 1.0.0

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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/build/es2019/interfaces/index.d.ts +2 -0
  4. package/build/es2019/interfaces/index.d.ts.map +1 -0
  5. package/build/es2019/interfaces/index.js +2 -0
  6. package/build/es2019/interfaces/index.js.map +1 -0
  7. package/build/es2019/interfaces/playout-audio-worklet-node.d.ts +4 -0
  8. package/build/es2019/interfaces/playout-audio-worklet-node.d.ts.map +1 -0
  9. package/build/es2019/interfaces/playout-audio-worklet-node.js +2 -0
  10. package/build/es2019/interfaces/playout-audio-worklet-node.js.map +1 -0
  11. package/build/es2019/module.d.ts +8 -0
  12. package/build/es2019/module.d.ts.map +1 -0
  13. package/build/es2019/module.js +49 -0
  14. package/build/es2019/module.js.map +1 -0
  15. package/build/es2019/types/any-playout-audio-worklet-node-options.d.ts +5 -0
  16. package/build/es2019/types/any-playout-audio-worklet-node-options.d.ts.map +1 -0
  17. package/build/es2019/types/any-playout-audio-worklet-node-options.js +2 -0
  18. package/build/es2019/types/any-playout-audio-worklet-node-options.js.map +1 -0
  19. package/build/es2019/types/fixed-options.d.ts +2 -0
  20. package/build/es2019/types/fixed-options.d.ts.map +1 -0
  21. package/build/es2019/types/fixed-options.js +2 -0
  22. package/build/es2019/types/fixed-options.js.map +1 -0
  23. package/build/es2019/types/index.d.ts +5 -0
  24. package/build/es2019/types/index.d.ts.map +1 -0
  25. package/build/es2019/types/index.js +5 -0
  26. package/build/es2019/types/index.js.map +1 -0
  27. package/build/es2019/types/native-playout-audio-worklet-node-options.d.ts +11 -0
  28. package/build/es2019/types/native-playout-audio-worklet-node-options.d.ts.map +1 -0
  29. package/build/es2019/types/native-playout-audio-worklet-node-options.js +2 -0
  30. package/build/es2019/types/native-playout-audio-worklet-node-options.js.map +1 -0
  31. package/build/es2019/types/native-playout-audio-worklet-node.d.ts +3 -0
  32. package/build/es2019/types/native-playout-audio-worklet-node.d.ts.map +1 -0
  33. package/build/es2019/types/native-playout-audio-worklet-node.js +2 -0
  34. package/build/es2019/types/native-playout-audio-worklet-node.js.map +1 -0
  35. package/build/es2019/types/playout-audio-worklet-node-options.d.ts +11 -0
  36. package/build/es2019/types/playout-audio-worklet-node-options.d.ts.map +1 -0
  37. package/build/es2019/types/playout-audio-worklet-node-options.js +2 -0
  38. package/build/es2019/types/playout-audio-worklet-node-options.js.map +1 -0
  39. package/build/es2019/worklet/worklet.d.ts +2 -0
  40. package/build/es2019/worklet/worklet.d.ts.map +1 -0
  41. package/build/es2019/worklet/worklet.js +3 -0
  42. package/build/es2019/worklet/worklet.js.map +1 -0
  43. package/build/es5/bundle.js +79 -0
  44. package/package.json +79 -0
  45. package/src/interfaces/index.ts +1 -0
  46. package/src/interfaces/playout-audio-worklet-node.ts +3 -0
  47. package/src/module.ts +72 -0
  48. package/src/tsconfig.json +6 -0
  49. package/src/types/any-playout-audio-worklet-node-options.ts +7 -0
  50. package/src/types/fixed-options.ts +1 -0
  51. package/src/types/index.ts +4 -0
  52. package/src/types/native-playout-audio-worklet-node-options.ts +16 -0
  53. package/src/types/native-playout-audio-worklet-node.ts +3 -0
  54. package/src/types/playout-audio-worklet-node-options.ts +16 -0
  55. package/src/worklet/worklet.ts +2 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Christoph Guttandin
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,5 @@
1
+ # playout-audio-worklet
2
+
3
+ **This module provides a loader for the PlayoutAudioWorkletProcessor and the corresponding PlayoutAudioWorkletNode.**
4
+
5
+ [![version](https://img.shields.io/npm/v/playout-audio-worklet.svg?style=flat-square)](https://www.npmjs.com/package/playout-audio-worklet)
@@ -0,0 +1,2 @@
1
+ export * from './playout-audio-worklet-node';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './playout-audio-worklet-node';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { IAudioWorkletNode, TContext } from 'standardized-audio-context';
2
+ export interface IPlayoutAudioWorkletNode<T extends TContext> extends IAudioWorkletNode<T> {
3
+ }
4
+ //# sourceMappingURL=playout-audio-worklet-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playout-audio-worklet-node.d.ts","sourceRoot":"","sources":["../../../src/interfaces/playout-audio-worklet-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEzE,MAAM,WAAW,wBAAwB,CAAC,CAAC,SAAS,QAAQ,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;CAAG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=playout-audio-worklet-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playout-audio-worklet-node.js","sourceRoot":"","sources":["../../../src/interfaces/playout-audio-worklet-node.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { TAudioWorkletNodeConstructor, TContext, TNativeAudioWorkletNodeConstructor, TNativeContext } from 'standardized-audio-context';
2
+ import { IPlayoutAudioWorkletNode } from './interfaces';
3
+ import { TAnyPlayoutAudioWorkletNodeOptions, TNativePlayoutAudioWorkletNode } from './types';
4
+ export * from './interfaces/index';
5
+ export * from './types/index';
6
+ export declare const addPlayoutAudioWorkletModule: (addAudioWorkletModule: (url: string) => Promise<void>) => Promise<void>;
7
+ export declare function createPlayoutAudioWorkletNode<T extends TContext | TNativeContext>(audioWorkletNodeConstructor: T extends TContext ? TAudioWorkletNodeConstructor : TNativeAudioWorkletNodeConstructor, context: T, options?: Partial<TAnyPlayoutAudioWorkletNodeOptions<T>>): T extends TContext ? IPlayoutAudioWorkletNode<T> : TNativePlayoutAudioWorkletNode;
8
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,4BAA4B,EAC5B,QAAQ,EAER,kCAAkC,EAClC,cAAc,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,kCAAkC,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAO7F,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAI9B,eAAO,MAAM,4BAA4B,GAAU,uBAAuB,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,kBAQvG,CAAC;AAEF,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,QAAQ,GAAG,cAAc,EAC7E,2BAA2B,EAAE,CAAC,SAAS,QAAQ,GAAG,4BAA4B,GAAG,kCAAkC,EACnH,OAAO,EAAE,CAAC,EACV,OAAO,GAAE,OAAO,CAAC,kCAAkC,CAAC,CAAC,CAAC,CAAM,GAC7D,CAAC,SAAS,QAAQ,GAAG,wBAAwB,CAAC,CAAC,CAAC,GAAG,8BAA8B,CAoCnF"}
@@ -0,0 +1,49 @@
1
+ import { worklet } from './worklet/worklet';
2
+ /*
3
+ * @todo Explicitly referencing the barrel file seems to be necessary when enabling the
4
+ * isolatedModules compiler option.
5
+ */
6
+ export * from './interfaces/index';
7
+ export * from './types/index';
8
+ const blob = new Blob([worklet], { type: 'application/javascript; charset=utf-8' });
9
+ export const addPlayoutAudioWorkletModule = async (addAudioWorkletModule) => {
10
+ const url = URL.createObjectURL(blob);
11
+ try {
12
+ await addAudioWorkletModule(url);
13
+ }
14
+ finally {
15
+ URL.revokeObjectURL(url);
16
+ }
17
+ };
18
+ export function createPlayoutAudioWorkletNode(audioWorkletNodeConstructor, context, options = {}) {
19
+ const { numberOfChannels, readPointerView, startView, stopView, storageView, writePointerView } = options;
20
+ const audioWorkletNode = new audioWorkletNodeConstructor(context, 'playout-audio-worklet-processor', {
21
+ ...options,
22
+ numberOfInputs: 0,
23
+ numberOfOutputs: 1,
24
+ outputChannelCount: [numberOfChannels],
25
+ pocessorOptions: {
26
+ readPointerView,
27
+ startView,
28
+ stopView,
29
+ storageView,
30
+ writePointerView
31
+ }
32
+ });
33
+ const listener = () => {
34
+ audioWorkletNode.port.removeEventListener('message', listener);
35
+ audioWorkletNode.port.close();
36
+ audioWorkletNode.dispatchEvent(new Event('ended'));
37
+ };
38
+ audioWorkletNode.port.addEventListener('message', listener);
39
+ audioWorkletNode.port.start();
40
+ Object.defineProperties(audioWorkletNode, {
41
+ port: {
42
+ get() {
43
+ throw new Error("The port of a PlayoutAudioWorkletNode can't be accessed.");
44
+ }
45
+ }
46
+ });
47
+ return audioWorkletNode;
48
+ }
49
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;GAGG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAE9B,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,uCAAuC,EAAE,CAAC,CAAC;AAEpF,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,EAAE,qBAAqD,EAAE,EAAE;IACxG,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAEtC,IAAI,CAAC;QACD,MAAM,qBAAqB,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;YAAS,CAAC;QACP,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,UAAU,6BAA6B,CACzC,2BAAmH,EACnH,OAAU,EACV,UAA0D,EAAE;IAK5D,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAC1G,MAAM,gBAAgB,GAAyB,IAAU,2BAA4B,CAAC,OAAO,EAAE,iCAAiC,EAAE;QAC9H,GAAG,OAAO;QACV,cAAc,EAAE,CAAC;QACjB,eAAe,EAAE,CAAC;QAClB,kBAAkB,EAAE,CAAC,gBAAgB,CAAC;QACtC,eAAe,EAAE;YACb,eAAe;YACf,SAAS;YACT,QAAQ;YACR,WAAW;YACX,gBAAgB;SACnB;KACJ,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,GAAG,EAAE;QAClB,gBAAgB,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC/D,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9B,gBAAgB,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC;IAEF,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC5D,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAE9B,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,EAAE;QACtC,IAAI,EAAE;YACF,GAAG;gBACC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;YAChF,CAAC;SACJ;KACJ,CAAC,CAAC;IAEH,OAAoC,gBAAgB,CAAC;AACzD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { TAnyContext, TContext } from 'standardized-audio-context';
2
+ import { TNativePlayoutAudioWorkletNodeOptions } from './native-playout-audio-worklet-node-options';
3
+ import { TPlayoutAudioWorkletNodeOptions } from './playout-audio-worklet-node-options';
4
+ export type TAnyPlayoutAudioWorkletNodeOptions<T extends TAnyContext> = T extends TContext ? TPlayoutAudioWorkletNodeOptions : TNativePlayoutAudioWorkletNodeOptions;
5
+ //# sourceMappingURL=any-playout-audio-worklet-node-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any-playout-audio-worklet-node-options.d.ts","sourceRoot":"","sources":["../../../src/types/any-playout-audio-worklet-node-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,qCAAqC,EAAE,MAAM,6CAA6C,CAAC;AACpG,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAEvF,MAAM,MAAM,kCAAkC,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,QAAQ,GACpF,+BAA+B,GAC/B,qCAAqC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=any-playout-audio-worklet-node-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any-playout-audio-worklet-node-options.js","sourceRoot":"","sources":["../../../src/types/any-playout-audio-worklet-node-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type TFixedOptions = 'numberOfInputs' | 'numberOfOutputs';
2
+ //# sourceMappingURL=fixed-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-options.d.ts","sourceRoot":"","sources":["../../../src/types/fixed-options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fixed-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-options.js","sourceRoot":"","sources":["../../../src/types/fixed-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export * from './any-playout-audio-worklet-node-options';
2
+ export * from './native-playout-audio-worklet-node';
3
+ export * from './native-playout-audio-worklet-node-options';
4
+ export * from './playout-audio-worklet-node-options';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAC;AACzD,cAAc,qCAAqC,CAAC;AACpD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,sCAAsC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './any-playout-audio-worklet-node-options';
2
+ export * from './native-playout-audio-worklet-node';
3
+ export * from './native-playout-audio-worklet-node-options';
4
+ export * from './playout-audio-worklet-node-options';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAC;AACzD,cAAc,qCAAqC,CAAC;AACpD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,sCAAsC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { TNativeAudioWorkletNodeOptions } from 'standardized-audio-context';
2
+ import { TFixedOptions } from './fixed-options';
3
+ export type TNativePlayoutAudioWorkletNodeOptions = Omit<TNativeAudioWorkletNodeOptions, TFixedOptions> & {
4
+ numberOfChannels: number;
5
+ readPointerView: Uint8Array | Uint16Array | Uint32Array;
6
+ startView: Uint8Array;
7
+ stopView: Uint8Array;
8
+ storageView: Float32Array;
9
+ writePointerView: Uint8Array | Uint16Array | Uint32Array;
10
+ };
11
+ //# sourceMappingURL=native-playout-audio-worklet-node-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-playout-audio-worklet-node-options.d.ts","sourceRoot":"","sources":["../../../src/types/native-playout-audio-worklet-node-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,qCAAqC,GAAG,IAAI,CAAC,8BAA8B,EAAE,aAAa,CAAC,GAAG;IACtG,gBAAgB,EAAE,MAAM,CAAC;IAEzB,eAAe,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;IAExD,SAAS,EAAE,UAAU,CAAC;IAEtB,QAAQ,EAAE,UAAU,CAAC;IAErB,WAAW,EAAE,YAAY,CAAC;IAE1B,gBAAgB,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;CAC5D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=native-playout-audio-worklet-node-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-playout-audio-worklet-node-options.js","sourceRoot":"","sources":["../../../src/types/native-playout-audio-worklet-node-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { TNativeAudioWorkletNode } from 'standardized-audio-context';
2
+ export type TNativePlayoutAudioWorkletNode = TNativeAudioWorkletNode;
3
+ //# sourceMappingURL=native-playout-audio-worklet-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-playout-audio-worklet-node.d.ts","sourceRoot":"","sources":["../../../src/types/native-playout-audio-worklet-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE,MAAM,MAAM,8BAA8B,GAAG,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=native-playout-audio-worklet-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-playout-audio-worklet-node.js","sourceRoot":"","sources":["../../../src/types/native-playout-audio-worklet-node.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { IAudioWorkletNodeOptions } from 'standardized-audio-context';
2
+ import { TFixedOptions } from './fixed-options';
3
+ export type TPlayoutAudioWorkletNodeOptions = Omit<IAudioWorkletNodeOptions, TFixedOptions> & {
4
+ numberOfChannels: number;
5
+ readPointerView: Uint8Array | Uint16Array | Uint32Array;
6
+ startView: Uint8Array;
7
+ stopView: Uint8Array;
8
+ storageView: Float32Array;
9
+ writePointerView: Uint8Array | Uint16Array | Uint32Array;
10
+ };
11
+ //# sourceMappingURL=playout-audio-worklet-node-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playout-audio-worklet-node-options.d.ts","sourceRoot":"","sources":["../../../src/types/playout-audio-worklet-node-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,+BAA+B,GAAG,IAAI,CAAC,wBAAwB,EAAE,aAAa,CAAC,GAAG;IAC1F,gBAAgB,EAAE,MAAM,CAAC;IAEzB,eAAe,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;IAExD,SAAS,EAAE,UAAU,CAAC;IAEtB,QAAQ,EAAE,UAAU,CAAC;IAErB,WAAW,EAAE,YAAY,CAAC;IAE1B,gBAAgB,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;CAC5D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=playout-audio-worklet-node-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playout-audio-worklet-node-options.js","sourceRoot":"","sources":["../../../src/types/playout-audio-worklet-node-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const worklet = "(()=>{\"use strict\";const e=128;class t extends AudioWorkletProcessor{constructor({numberOfInputs:t,numberOfOutputs:r,outputChannelCount:n,processorOptions:o}){if(0!==t)throw new Error(\"The numberOfInputs must be 0.\");if(1!==r)throw new Error(\"The numberOfOutputs must be 1.\");if(void 0===n||1!==n.length)throw new Error(\"The outputChannelCount must define a single output.\");const[i]=n;if(\"object\"!=typeof o||null===o)throw new Error;const s=\"readPointerView\"in o?o.readPointerView:null;if(!(s instanceof Uint8Array||s instanceof Uint16Array||s instanceof Uint32Array))throw new Error('The readPointerView needs to be an instance of \"Uint8Array\", \"Uint16Array\", or \"Uint32Array\".');if(1!==s.length)throw new Error(\"The readPointerView needs to have a length of 1.\");const a=\"startView\"in o?o.startView:null;if(!(a instanceof Uint16Array))throw new Error('The startView needs to be an instance of \"Uint16Array\".');if(1!==a.length)throw new Error(\"The startView needs to have a length of 1.\");const h=\"stopView\"in o?o.stopView:null;if(!(h instanceof Uint16Array))throw new Error('The stopView needs to be an instance of \"Uint16Array\".');if(1!==h.length)throw new Error(\"The stopView needs to have a length of 1.\");const w=\"storageView\"in o?o.storageView:null;if(!(w instanceof Float32Array))throw new Error('The storageView needs to be an instance of \"Float32Array\".');const f=w.length/i;if(!Number.isInteger(f))throw new Error(\"The storageView needs to have a length which is a multiple of the number of channels.\");const l=f/e;if(!Number.isInteger(l))throw new Error(\"The capacity can only be a multiple of the render quantum size.\");const u=\"writePointerView\"in o?o.writePointerView:null;if(!(u instanceof Uint8Array||u instanceof Uint16Array||u instanceof Uint32Array))throw new Error('The writePointerView needs to be an instance of \"Uint8Array\", \"Uint16Array\", or \"Uint32Array\".');if(1!==u.length)throw new Error(\"The writePointerView needs to have a length of 1.\");if(s.byteLength!==u.byteLength)throw new Error(\"The pointer need to be of the same size.\");if(f>=2**(8*s.byteLength-1))throw new Error(\"The capacity exceeds the pointer range.\");super(),this._isStarted=!1,this._numberOfChannels=i,this._numberOfSlots=l,this._readPointerView=s,this._slots=Array.from({length:l},(t,r)=>{const n=r*e;return Array.from({length:i},(t,r)=>{const o=n+r*l*e;return w.subarray(o,o+e)})}),this._startView=a,this._stopView=h,this._writePointerView=u}process(e,[t]){if(!this._isStarted){if(!this._readStart())return!0;this._isStarted=!0}const r=!(!this._readStorage(t)&&this._readStop());return r||(this.port.postMessage(null),this.port.close()),r}_readStart(){return 1===Atomics.load(this._startView,0)}_readStop(){return 1===Atomics.load(this._stopView,0)}_readStorage(t){const r=Atomics.load(this._readPointerView,0)/e;if(Math.floor((524287&Atomics.load(this._writePointerView,0))/e)===r)return!1;const n=this._slots[r%this._numberOfSlots];for(let e=0;e<this._numberOfChannels;e+=1)t[e].set(n[e]);return Atomics.store(this._readPointerView,0,(r+1)%(2*this._numberOfSlots)*e),!0}}t.parameterDescriptors=[],registerProcessor(\"playout-audio-worklet-processor\",t)})();";
2
+ //# sourceMappingURL=worklet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worklet.d.ts","sourceRoot":"","sources":["../../../src/worklet/worklet.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,mpGAA2lG,CAAC"}
@@ -0,0 +1,3 @@
1
+ // This is the minified and stringified code of the playout-audio-worklet-processor package.
2
+ export const worklet = `(()=>{"use strict";const e=128;class t extends AudioWorkletProcessor{constructor({numberOfInputs:t,numberOfOutputs:r,outputChannelCount:n,processorOptions:o}){if(0!==t)throw new Error("The numberOfInputs must be 0.");if(1!==r)throw new Error("The numberOfOutputs must be 1.");if(void 0===n||1!==n.length)throw new Error("The outputChannelCount must define a single output.");const[i]=n;if("object"!=typeof o||null===o)throw new Error;const s="readPointerView"in o?o.readPointerView:null;if(!(s instanceof Uint8Array||s instanceof Uint16Array||s instanceof Uint32Array))throw new Error('The readPointerView needs to be an instance of "Uint8Array", "Uint16Array", or "Uint32Array".');if(1!==s.length)throw new Error("The readPointerView needs to have a length of 1.");const a="startView"in o?o.startView:null;if(!(a instanceof Uint16Array))throw new Error('The startView needs to be an instance of "Uint16Array".');if(1!==a.length)throw new Error("The startView needs to have a length of 1.");const h="stopView"in o?o.stopView:null;if(!(h instanceof Uint16Array))throw new Error('The stopView needs to be an instance of "Uint16Array".');if(1!==h.length)throw new Error("The stopView needs to have a length of 1.");const w="storageView"in o?o.storageView:null;if(!(w instanceof Float32Array))throw new Error('The storageView needs to be an instance of "Float32Array".');const f=w.length/i;if(!Number.isInteger(f))throw new Error("The storageView needs to have a length which is a multiple of the number of channels.");const l=f/e;if(!Number.isInteger(l))throw new Error("The capacity can only be a multiple of the render quantum size.");const u="writePointerView"in o?o.writePointerView:null;if(!(u instanceof Uint8Array||u instanceof Uint16Array||u instanceof Uint32Array))throw new Error('The writePointerView needs to be an instance of "Uint8Array", "Uint16Array", or "Uint32Array".');if(1!==u.length)throw new Error("The writePointerView needs to have a length of 1.");if(s.byteLength!==u.byteLength)throw new Error("The pointer need to be of the same size.");if(f>=2**(8*s.byteLength-1))throw new Error("The capacity exceeds the pointer range.");super(),this._isStarted=!1,this._numberOfChannels=i,this._numberOfSlots=l,this._readPointerView=s,this._slots=Array.from({length:l},(t,r)=>{const n=r*e;return Array.from({length:i},(t,r)=>{const o=n+r*l*e;return w.subarray(o,o+e)})}),this._startView=a,this._stopView=h,this._writePointerView=u}process(e,[t]){if(!this._isStarted){if(!this._readStart())return!0;this._isStarted=!0}const r=!(!this._readStorage(t)&&this._readStop());return r||(this.port.postMessage(null),this.port.close()),r}_readStart(){return 1===Atomics.load(this._startView,0)}_readStop(){return 1===Atomics.load(this._stopView,0)}_readStorage(t){const r=Atomics.load(this._readPointerView,0)/e;if(Math.floor((524287&Atomics.load(this._writePointerView,0))/e)===r)return!1;const n=this._slots[r%this._numberOfSlots];for(let e=0;e<this._numberOfChannels;e+=1)t[e].set(n[e]);return Atomics.store(this._readPointerView,0,(r+1)%(2*this._numberOfSlots)*e),!0}}t.parameterDescriptors=[],registerProcessor("playout-audio-worklet-processor",t)})();`; // tslint:disable-line:max-line-length
3
+ //# sourceMappingURL=worklet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worklet.js","sourceRoot":"","sources":["../../../src/worklet/worklet.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,MAAM,CAAC,MAAM,OAAO,GAAG,wlGAAwlG,CAAC,CAAC,sCAAsC"}
@@ -0,0 +1,79 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/defineProperty'), require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/regenerator')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/defineProperty', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/regenerator'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.playoutAudioWorklet = {}, global._defineProperty, global._asyncToGenerator, global._regeneratorRuntime));
5
+ })(this, (function (exports, _defineProperty, _asyncToGenerator, _regeneratorRuntime) { 'use strict';
6
+
7
+ // This is the minified and stringified code of the playout-audio-worklet-processor package.
8
+ var worklet = "(()=>{var e={45(e,t,r){var o=r(738).default;e.exports=function(e,t){if(\"object\"!=o(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||\"default\");if(\"object\"!=o(n))return n;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},72(e){function t(r){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},79(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o},e.exports.__esModule=!0,e.exports.default=e.exports},122(e,t,r){var o=r(79);e.exports=function(e,t){if(e){if(\"string\"==typeof e)return o(e,t);var r={}.toString.call(e).slice(8,-1);return\"Object\"===r&&e.constructor&&(r=e.constructor.name),\"Map\"===r||\"Set\"===r?Array.from(e):\"Arguments\"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},156(e){e.exports=function(e,t){var r=null==e?null:\"undefined\"!=typeof Symbol&&e[Symbol.iterator]||e[\"@@iterator\"];if(null!=r){var o,n,s,i,a=[],u=!0,l=!1;try{if(s=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(o=s.call(r)).done)&&(a.push(o.value),a.length!==t);u=!0);}catch(e){l=!0,n=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw n}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports},383(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError(\"Cannot call a class as a function\")},e.exports.__esModule=!0,e.exports.default=e.exports},452(e,t,r){var o=r(738).default,n=r(475);e.exports=function(e,t){if(t&&(\"object\"==o(t)||\"function\"==typeof t))return t;if(void 0!==t)throw new TypeError(\"Derived constructors may only return object or undefined\");return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475(e){e.exports=function(e){if(void 0===e)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return e},e.exports.__esModule=!0,e.exports.default=e.exports},511(e,t,r){var o=r(636);e.exports=function(e,t){if(\"function\"!=typeof t&&null!==t)throw new TypeError(\"Super expression must either be null or a function\");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,\"prototype\",{writable:!1}),t&&o(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},550(e){function t(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(r){}return(e.exports=t=function(){return!!r},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},579(e,t,r){var o=r(736);function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,\"value\"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,\"prototype\",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},636(e){function t(r,o){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,o)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},646(e,t,r){var o=r(550),n=r(636);e.exports=function(e,t,r){if(o())return Reflect.construct.apply(null,arguments);var s=[null];s.push.apply(s,t);var i=new(e.bind.apply(e,s));return r&&n(i,r.prototype),i},e.exports.__esModule=!0,e.exports.default=e.exports},691(e){e.exports=function(e){try{return-1!==Function.toString.call(e).indexOf(\"[native code]\")}catch(t){return\"function\"==typeof e}},e.exports.__esModule=!0,e.exports.default=e.exports},715(e,t,r){var o=r(987),n=r(156),s=r(122),i=r(752);e.exports=function(e,t){return o(e)||n(e,t)||s(e,t)||i()},e.exports.__esModule=!0,e.exports.default=e.exports},736(e,t,r){var o=r(738).default,n=r(45);e.exports=function(e){var t=n(e,\"string\");return\"symbol\"==o(t)?t:t+\"\"},e.exports.__esModule=!0,e.exports.default=e.exports},738(e){function t(r){return e.exports=t=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&\"function\"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?\"symbol\":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},752(e){e.exports=function(){throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")},e.exports.__esModule=!0,e.exports.default=e.exports},763(e,t,r){!function(e,t,r,o,n,s,i,a){\"use strict\";function u(e,t,r){return t=s(t),n(e,l()?Reflect.construct(t,[],s(e).constructor):t.apply(e,r))}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var p=128,f=524287,c=function(n){function s(o){var n,i=o.numberOfInputs,a=o.numberOfOutputs,l=o.outputChannelCount,f=o.processorOptions;if(r(this,s),0!==i)throw new Error(\"The numberOfInputs must be 0.\");if(1!==a)throw new Error(\"The numberOfOutputs must be 1.\");if(void 0===l||1!==l.length)throw new Error(\"The outputChannelCount must define a single output.\");var c=t(l,1)[0];if(\"object\"!==e(f)||null===f)throw new Error;var d=\"readPointerView\"in f?f.readPointerView:null;if(!(d instanceof Uint8Array||d instanceof Uint16Array||d instanceof Uint32Array))throw new Error('The readPointerView needs to be an instance of \"Uint8Array\", \"Uint16Array\", or \"Uint32Array\".');if(1!==d.length)throw new Error(\"The readPointerView needs to have a length of 1.\");var h=\"startView\"in f?f.startView:null;if(!(h instanceof Uint16Array))throw new Error('The startView needs to be an instance of \"Uint16Array\".');if(1!==h.length)throw new Error(\"The startView needs to have a length of 1.\");var x=\"stopView\"in f?f.stopView:null;if(!(x instanceof Uint16Array))throw new Error('The stopView needs to be an instance of \"Uint16Array\".');if(1!==x.length)throw new Error(\"The stopView needs to have a length of 1.\");var y=\"storageView\"in f?f.storageView:null;if(!(y instanceof Float32Array))throw new Error('The storageView needs to be an instance of \"Float32Array\".');var w=y.length/c;if(!Number.isInteger(w))throw new Error(\"The storageView needs to have a length which is a multiple of the number of channels.\");var _=w/p;if(!Number.isInteger(_))throw new Error(\"The capacity can only be a multiple of the render quantum size.\");var b=\"writePointerView\"in f?f.writePointerView:null;if(!(b instanceof Uint8Array||b instanceof Uint16Array||b instanceof Uint32Array))throw new Error('The writePointerView needs to be an instance of \"Uint8Array\", \"Uint16Array\", or \"Uint32Array\".');if(1!==b.length)throw new Error(\"The writePointerView needs to have a length of 1.\");if(d.byteLength!==b.byteLength)throw new Error(\"The pointer need to be of the same size.\");if(w>=Math.pow(2,8*d.byteLength-1))throw new Error(\"The capacity exceeds the pointer range.\");return(n=u(this,s))._isStarted=!1,n._numberOfChannels=c,n._numberOfSlots=_,n._readPointerView=d,n._slots=Array.from({length:_},function(e,t){var r=t*p;return Array.from({length:c},function(e,t){var o=r+t*_*p;return y.subarray(o,o+p)})}),n._startView=h,n._stopView=x,n._writePointerView=b,n}return i(s,n),o(s,[{key:\"process\",value:function(e,r){var o=t(r,1)[0];if(!this._isStarted){if(!this._readStart())return!0;this._isStarted=!0}var n=!(!this._readStorage(o)&&this._readStop());return n||(this.port.postMessage(null),this.port.close()),n}},{key:\"_readStart\",value:function(){return 1===Atomics.load(this._startView,0)}},{key:\"_readStop\",value:function(){return 1===Atomics.load(this._stopView,0)}},{key:\"_readStorage\",value:function(e){var t=Atomics.load(this._readPointerView,0)/p;if(Math.floor((Atomics.load(this._writePointerView,0)&f)/p)===t)return!1;for(var r=this._slots[t%this._numberOfSlots],o=0;o<this._numberOfChannels;o+=1)e[o].set(r[o]);return Atomics.store(this._readPointerView,0,(t+1)%(2*this._numberOfSlots)*p),!0}}])}(a(AudioWorkletProcessor));c.parameterDescriptors=[],registerProcessor(\"playout-audio-worklet-processor\",c)}(r(738),r(715),r(383),r(579),r(452),r(72),r(511),r(837))},837(e,t,r){var o=r(72),n=r(636),s=r(691),i=r(646);function a(t){var r=\"function\"==typeof Map?new Map:void 0;return e.exports=a=function(e){if(null===e||!s(e))return e;if(\"function\"!=typeof e)throw new TypeError(\"Super expression must either be null or a function\");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return i(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n(t,e)},e.exports.__esModule=!0,e.exports.default=e.exports,a(t)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports},987(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o].call(s.exports,s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{\"use strict\";r(763)})()})();"; // tslint:disable-line:max-line-length
9
+
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ var blob = new Blob([worklet], {
13
+ type: 'application/javascript; charset=utf-8'
14
+ });
15
+ var addPlayoutAudioWorkletModule = /*#__PURE__*/function () {
16
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(addAudioWorkletModule) {
17
+ var url;
18
+ return _regeneratorRuntime.wrap(function (_context) {
19
+ while (1) switch (_context.prev = _context.next) {
20
+ case 0:
21
+ url = URL.createObjectURL(blob);
22
+ _context.prev = 1;
23
+ _context.next = 2;
24
+ return addAudioWorkletModule(url);
25
+ case 2:
26
+ _context.prev = 2;
27
+ URL.revokeObjectURL(url);
28
+ return _context.finish(2);
29
+ case 3:
30
+ case "end":
31
+ return _context.stop();
32
+ }
33
+ }, _callee, null, [[1,, 2, 3]]);
34
+ }));
35
+ return function addPlayoutAudioWorkletModule(_x) {
36
+ return _ref.apply(this, arguments);
37
+ };
38
+ }();
39
+ function createPlayoutAudioWorkletNode(audioWorkletNodeConstructor, context) {
40
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
41
+ var numberOfChannels = options.numberOfChannels,
42
+ readPointerView = options.readPointerView,
43
+ startView = options.startView,
44
+ stopView = options.stopView,
45
+ storageView = options.storageView,
46
+ writePointerView = options.writePointerView;
47
+ var audioWorkletNode = new audioWorkletNodeConstructor(context, 'playout-audio-worklet-processor', _objectSpread(_objectSpread({}, options), {}, {
48
+ numberOfInputs: 0,
49
+ numberOfOutputs: 1,
50
+ outputChannelCount: [numberOfChannels],
51
+ pocessorOptions: {
52
+ readPointerView: readPointerView,
53
+ startView: startView,
54
+ stopView: stopView,
55
+ storageView: storageView,
56
+ writePointerView: writePointerView
57
+ }
58
+ }));
59
+ var _listener = function listener() {
60
+ audioWorkletNode.port.removeEventListener('message', _listener);
61
+ audioWorkletNode.port.close();
62
+ audioWorkletNode.dispatchEvent(new Event('ended'));
63
+ };
64
+ audioWorkletNode.port.addEventListener('message', _listener);
65
+ audioWorkletNode.port.start();
66
+ Object.defineProperties(audioWorkletNode, {
67
+ port: {
68
+ get: function get() {
69
+ throw new Error("The port of a PlayoutAudioWorkletNode can't be accessed.");
70
+ }
71
+ }
72
+ });
73
+ return audioWorkletNode;
74
+ }
75
+
76
+ exports.addPlayoutAudioWorkletModule = addPlayoutAudioWorkletModule;
77
+ exports.createPlayoutAudioWorkletNode = createPlayoutAudioWorkletNode;
78
+
79
+ }));
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "author": "Christoph Guttandin",
3
+ "bugs": {
4
+ "url": "https://github.com/chrisguttandin/playout-audio-worklet/issues"
5
+ },
6
+ "config": {
7
+ "commitizen": {
8
+ "path": "cz-conventional-changelog"
9
+ }
10
+ },
11
+ "dependencies": {
12
+ "@babel/runtime": "^7.28.4",
13
+ "playout-audio-worklet-processor": "^1.0.0",
14
+ "standardized-audio-context": "^25.3.77",
15
+ "tslib": "^2.8.1"
16
+ },
17
+ "description": "This module provides a loader for the PlayoutAudioWorkletProcessor and the corresponding PlayoutAudioWorkletNode.",
18
+ "devDependencies": {
19
+ "@babel/core": "^7.28.5",
20
+ "@babel/plugin-external-helpers": "^7.27.1",
21
+ "@babel/plugin-transform-runtime": "^7.28.5",
22
+ "@babel/preset-env": "^7.28.5",
23
+ "@commitlint/cli": "^19.8.1",
24
+ "@commitlint/config-angular": "^19.8.1",
25
+ "@rollup/plugin-babel": "^6.1.0",
26
+ "@rollup/plugin-replace": "^6.0.3",
27
+ "@vitest/browser-webdriverio": "^4.0.16",
28
+ "babel-loader": "^10.0.0",
29
+ "chai": "^6.2.1",
30
+ "commitizen": "^4.3.1",
31
+ "cz-conventional-changelog": "^3.3.0",
32
+ "eslint": "^8.57.0",
33
+ "eslint-config-holy-grail": "^61.0.3",
34
+ "husky": "^9.1.7",
35
+ "lint-staged": "^16.2.7",
36
+ "memfs": "^4.51.1",
37
+ "prettier": "^3.7.4",
38
+ "rimraf": "^6.1.2",
39
+ "rollup": "^4.53.5",
40
+ "sinon": "^21.0.0",
41
+ "sinon-chai": "^4.0.1",
42
+ "terser-webpack-plugin": "^5.3.16",
43
+ "ts-loader": "^9.5.4",
44
+ "tsconfig-holy-grail": "^15.0.2",
45
+ "tslint": "^6.1.3",
46
+ "tslint-config-holy-grail": "^56.0.6",
47
+ "typescript": "^5.9.3",
48
+ "vitest": "^4.0.16",
49
+ "webpack": "^5.104.1",
50
+ "webpack-cli": "^6.0.1"
51
+ },
52
+ "files": [
53
+ "build/es2019/",
54
+ "build/es5/",
55
+ "src/"
56
+ ],
57
+ "homepage": "https://github.com/chrisguttandin/playout-audio-worklet",
58
+ "license": "MIT",
59
+ "main": "build/es5/bundle.js",
60
+ "module": "build/es2019/module.js",
61
+ "name": "playout-audio-worklet",
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "https://github.com/chrisguttandin/playout-audio-worklet.git"
65
+ },
66
+ "scripts": {
67
+ "build": "rimraf build/* && webpack --config config/webpack/worklet-es2019.js && tsc --project src/tsconfig.json && rollup --config config/rollup/bundle.mjs",
68
+ "lint": "npm run lint:config && npm run lint:src && npm run lint:test",
69
+ "lint:config": "eslint --config config/eslint/config.json --ext .cjs --ext .js --ext .mjs --report-unused-disable-directives config/",
70
+ "lint:src": "tslint --config config/tslint/src.json --project src/tsconfig.json src/*.ts src/**/*.ts",
71
+ "lint:test": "eslint --config config/eslint/test.json --ext .js --report-unused-disable-directives test/",
72
+ "prepare": "husky",
73
+ "prepublishOnly": "npm run build",
74
+ "test": "npm run lint && npm run build && npm run test:unit",
75
+ "test:unit": "if [ \"$TYPE\" = \"\" -o \"$TYPE\" = \"unit\" ]; then npx vitest --config config/vitest/unit.ts; fi"
76
+ },
77
+ "types": "build/es2019/module.d.ts",
78
+ "version": "1.0.0"
79
+ }
@@ -0,0 +1 @@
1
+ export * from './playout-audio-worklet-node';
@@ -0,0 +1,3 @@
1
+ import { IAudioWorkletNode, TContext } from 'standardized-audio-context';
2
+
3
+ export interface IPlayoutAudioWorkletNode<T extends TContext> extends IAudioWorkletNode<T> {}
package/src/module.ts ADDED
@@ -0,0 +1,72 @@
1
+ import {
2
+ IAudioWorkletNode,
3
+ TAudioWorkletNodeConstructor,
4
+ TContext,
5
+ TNativeAudioWorkletNode,
6
+ TNativeAudioWorkletNodeConstructor,
7
+ TNativeContext
8
+ } from 'standardized-audio-context';
9
+ import { IPlayoutAudioWorkletNode } from './interfaces';
10
+ import { TAnyPlayoutAudioWorkletNodeOptions, TNativePlayoutAudioWorkletNode } from './types';
11
+ import { worklet } from './worklet/worklet';
12
+
13
+ /*
14
+ * @todo Explicitly referencing the barrel file seems to be necessary when enabling the
15
+ * isolatedModules compiler option.
16
+ */
17
+ export * from './interfaces/index';
18
+ export * from './types/index';
19
+
20
+ const blob = new Blob([worklet], { type: 'application/javascript; charset=utf-8' });
21
+
22
+ export const addPlayoutAudioWorkletModule = async (addAudioWorkletModule: (url: string) => Promise<void>) => {
23
+ const url = URL.createObjectURL(blob);
24
+
25
+ try {
26
+ await addAudioWorkletModule(url);
27
+ } finally {
28
+ URL.revokeObjectURL(url);
29
+ }
30
+ };
31
+
32
+ export function createPlayoutAudioWorkletNode<T extends TContext | TNativeContext>(
33
+ audioWorkletNodeConstructor: T extends TContext ? TAudioWorkletNodeConstructor : TNativeAudioWorkletNodeConstructor,
34
+ context: T,
35
+ options: Partial<TAnyPlayoutAudioWorkletNodeOptions<T>> = {}
36
+ ): T extends TContext ? IPlayoutAudioWorkletNode<T> : TNativePlayoutAudioWorkletNode {
37
+ type TAnyAudioWorkletNode = T extends TContext ? IAudioWorkletNode<T> : TNativeAudioWorkletNode;
38
+ type TAnyPlayoutAudioWorkletNode = T extends TContext ? IPlayoutAudioWorkletNode<T> : TNativePlayoutAudioWorkletNode;
39
+
40
+ const { numberOfChannels, readPointerView, startView, stopView, storageView, writePointerView } = options;
41
+ const audioWorkletNode: TAnyAudioWorkletNode = new (<any>audioWorkletNodeConstructor)(context, 'playout-audio-worklet-processor', {
42
+ ...options,
43
+ numberOfInputs: 0,
44
+ numberOfOutputs: 1,
45
+ outputChannelCount: [numberOfChannels],
46
+ pocessorOptions: {
47
+ readPointerView,
48
+ startView,
49
+ stopView,
50
+ storageView,
51
+ writePointerView
52
+ }
53
+ });
54
+ const listener = () => {
55
+ audioWorkletNode.port.removeEventListener('message', listener);
56
+ audioWorkletNode.port.close();
57
+ audioWorkletNode.dispatchEvent(new Event('ended'));
58
+ };
59
+
60
+ audioWorkletNode.port.addEventListener('message', listener);
61
+ audioWorkletNode.port.start();
62
+
63
+ Object.defineProperties(audioWorkletNode, {
64
+ port: {
65
+ get(): TAnyPlayoutAudioWorkletNode['port'] {
66
+ throw new Error("The port of a PlayoutAudioWorkletNode can't be accessed.");
67
+ }
68
+ }
69
+ });
70
+
71
+ return <TAnyPlayoutAudioWorkletNode>audioWorkletNode;
72
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "compilerOptions": {
3
+ "isolatedModules": true
4
+ },
5
+ "extends": "tsconfig-holy-grail/src/tsconfig-browser"
6
+ }
@@ -0,0 +1,7 @@
1
+ import { TAnyContext, TContext } from 'standardized-audio-context';
2
+ import { TNativePlayoutAudioWorkletNodeOptions } from './native-playout-audio-worklet-node-options';
3
+ import { TPlayoutAudioWorkletNodeOptions } from './playout-audio-worklet-node-options';
4
+
5
+ export type TAnyPlayoutAudioWorkletNodeOptions<T extends TAnyContext> = T extends TContext
6
+ ? TPlayoutAudioWorkletNodeOptions
7
+ : TNativePlayoutAudioWorkletNodeOptions;
@@ -0,0 +1 @@
1
+ export type TFixedOptions = 'numberOfInputs' | 'numberOfOutputs';
@@ -0,0 +1,4 @@
1
+ export * from './any-playout-audio-worklet-node-options';
2
+ export * from './native-playout-audio-worklet-node';
3
+ export * from './native-playout-audio-worklet-node-options';
4
+ export * from './playout-audio-worklet-node-options';
@@ -0,0 +1,16 @@
1
+ import { TNativeAudioWorkletNodeOptions } from 'standardized-audio-context';
2
+ import { TFixedOptions } from './fixed-options';
3
+
4
+ export type TNativePlayoutAudioWorkletNodeOptions = Omit<TNativeAudioWorkletNodeOptions, TFixedOptions> & {
5
+ numberOfChannels: number;
6
+
7
+ readPointerView: Uint8Array | Uint16Array | Uint32Array;
8
+
9
+ startView: Uint8Array;
10
+
11
+ stopView: Uint8Array;
12
+
13
+ storageView: Float32Array;
14
+
15
+ writePointerView: Uint8Array | Uint16Array | Uint32Array;
16
+ };
@@ -0,0 +1,3 @@
1
+ import { TNativeAudioWorkletNode } from 'standardized-audio-context';
2
+
3
+ export type TNativePlayoutAudioWorkletNode = TNativeAudioWorkletNode;
@@ -0,0 +1,16 @@
1
+ import { IAudioWorkletNodeOptions } from 'standardized-audio-context';
2
+ import { TFixedOptions } from './fixed-options';
3
+
4
+ export type TPlayoutAudioWorkletNodeOptions = Omit<IAudioWorkletNodeOptions, TFixedOptions> & {
5
+ numberOfChannels: number;
6
+
7
+ readPointerView: Uint8Array | Uint16Array | Uint32Array;
8
+
9
+ startView: Uint8Array;
10
+
11
+ stopView: Uint8Array;
12
+
13
+ storageView: Float32Array;
14
+
15
+ writePointerView: Uint8Array | Uint16Array | Uint32Array;
16
+ };
@@ -0,0 +1,2 @@
1
+ // This is the minified and stringified code of the playout-audio-worklet-processor package.
2
+ export const worklet = `(()=>{"use strict";const e=128;class t extends AudioWorkletProcessor{constructor({numberOfInputs:t,numberOfOutputs:r,outputChannelCount:n,processorOptions:o}){if(0!==t)throw new Error("The numberOfInputs must be 0.");if(1!==r)throw new Error("The numberOfOutputs must be 1.");if(void 0===n||1!==n.length)throw new Error("The outputChannelCount must define a single output.");const[i]=n;if("object"!=typeof o||null===o)throw new Error;const s="readPointerView"in o?o.readPointerView:null;if(!(s instanceof Uint8Array||s instanceof Uint16Array||s instanceof Uint32Array))throw new Error('The readPointerView needs to be an instance of "Uint8Array", "Uint16Array", or "Uint32Array".');if(1!==s.length)throw new Error("The readPointerView needs to have a length of 1.");const a="startView"in o?o.startView:null;if(!(a instanceof Uint16Array))throw new Error('The startView needs to be an instance of "Uint16Array".');if(1!==a.length)throw new Error("The startView needs to have a length of 1.");const h="stopView"in o?o.stopView:null;if(!(h instanceof Uint16Array))throw new Error('The stopView needs to be an instance of "Uint16Array".');if(1!==h.length)throw new Error("The stopView needs to have a length of 1.");const w="storageView"in o?o.storageView:null;if(!(w instanceof Float32Array))throw new Error('The storageView needs to be an instance of "Float32Array".');const f=w.length/i;if(!Number.isInteger(f))throw new Error("The storageView needs to have a length which is a multiple of the number of channels.");const l=f/e;if(!Number.isInteger(l))throw new Error("The capacity can only be a multiple of the render quantum size.");const u="writePointerView"in o?o.writePointerView:null;if(!(u instanceof Uint8Array||u instanceof Uint16Array||u instanceof Uint32Array))throw new Error('The writePointerView needs to be an instance of "Uint8Array", "Uint16Array", or "Uint32Array".');if(1!==u.length)throw new Error("The writePointerView needs to have a length of 1.");if(s.byteLength!==u.byteLength)throw new Error("The pointer need to be of the same size.");if(f>=2**(8*s.byteLength-1))throw new Error("The capacity exceeds the pointer range.");super(),this._isStarted=!1,this._numberOfChannels=i,this._numberOfSlots=l,this._readPointerView=s,this._slots=Array.from({length:l},(t,r)=>{const n=r*e;return Array.from({length:i},(t,r)=>{const o=n+r*l*e;return w.subarray(o,o+e)})}),this._startView=a,this._stopView=h,this._writePointerView=u}process(e,[t]){if(!this._isStarted){if(!this._readStart())return!0;this._isStarted=!0}const r=!(!this._readStorage(t)&&this._readStop());return r||(this.port.postMessage(null),this.port.close()),r}_readStart(){return 1===Atomics.load(this._startView,0)}_readStop(){return 1===Atomics.load(this._stopView,0)}_readStorage(t){const r=Atomics.load(this._readPointerView,0)/e;if(Math.floor((524287&Atomics.load(this._writePointerView,0))/e)===r)return!1;const n=this._slots[r%this._numberOfSlots];for(let e=0;e<this._numberOfChannels;e+=1)t[e].set(n[e]);return Atomics.store(this._readPointerView,0,(r+1)%(2*this._numberOfSlots)*e),!0}}t.parameterDescriptors=[],registerProcessor("playout-audio-worklet-processor",t)})();`; // tslint:disable-line:max-line-length