node-web-audio-api 0.18.0 → 0.20.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 +14 -0
- package/TODOS.md +134 -12
- package/index.mjs +17 -6
- package/js/AnalyserNode.js +259 -48
- package/js/AudioBuffer.js +243 -0
- package/js/AudioBufferSourceNode.js +259 -41
- package/js/AudioContext.js +294 -28
- package/js/AudioDestinationNode.js +42 -100
- package/js/AudioListener.js +219 -0
- package/js/AudioNode.js +323 -0
- package/js/AudioParam.js +252 -39
- package/js/AudioScheduledSourceNode.js +120 -0
- package/js/BaseAudioContext.js +434 -0
- package/js/BiquadFilterNode.js +218 -29
- package/js/ChannelMergerNode.js +93 -22
- package/js/ChannelSplitterNode.js +93 -22
- package/js/ConstantSourceNode.js +86 -26
- package/js/ConvolverNode.js +158 -29
- package/js/DelayNode.js +112 -21
- package/js/DynamicsCompressorNode.js +195 -27
- package/js/Events.js +84 -0
- package/js/GainNode.js +104 -21
- package/js/IIRFilterNode.js +136 -23
- package/js/MediaStreamAudioSourceNode.js +80 -24
- package/js/OfflineAudioContext.js +198 -35
- package/js/OscillatorNode.js +189 -32
- package/js/PannerNode.js +458 -56
- package/js/PeriodicWave.js +67 -3
- package/js/ScriptProcessorNode.js +179 -0
- package/js/StereoPannerNode.js +104 -21
- package/js/WaveShaperNode.js +144 -29
- package/js/lib/cast.js +19 -0
- package/js/lib/errors.js +10 -55
- package/js/lib/events.js +10 -0
- package/js/lib/symbols.js +20 -0
- package/js/lib/utils.js +12 -12
- package/js/monkey-patch.js +40 -31
- package/node-web-audio-api.darwin-arm64.node +0 -0
- package/node-web-audio-api.darwin-x64.node +0 -0
- package/node-web-audio-api.linux-arm-gnueabihf.node +0 -0
- package/node-web-audio-api.linux-arm64-gnu.node +0 -0
- package/node-web-audio-api.linux-x64-gnu.node +0 -0
- package/node-web-audio-api.win32-arm64-msvc.node +0 -0
- package/node-web-audio-api.win32-x64-msvc.node +0 -0
- package/package.json +7 -4
- package/run-wpt.md +27 -0
- package/run-wpt.sh +5 -0
- package/js/AudioNode.mixin.js +0 -132
- package/js/AudioScheduledSourceNode.mixin.js +0 -67
- package/js/BaseAudioContext.mixin.js +0 -154
- package/js/EventTarget.mixin.js +0 -60
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
const conversions = require('webidl-conversions');
|
|
2
|
+
|
|
3
|
+
const { throwSanitizedError } = require('./lib/errors.js');
|
|
4
|
+
const { kEnumerableProperty, kHiddenProperty } = require('./lib/utils.js');
|
|
5
|
+
const { kNapiObj } = require('./lib/symbols.js');
|
|
6
|
+
|
|
7
|
+
const AudioParam = require('./AudioParam.js');
|
|
8
|
+
|
|
9
|
+
class AudioListener {
|
|
10
|
+
#positionX = null;
|
|
11
|
+
#positionY = null;
|
|
12
|
+
#positionZ = null;
|
|
13
|
+
#forwardX = null;
|
|
14
|
+
#forwardY = null;
|
|
15
|
+
#forwardZ = null;
|
|
16
|
+
#upX = null;
|
|
17
|
+
#upY = null;
|
|
18
|
+
#upZ = null;
|
|
19
|
+
|
|
20
|
+
constructor(options) {
|
|
21
|
+
// Make constructor "private"
|
|
22
|
+
if (
|
|
23
|
+
(typeof options !== 'object')
|
|
24
|
+
|| !(kNapiObj in options)
|
|
25
|
+
|| options[kNapiObj]['Symbol.toStringTag'] !== 'AudioListener'
|
|
26
|
+
) {
|
|
27
|
+
throw new TypeError('Illegal constructor');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Object.defineProperty(this, kNapiObj, {
|
|
31
|
+
value: options[kNapiObj],
|
|
32
|
+
...kHiddenProperty,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
this.#positionX = new AudioParam({ [kNapiObj]: this[kNapiObj].positionX });
|
|
36
|
+
this.#positionY = new AudioParam({ [kNapiObj]: this[kNapiObj].positionY });
|
|
37
|
+
this.#positionZ = new AudioParam({ [kNapiObj]: this[kNapiObj].positionZ });
|
|
38
|
+
this.#forwardX = new AudioParam({ [kNapiObj]: this[kNapiObj].forwardX });
|
|
39
|
+
this.#forwardY = new AudioParam({ [kNapiObj]: this[kNapiObj].forwardY });
|
|
40
|
+
this.#forwardZ = new AudioParam({ [kNapiObj]: this[kNapiObj].forwardZ });
|
|
41
|
+
this.#upX = new AudioParam({ [kNapiObj]: this[kNapiObj].upX });
|
|
42
|
+
this.#upY = new AudioParam({ [kNapiObj]: this[kNapiObj].upY });
|
|
43
|
+
this.#upZ = new AudioParam({ [kNapiObj]: this[kNapiObj].upZ });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get positionX() {
|
|
47
|
+
if (!(this instanceof AudioListener)) {
|
|
48
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return this.#positionX;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get positionY() {
|
|
55
|
+
if (!(this instanceof AudioListener)) {
|
|
56
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return this.#positionY;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get positionZ() {
|
|
63
|
+
if (!(this instanceof AudioListener)) {
|
|
64
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return this.#positionZ;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get forwardX() {
|
|
71
|
+
if (!(this instanceof AudioListener)) {
|
|
72
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return this.#forwardX;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get forwardY() {
|
|
79
|
+
if (!(this instanceof AudioListener)) {
|
|
80
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return this.#forwardY;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get forwardZ() {
|
|
87
|
+
if (!(this instanceof AudioListener)) {
|
|
88
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return this.#forwardZ;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get upX() {
|
|
95
|
+
if (!(this instanceof AudioListener)) {
|
|
96
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return this.#upX;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get upY() {
|
|
103
|
+
if (!(this instanceof AudioListener)) {
|
|
104
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return this.#upY;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get upZ() {
|
|
111
|
+
if (!(this instanceof AudioListener)) {
|
|
112
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return this.#upZ;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setPosition(x, y, z) {
|
|
119
|
+
if (!(this instanceof AudioListener)) {
|
|
120
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (arguments.length < 3) {
|
|
124
|
+
throw new TypeError(`Failed to execute 'setPosition' on 'AudioListener': 3 arguments required, but only 0 present.`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
x = conversions['float'](x, {
|
|
128
|
+
context: `Failed to execute 'setPosition' on 'AudioListener': The provided float value`,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
y = conversions['float'](y, {
|
|
132
|
+
context: `Failed to execute 'setPosition' on 'AudioListener': The provided float value`,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
z = conversions['float'](z, {
|
|
136
|
+
context: `Failed to execute 'setPosition' on 'AudioListener': The provided float value`,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
this[kNapiObj].setPosition(x, y, z);
|
|
141
|
+
} catch (err) {
|
|
142
|
+
throwSanitizedError(err);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
setOrientation(x, y, z, xUp, yUp, zUp) {
|
|
147
|
+
if (!(this instanceof AudioListener)) {
|
|
148
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioListener\'');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (arguments.length < 6) {
|
|
152
|
+
throw new TypeError(`Failed to execute 'setOrientation' on 'AudioListener': 6 arguments required, but only 0 present.`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
x = conversions['float'](x, {
|
|
156
|
+
context: `Failed to execute 'setOrientation' on 'AudioListener': The provided float value`,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
y = conversions['float'](y, {
|
|
160
|
+
context: `Failed to execute 'setOrientation' on 'AudioListener': The provided float value`,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
z = conversions['float'](z, {
|
|
164
|
+
context: `Failed to execute 'setOrientation' on 'AudioListener': The provided float value`,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
xUp = conversions['float'](xUp, {
|
|
168
|
+
context: `Failed to execute 'setOrientation' on 'AudioListener': The provided float value`,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
yUp = conversions['float'](yUp, {
|
|
172
|
+
context: `Failed to execute 'setOrientation' on 'AudioListener': The provided float value`,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
zUp = conversions['float'](zUp, {
|
|
176
|
+
context: `Failed to execute 'setOrientation' on 'AudioListener': The provided float value`,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
this[kNapiObj].setOrientation(x, y, z, xUp, yUp, zUp);
|
|
181
|
+
} catch (err) {
|
|
182
|
+
throwSanitizedError(err);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
Object.defineProperties(AudioListener, {
|
|
188
|
+
length: {
|
|
189
|
+
__proto__: null,
|
|
190
|
+
writable: false,
|
|
191
|
+
enumerable: false,
|
|
192
|
+
configurable: true,
|
|
193
|
+
value: 0,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
Object.defineProperties(AudioListener.prototype, {
|
|
198
|
+
[Symbol.toStringTag]: {
|
|
199
|
+
__proto__: null,
|
|
200
|
+
writable: false,
|
|
201
|
+
enumerable: false,
|
|
202
|
+
configurable: true,
|
|
203
|
+
value: 'AudioListener',
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
positionX: kEnumerableProperty,
|
|
207
|
+
positionY: kEnumerableProperty,
|
|
208
|
+
positionZ: kEnumerableProperty,
|
|
209
|
+
forwardX: kEnumerableProperty,
|
|
210
|
+
forwardY: kEnumerableProperty,
|
|
211
|
+
forwardZ: kEnumerableProperty,
|
|
212
|
+
upX: kEnumerableProperty,
|
|
213
|
+
upY: kEnumerableProperty,
|
|
214
|
+
upZ: kEnumerableProperty,
|
|
215
|
+
setPosition: kEnumerableProperty,
|
|
216
|
+
setOrientation: kEnumerableProperty,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
module.exports = AudioListener;
|
package/js/AudioNode.js
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
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
|
+
const conversions = require('webidl-conversions');
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
throwSanitizedError,
|
|
24
|
+
} = require('./lib/errors.js');
|
|
25
|
+
const {
|
|
26
|
+
kEnumerableProperty,
|
|
27
|
+
kHiddenProperty,
|
|
28
|
+
} = require('./lib/utils.js');
|
|
29
|
+
const {
|
|
30
|
+
kNapiObj,
|
|
31
|
+
} = require('./lib/symbols.js');
|
|
32
|
+
|
|
33
|
+
const AudioParam = require('./AudioParam.js');
|
|
34
|
+
|
|
35
|
+
class AudioNode extends EventTarget {
|
|
36
|
+
#context = null;
|
|
37
|
+
|
|
38
|
+
constructor(context, options) {
|
|
39
|
+
// Make constructor "private"
|
|
40
|
+
if (
|
|
41
|
+
(typeof options !== 'object') ||
|
|
42
|
+
!(kNapiObj in options)
|
|
43
|
+
) {
|
|
44
|
+
throw new TypeError('Illegal constructor');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
super(options[kNapiObj]);
|
|
48
|
+
|
|
49
|
+
this.#context = context;
|
|
50
|
+
|
|
51
|
+
Object.defineProperty(this, kNapiObj, {
|
|
52
|
+
value: options[kNapiObj],
|
|
53
|
+
...kHiddenProperty,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get context() {
|
|
58
|
+
return this.#context;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get numberOfInputs() {
|
|
62
|
+
if (!(this instanceof AudioNode)) {
|
|
63
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioNode\'');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return this[kNapiObj].numberOfInputs;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get numberOfOutputs() {
|
|
70
|
+
if (!(this instanceof AudioNode)) {
|
|
71
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioNode\'');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return this[kNapiObj].numberOfOutputs;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get channelCount() {
|
|
78
|
+
if (!(this instanceof AudioNode)) {
|
|
79
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioNode\'');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return this[kNapiObj].channelCount;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
set channelCount(value) {
|
|
86
|
+
if (!(this instanceof AudioNode)) {
|
|
87
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioNode\'');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
value = conversions['unsigned long'](value, {
|
|
91
|
+
context: `Failed to set the 'channelCount' property on 'AudioNode': Value`,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
this[kNapiObj].channelCount = value;
|
|
96
|
+
} catch (err) {
|
|
97
|
+
throwSanitizedError(err);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get channelCountMode() {
|
|
102
|
+
if (!(this instanceof AudioNode)) {
|
|
103
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioNode\'');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return this[kNapiObj].channelCountMode;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
set channelCountMode(value) {
|
|
110
|
+
if (!(this instanceof AudioNode)) {
|
|
111
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioNode\'');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!['max', 'clamped-max', 'explicit'].includes(value)) {
|
|
115
|
+
console.warn(`Failed to set the 'channelCountMode' property on 'AudioNode': Value '${value}' is not a valid 'ChannelCountMode' enum value`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
this[kNapiObj].channelCountMode = value;
|
|
121
|
+
} catch (err) {
|
|
122
|
+
throwSanitizedError(err);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get channelInterpretation() {
|
|
127
|
+
if (!(this instanceof AudioNode)) {
|
|
128
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioNode\'');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return this[kNapiObj].channelInterpretation;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
set channelInterpretation(value) {
|
|
135
|
+
if (!(this instanceof AudioNode)) {
|
|
136
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioNode\'');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (!['speakers', 'discrete'].includes(value)) {
|
|
140
|
+
console.warn(`Failed to set the 'channelInterpretation' property on 'AudioNode': Value '${value}' is not a valid 'ChannelInterpretation' enum value`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
this[kNapiObj].channelInterpretation = value;
|
|
146
|
+
} catch (err) {
|
|
147
|
+
throwSanitizedError(err);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
connect(...args) {
|
|
152
|
+
if (!(this instanceof AudioNode)) {
|
|
153
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioNode\'');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (arguments.length < 1) {
|
|
157
|
+
throw new TypeError(`Failed to execute 'connect' on 'AudioNode': 1 argument required, but only ${arguments.length} present`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let destination;
|
|
161
|
+
let output;
|
|
162
|
+
let input;
|
|
163
|
+
|
|
164
|
+
// note that audio listener params are not wrapped
|
|
165
|
+
if (args[0] instanceof AudioNode) {
|
|
166
|
+
destination = args[0][kNapiObj];
|
|
167
|
+
|
|
168
|
+
if (args[1] !== undefined) {
|
|
169
|
+
output = conversions['unsigned long'](args[1], {
|
|
170
|
+
enforceRange: true,
|
|
171
|
+
context: 'Failed to execute \'connect\' on \'AudioNode\':',
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
output = 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (args[2] !== undefined) {
|
|
178
|
+
input = conversions['unsigned long'](args[2], {
|
|
179
|
+
enforceRange: true,
|
|
180
|
+
context: 'Failed to execute \'connect\' on \'AudioNode\':',
|
|
181
|
+
});
|
|
182
|
+
} else {
|
|
183
|
+
input = 0;
|
|
184
|
+
}
|
|
185
|
+
} else if (args[0] instanceof AudioParam) {
|
|
186
|
+
if (arguments.length > 2) {
|
|
187
|
+
throw new TypeError('Failed to execute \'connect\' on \'AudioNode\': parameter 1 is not of type \'AudioNode\'');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
destination = args[0][kNapiObj];
|
|
191
|
+
|
|
192
|
+
if (args[1] !== undefined) {
|
|
193
|
+
output = conversions['unsigned long'](args[1], {
|
|
194
|
+
enforceRange: true,
|
|
195
|
+
context: 'Failed to execute \'connect\' on \'AudioNode\':',
|
|
196
|
+
});
|
|
197
|
+
} else {
|
|
198
|
+
output = 0;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Rust does not make difference between AudioNode and AudioParam
|
|
202
|
+
input = 0;
|
|
203
|
+
} else {
|
|
204
|
+
throw new TypeError('Failed to execute \'connect\' on \'AudioNode\': Overload resolution failed');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
this[kNapiObj].connect(destination, output, input);
|
|
209
|
+
} catch (err) {
|
|
210
|
+
throwSanitizedError(err);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// return given destination
|
|
214
|
+
return args[0];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
disconnect(...args) {
|
|
218
|
+
if (!(this instanceof AudioNode)) {
|
|
219
|
+
throw new TypeError('Invalid Invocation: Value of \'this\' must be of type \'AudioNode\'');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (arguments.length > 2) {
|
|
223
|
+
if (args[0] instanceof AudioNode) {
|
|
224
|
+
const destination = args[0][kNapiObj];
|
|
225
|
+
const output = conversions['unsigned long'](args[1], {
|
|
226
|
+
enforceRange: true,
|
|
227
|
+
context: 'Failed to execute \'disconnect\' on \'AudioNode\':',
|
|
228
|
+
});
|
|
229
|
+
const input = conversions['unsigned long'](args[2], {
|
|
230
|
+
enforceRange: true,
|
|
231
|
+
context: 'Failed to execute \'disconnect\' on \'AudioNode\':',
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
try {
|
|
235
|
+
return this[kNapiObj].disconnect(destination, output, input);
|
|
236
|
+
} catch (err) {
|
|
237
|
+
throwSanitizedError(err);
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
throw new TypeError('Failed to execute \'disconnect\' on \'AudioNode\': : Overload resolution failed');
|
|
241
|
+
}
|
|
242
|
+
} else if (arguments.length === 2) {
|
|
243
|
+
if (args[0] instanceof AudioNode || args[0] instanceof AudioParam) {
|
|
244
|
+
const destination = args[0][kNapiObj];
|
|
245
|
+
const output = conversions['unsigned long'](args[1], {
|
|
246
|
+
enforceRange: true,
|
|
247
|
+
context: 'Failed to execute \'disconnect\' on \'AudioNode\':',
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
try {
|
|
251
|
+
return this[kNapiObj].disconnect(destination, output);
|
|
252
|
+
} catch (err) {
|
|
253
|
+
throwSanitizedError(err);
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
throw new TypeError('Failed to execute \'disconnect\' on \'AudioNode\': : Overload resolution failed');
|
|
257
|
+
}
|
|
258
|
+
} else if (arguments.length === 1) {
|
|
259
|
+
if (args[0] instanceof AudioNode || args[0] instanceof AudioParam) {
|
|
260
|
+
const destination = args[0][kNapiObj];
|
|
261
|
+
|
|
262
|
+
try {
|
|
263
|
+
return this[kNapiObj].disconnect(destination);
|
|
264
|
+
} catch (err) {
|
|
265
|
+
throwSanitizedError(err);
|
|
266
|
+
}
|
|
267
|
+
} else if (Number.isFinite(args[0])) {
|
|
268
|
+
const output = conversions['unsigned long'](args[0], {
|
|
269
|
+
enforceRange: true,
|
|
270
|
+
context: 'Failed to execute \'disconnect\' on \'AudioNode\':',
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
try {
|
|
274
|
+
return this[kNapiObj].disconnect(output);
|
|
275
|
+
} catch (err) {
|
|
276
|
+
throwSanitizedError(err);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Note that we don't have the "overload resolution failed" branch here
|
|
281
|
+
// which seems to be aligned with browsers behavior
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Just call disconnect for remaning cases
|
|
285
|
+
// - i.e. including node.disconnect(NaN), node.disconnect(null), etc.
|
|
286
|
+
try {
|
|
287
|
+
this[kNapiObj].disconnect();
|
|
288
|
+
} catch (err) {
|
|
289
|
+
throwSanitizedError(err);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
Object.defineProperties(AudioNode, {
|
|
295
|
+
length: {
|
|
296
|
+
__proto__: null,
|
|
297
|
+
writable: false,
|
|
298
|
+
enumerable: false,
|
|
299
|
+
configurable: true,
|
|
300
|
+
value: 0,
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
Object.defineProperties(AudioNode.prototype, {
|
|
305
|
+
[Symbol.toStringTag]: {
|
|
306
|
+
__proto__: null,
|
|
307
|
+
writable: false,
|
|
308
|
+
enumerable: false,
|
|
309
|
+
configurable: true,
|
|
310
|
+
value: 'AudioNode',
|
|
311
|
+
},
|
|
312
|
+
|
|
313
|
+
context: kEnumerableProperty,
|
|
314
|
+
numberOfInputs: kEnumerableProperty,
|
|
315
|
+
numberOfOutputs: kEnumerableProperty,
|
|
316
|
+
channelCount: kEnumerableProperty,
|
|
317
|
+
channelCountMode: kEnumerableProperty,
|
|
318
|
+
channelInterpretation: kEnumerableProperty,
|
|
319
|
+
connect: kEnumerableProperty,
|
|
320
|
+
disconnect: kEnumerableProperty,
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
module.exports = AudioNode;
|