tone 15.5.2 → 15.5.3
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/Tone/core/util/TypeCheck.ts +9 -9
- package/Tone/source/UserMedia.test.ts +131 -112
- package/Tone/source/UserMedia.ts +37 -26
- package/Tone/source/oscillator/Oscillator.test.ts +3 -4
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/core/util/TypeCheck.d.ts +8 -8
- package/build/esm/core/util/TypeCheck.js.map +1 -1
- package/build/esm/source/UserMedia.d.ts +3 -3
- package/build/esm/source/UserMedia.js +32 -25
- package/build/esm/source/UserMedia.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { Note } from "../type/Units.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Test if the arg is undefined
|
|
4
4
|
*/
|
|
5
|
-
export declare function isUndef(arg:
|
|
5
|
+
export declare function isUndef(arg: unknown): arg is undefined;
|
|
6
6
|
/**
|
|
7
7
|
* Test if the arg is not undefined
|
|
8
8
|
*/
|
|
@@ -10,29 +10,29 @@ export declare function isDefined<T>(arg: T | undefined): arg is T;
|
|
|
10
10
|
/**
|
|
11
11
|
* Test if the arg is a function
|
|
12
12
|
*/
|
|
13
|
-
export declare function isFunction(arg:
|
|
13
|
+
export declare function isFunction(arg: unknown): arg is (a: any) => any;
|
|
14
14
|
/**
|
|
15
15
|
* Test if the argument is a number.
|
|
16
16
|
*/
|
|
17
|
-
export declare function isNumber(arg:
|
|
17
|
+
export declare function isNumber(arg: unknown): arg is number;
|
|
18
18
|
/**
|
|
19
19
|
* Test if the given argument is an object literal (i.e. `{}`);
|
|
20
20
|
*/
|
|
21
|
-
export declare function isObject(arg:
|
|
21
|
+
export declare function isObject(arg: unknown): arg is object;
|
|
22
22
|
/**
|
|
23
23
|
* Test if the argument is a boolean.
|
|
24
24
|
*/
|
|
25
|
-
export declare function isBoolean(arg:
|
|
25
|
+
export declare function isBoolean(arg: unknown): arg is boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Test if the argument is an Array
|
|
28
28
|
*/
|
|
29
|
-
export declare function isArray(arg:
|
|
29
|
+
export declare function isArray(arg: unknown): arg is any[];
|
|
30
30
|
/**
|
|
31
31
|
* Test if the argument is a string.
|
|
32
32
|
*/
|
|
33
|
-
export declare function isString(arg:
|
|
33
|
+
export declare function isString(arg: unknown): arg is string;
|
|
34
34
|
/**
|
|
35
35
|
* Test if the argument is in the form of a note in scientific pitch notation.
|
|
36
36
|
* e.g. "C4"
|
|
37
37
|
*/
|
|
38
|
-
export declare function isNote(arg:
|
|
38
|
+
export declare function isNote(arg: unknown): arg is Note;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeCheck.js","sourceRoot":"","sources":["../../../../Tone/core/util/TypeCheck.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"TypeCheck.js","sourceRoot":"","sources":["../../../../Tone/core/util/TypeCheck.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,GAAY;IACnC,OAAO,GAAG,KAAK,SAAS,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAI,GAAkB;IAC9C,OAAO,GAAG,KAAK,SAAS,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAY;IACtC,OAAO,OAAO,GAAG,KAAK,UAAU,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAY;IACpC,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAY;IACpC,OAAO,CACN,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,iBAAiB;QACxD,GAAc,CAAC,WAAW,KAAK,MAAM,CACtC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,GAAY;IACrC,OAAO,OAAO,GAAG,KAAK,SAAS,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,GAAY;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAY;IACpC,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,GAAY;IAClC,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,qCAAqC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -58,11 +58,11 @@ export declare class UserMedia extends ToneAudioNode<UserMediaOptions> {
|
|
|
58
58
|
* Open the media stream. If a string is passed in, it is assumed
|
|
59
59
|
* to be the label or id of the stream, if a number is passed in,
|
|
60
60
|
* it is the input number of the stream.
|
|
61
|
-
* @param
|
|
62
|
-
*
|
|
61
|
+
* @param labelOrIdOrConstraints The label or id of the audio input media device, or a getUserMedia constraints object.
|
|
62
|
+
* With no argument, the default stream is opened.
|
|
63
63
|
* @return The promise is resolved when the stream is open.
|
|
64
64
|
*/
|
|
65
|
-
open(
|
|
65
|
+
open(labelOrIdOrConstraints?: string | number | MediaStreamConstraints): Promise<this>;
|
|
66
66
|
/**
|
|
67
67
|
* Close the media stream
|
|
68
68
|
*/
|
|
@@ -2,9 +2,9 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
import { Volume } from "../component/channel/Volume.js";
|
|
3
3
|
import { connect, ToneAudioNode, } from "../core/context/ToneAudioNode.js";
|
|
4
4
|
import { assert } from "../core/util/Debug.js";
|
|
5
|
-
import { optionsFromArguments } from "../core/util/Defaults.js";
|
|
5
|
+
import { deepMerge, optionsFromArguments } from "../core/util/Defaults.js";
|
|
6
6
|
import { readOnly } from "../core/util/Interface.js";
|
|
7
|
-
import { isDefined, isNumber } from "../core/util/TypeCheck.js";
|
|
7
|
+
import { isDefined, isNumber, isObject } from "../core/util/TypeCheck.js";
|
|
8
8
|
/**
|
|
9
9
|
* UserMedia uses MediaDevices.getUserMedia to open up and external microphone or audio input.
|
|
10
10
|
* Check [MediaDevices API Support](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia)
|
|
@@ -47,43 +47,50 @@ export class UserMedia extends ToneAudioNode {
|
|
|
47
47
|
* Open the media stream. If a string is passed in, it is assumed
|
|
48
48
|
* to be the label or id of the stream, if a number is passed in,
|
|
49
49
|
* it is the input number of the stream.
|
|
50
|
-
* @param
|
|
51
|
-
*
|
|
50
|
+
* @param labelOrIdOrConstraints The label or id of the audio input media device, or a getUserMedia constraints object.
|
|
51
|
+
* With no argument, the default stream is opened.
|
|
52
52
|
* @return The promise is resolved when the stream is open.
|
|
53
53
|
*/
|
|
54
|
-
open(
|
|
54
|
+
open(labelOrIdOrConstraints) {
|
|
55
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
56
|
assert(UserMedia.supported, "UserMedia is not supported");
|
|
57
57
|
// close the previous stream
|
|
58
58
|
if (this.state === "started") {
|
|
59
59
|
this.close();
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
if (isNumber(labelOrId)) {
|
|
63
|
-
this._device = devices[labelOrId];
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this._device = devices.find((device) => {
|
|
67
|
-
return (device.label === labelOrId || device.deviceId === labelOrId);
|
|
68
|
-
});
|
|
69
|
-
// didn't find a matching device
|
|
70
|
-
if (!this._device && devices.length > 0) {
|
|
71
|
-
this._device = devices[0];
|
|
72
|
-
}
|
|
73
|
-
assert(isDefined(this._device), `No matching device ${labelOrId}`);
|
|
74
|
-
}
|
|
75
|
-
// do getUserMedia
|
|
76
|
-
const constraints = {
|
|
61
|
+
let constraints = {
|
|
77
62
|
audio: {
|
|
78
63
|
echoCancellation: false,
|
|
79
64
|
sampleRate: this.context.sampleRate,
|
|
80
65
|
noiseSuppression: false,
|
|
81
|
-
mozNoiseSuppression: false,
|
|
82
66
|
},
|
|
83
67
|
};
|
|
84
|
-
if (
|
|
85
|
-
//
|
|
86
|
-
constraints
|
|
68
|
+
if (isObject(labelOrIdOrConstraints)) {
|
|
69
|
+
// if the user passed in a constraints object
|
|
70
|
+
constraints = deepMerge(constraints, labelOrIdOrConstraints);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// if the user passed in a label or id
|
|
74
|
+
const devices = yield UserMedia.enumerateDevices();
|
|
75
|
+
if (isNumber(labelOrIdOrConstraints)) {
|
|
76
|
+
this._device = devices[labelOrIdOrConstraints];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this._device = devices.find((device) => {
|
|
80
|
+
return (device.label === labelOrIdOrConstraints ||
|
|
81
|
+
device.deviceId === labelOrIdOrConstraints);
|
|
82
|
+
});
|
|
83
|
+
// didn't find a matching device
|
|
84
|
+
if (!this._device && devices.length > 0) {
|
|
85
|
+
this._device = devices[0];
|
|
86
|
+
}
|
|
87
|
+
assert(isDefined(this._device), `No matching device ${labelOrIdOrConstraints}`);
|
|
88
|
+
}
|
|
89
|
+
// if there is a device, set the deviceId
|
|
90
|
+
if (this._device) {
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
constraints.audio.deviceId = this._device.deviceId;
|
|
93
|
+
}
|
|
87
94
|
}
|
|
88
95
|
const stream = yield navigator.mediaDevices.getUserMedia(constraints);
|
|
89
96
|
// start a new source only if the previous one is closed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMedia.js","sourceRoot":"","sources":["../../../Tone/source/UserMedia.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD,OAAO,EACN,OAAO,E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CAAC;IAED,OAAO;QACN,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACH,MAAM,KAAK,SAAS;QACnB,OAAO,CACN,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC;YACjC,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,CAC9C,CAAC;IACH,CAAC;CACD"}
|
package/build/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = "15.5.
|
|
1
|
+
export const version = "15.5.3";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|