node-web-audio-api 0.17.0 → 0.18.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.18.0 (13/03/2024)
2
+
3
+ - Fix `MediaStreamAudioSourceNode`
4
+
1
5
  ## v0.17.0 (08/03/2024)
2
6
 
3
7
  - Update upstream crate to [1.0.0-rc.2](https://github.com/orottier/web-audio-api-rs/blob/main/CHANGELOG.md#version-100-rc2-2024-03-07)
package/TODOS.md ADDED
@@ -0,0 +1,21 @@
1
+ # TODO
2
+
3
+ - [ ] Review AudioBuffer
4
+ - [ ] Ended event in AudioScheduledSourceNode for offline audio context
5
+ - [ ] `MediaStreamAudioSourceNode`
6
+ + [x] properly handle `mediaStream`
7
+ + [ ] do not accept OfflineAudioContext (see if this can be delegated to upstream)
8
+
9
+ - [ ] wpt bot
10
+
11
+ - [ ] OfflineAudioContext should not lock the process w/ event listeners if startRendering has not been called
12
+
13
+ - [ ] wrap EventTarget::dispatchEvent in setTimeout(callback , 0); so that events are dispatched in the next microtask ?
14
+
15
+
16
+ ## AudioBuffer notes
17
+
18
+ - [x] `AudioBuffer` has to be a facade because `startRendering`, `decodeAudioData`
19
+ - [x] need to adapt `AudioBufferSourceNode` and `ConvolverNode` so
20
+ that `set buffer(value)` retrieve the wrapped value
21
+ - [ ] No fucking sound when buffer comes from `decodeAudioData`..., but ok when `createBuffer`
package/index.mjs CHANGED
@@ -31,8 +31,6 @@ export const {
31
31
  AudioDestinationNode,
32
32
  AudioBuffer,
33
33
  PeriodicWave,
34
- // manually written nodes
35
- MediaStreamAudioSourceNode,
36
34
  // generated supported nodes
37
35
  AnalyserNode,
38
36
  AudioBufferSourceNode,
@@ -45,6 +43,7 @@ export const {
45
43
  DynamicsCompressorNode,
46
44
  GainNode,
47
45
  IIRFilterNode,
46
+ MediaStreamAudioSourceNode,
48
47
  OscillatorNode,
49
48
  PannerNode,
50
49
  StereoPannerNode,
@@ -33,6 +33,7 @@ module.exports = (superclass, bindings) => {
33
33
  DynamicsCompressorNode,
34
34
  GainNode,
35
35
  IIRFilterNode,
36
+ MediaStreamAudioSourceNode,
36
37
  OscillatorNode,
37
38
  PannerNode,
38
39
  StereoPannerNode,
@@ -128,6 +129,7 @@ module.exports = (superclass, bindings) => {
128
129
  return new IIRFilterNode(this, options);
129
130
  }
130
131
 
132
+
131
133
  createOscillator() {
132
134
  return new OscillatorNode(this);
133
135
  }
@@ -0,0 +1,59 @@
1
+ // -------------------------------------------------------------------------- //
2
+ // -------------------------------------------------------------------------- //
3
+ // //
4
+ // //
5
+ // //
6
+ // ██╗ ██╗ █████╗ ██████╗ ███╗ ██╗██╗███╗ ██╗ ██████╗ //
7
+ // ██║ ██║██╔══██╗██╔══██╗████╗ ██║██║████╗ ██║██╔════╝ //
8
+ // ██║ █╗ ██║███████║██████╔╝██╔██╗ ██║██║██╔██╗ ██║██║ ███╗ //
9
+ // ██║███╗██║██╔══██║██╔══██╗██║╚██╗██║██║██║╚██╗██║██║ ██║ //
10
+ // ╚███╔███╔╝██║ ██║██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝ //
11
+ // ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ //
12
+ // //
13
+ // //
14
+ // - This file has been generated --------------------------- //
15
+ // //
16
+ // //
17
+ // -------------------------------------------------------------------------- //
18
+ // -------------------------------------------------------------------------- //
19
+
20
+ // eslint-disable-next-line no-unused-vars
21
+ const { throwSanitizedError } = require('./lib/errors.js');
22
+ // eslint-disable-next-line no-unused-vars
23
+ const { AudioParam } = require('./AudioParam.js');
24
+ const EventTargetMixin = require('./EventTarget.mixin.js');
25
+ const AudioNodeMixin = require('./AudioNode.mixin.js');
26
+
27
+
28
+ module.exports = (NativeMediaStreamAudioSourceNode) => {
29
+
30
+ const EventTarget = EventTargetMixin(NativeMediaStreamAudioSourceNode);
31
+ const AudioNode = AudioNodeMixin(EventTarget);
32
+
33
+ class MediaStreamAudioSourceNode extends AudioNode {
34
+ constructor(context, options) {
35
+ if (options !== undefined && typeof options !== 'object') {
36
+ throw new TypeError("Failed to construct 'MediaStreamAudioSourceNode': argument 2 is not of type 'MediaStreamAudioSourceOptions'")
37
+ }
38
+
39
+ super(context, options);
40
+
41
+ }
42
+
43
+ // getters
44
+
45
+ get mediaStream() {
46
+ return super.mediaStream;
47
+ }
48
+
49
+ // setters
50
+
51
+ // methods
52
+
53
+ }
54
+
55
+ return MediaStreamAudioSourceNode;
56
+ };
57
+
58
+
59
+
@@ -13,10 +13,12 @@ module.exports = function patchOfflineAudioContext(bindings) {
13
13
  constructor(...args) {
14
14
  // handle initialisation with either an options object or a sequence of parameters
15
15
  // https://webaudio.github.io/web-audio-api/#dom-offlineaudiocontext-constructor-contextoptions-contextoptions
16
- if (isPlainObject(args[0])
17
- && 'numberOfChannels' in args[0] && 'length' in args[0] && 'sampleRate' in args[0]
16
+ if (isPlainObject(args[0]) && 'length' in args[0] && 'sampleRate' in args[0]
18
17
  ) {
19
- const { numberOfChannels, length, sampleRate } = args[0];
18
+ let { numberOfChannels, length, sampleRate } = args[0];
19
+ if (numberOfChannels === undefined) {
20
+ numberOfChannels = 1;
21
+ }
20
22
  args = [numberOfChannels, length, sampleRate];
21
23
  }
22
24
 
@@ -33,6 +33,7 @@ module.exports = function monkeyPatch(nativeBinding) {
33
33
  nativeBinding.DynamicsCompressorNode = require('./DynamicsCompressorNode.js')(nativeBinding.DynamicsCompressorNode);
34
34
  nativeBinding.GainNode = require('./GainNode.js')(nativeBinding.GainNode);
35
35
  nativeBinding.IIRFilterNode = require('./IIRFilterNode.js')(nativeBinding.IIRFilterNode);
36
+ nativeBinding.MediaStreamAudioSourceNode = require('./MediaStreamAudioSourceNode.js')(nativeBinding.MediaStreamAudioSourceNode);
36
37
  nativeBinding.OscillatorNode = require('./OscillatorNode.js')(nativeBinding.OscillatorNode);
37
38
  nativeBinding.PannerNode = require('./PannerNode.js')(nativeBinding.PannerNode);
38
39
  nativeBinding.StereoPannerNode = require('./StereoPannerNode.js')(nativeBinding.StereoPannerNode);
Binary file
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "node-web-audio-api",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "author": "Benjamin Matuszewski",
5
5
  "description": "Node.js bindings for web-audio-api-rs using napi-rs",
6
6
  "exports": {
7
7
  "import": "./index.mjs",
8
8
  "require": "./index.cjs"
9
9
  },
10
- "repository": "https://github.com/ircam-ismm/node-web-audio-api",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/ircam-ismm/node-web-audio-api.git"
13
+ },
11
14
  "license": "BSD-3-Clause",
12
15
  "keywords": [
13
16
  "audio",