tone 15.1.23 → 15.2.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/Tone/signal/ToneConstantSource.test.ts +63 -2
- package/Tone/signal/ToneConstantSource.ts +37 -6
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/signal/ToneConstantSource.d.ts +5 -1
- package/build/esm/signal/ToneConstantSource.js +36 -7
- package/build/esm/signal/ToneConstantSource.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ export declare class ToneConstantSource<TypeName extends UnitName = "number"> ex
|
|
|
18
18
|
/**
|
|
19
19
|
* The signal generator
|
|
20
20
|
*/
|
|
21
|
-
private _source
|
|
21
|
+
private _source?;
|
|
22
22
|
/**
|
|
23
23
|
* The offset of the signal generator
|
|
24
24
|
*/
|
|
@@ -29,6 +29,10 @@ export declare class ToneConstantSource<TypeName extends UnitName = "number"> ex
|
|
|
29
29
|
constructor(offset: UnitMap[TypeName]);
|
|
30
30
|
constructor(options?: Partial<ToneConstantSourceOptions<TypeName>>);
|
|
31
31
|
static getDefaults(): ToneConstantSourceOptions<any>;
|
|
32
|
+
/**
|
|
33
|
+
* Once the context is started, kick off source.
|
|
34
|
+
*/
|
|
35
|
+
private readonly _contextStarted;
|
|
32
36
|
/**
|
|
33
37
|
* Start the source node at the given time
|
|
34
38
|
* @param time When to start the source
|
|
@@ -9,18 +9,40 @@ import { OneShotSource, } from "../source/OneShotSource.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export class ToneConstantSource extends OneShotSource {
|
|
11
11
|
constructor() {
|
|
12
|
+
var _a;
|
|
12
13
|
const options = optionsFromArguments(ToneConstantSource.getDefaults(), arguments, ["offset"]);
|
|
13
14
|
super(options);
|
|
14
15
|
this.name = "ToneConstantSource";
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Once the context is started, kick off source.
|
|
17
18
|
*/
|
|
18
|
-
this.
|
|
19
|
-
|
|
19
|
+
this._contextStarted = (state) => {
|
|
20
|
+
if (state !== "running") {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this._source = this.context.createConstantSource();
|
|
24
|
+
connect(this._source, this._gainNode);
|
|
25
|
+
this.offset.setParam(this._source.offset);
|
|
26
|
+
if (this.state === "started") {
|
|
27
|
+
this._source.start(0);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const isSuspended = !this.context.isOffline && this.context.state !== "running";
|
|
31
|
+
if (!isSuspended) {
|
|
32
|
+
this._source = this.context.createConstantSource();
|
|
33
|
+
connect(this._source, this._gainNode);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.context.on("statechange", this._contextStarted);
|
|
37
|
+
}
|
|
20
38
|
this.offset = new Param({
|
|
21
39
|
context: this.context,
|
|
22
40
|
convert: options.convert,
|
|
23
|
-
param:
|
|
41
|
+
param: isSuspended
|
|
42
|
+
? // placeholder param until the context is started
|
|
43
|
+
this.context.createGain().gain
|
|
44
|
+
: (_a = this._source) === null || _a === void 0 ? void 0 : _a.offset,
|
|
45
|
+
swappable: isSuspended,
|
|
24
46
|
units: options.units,
|
|
25
47
|
value: options.offset,
|
|
26
48
|
minValue: options.minValue,
|
|
@@ -39,22 +61,29 @@ export class ToneConstantSource extends OneShotSource {
|
|
|
39
61
|
* @param time When to start the source
|
|
40
62
|
*/
|
|
41
63
|
start(time) {
|
|
64
|
+
var _a;
|
|
42
65
|
const computedTime = this.toSeconds(time);
|
|
43
66
|
this.log("start", computedTime);
|
|
44
67
|
this._startGain(computedTime);
|
|
45
|
-
this._source.start(computedTime);
|
|
68
|
+
(_a = this._source) === null || _a === void 0 ? void 0 : _a.start(computedTime);
|
|
46
69
|
return this;
|
|
47
70
|
}
|
|
48
71
|
_stopSource(time) {
|
|
49
|
-
|
|
72
|
+
var _a;
|
|
73
|
+
if (this.state === "stopped") {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
(_a = this._source) === null || _a === void 0 ? void 0 : _a.stop(time);
|
|
50
77
|
}
|
|
51
78
|
dispose() {
|
|
79
|
+
var _a;
|
|
52
80
|
super.dispose();
|
|
53
81
|
if (this.state === "started") {
|
|
54
82
|
this.stop();
|
|
55
83
|
}
|
|
56
|
-
this._source.disconnect();
|
|
84
|
+
(_a = this._source) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
57
85
|
this.offset.dispose();
|
|
86
|
+
this.context.off("statechange", this._contextStarted);
|
|
58
87
|
return this;
|
|
59
88
|
}
|
|
60
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToneConstantSource.js","sourceRoot":"","sources":["../../../Tone/signal/ToneConstantSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACN,aAAa,GAEb,MAAM,4BAA4B,CAAC;AAWpC;;;;GAIG;AACH,MAAM,OAAO,kBAEX,SAAQ,aAAkD;IAkB3D
|
|
1
|
+
{"version":3,"file":"ToneConstantSource.js","sourceRoot":"","sources":["../../../Tone/signal/ToneConstantSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACN,aAAa,GAEb,MAAM,4BAA4B,CAAC;AAWpC;;;;GAIG;AACH,MAAM,OAAO,kBAEX,SAAQ,aAAkD;IAkB3D;;QACC,MAAM,OAAO,GAAG,oBAAoB,CACnC,kBAAkB,CAAC,WAAW,EAAE,EAChC,SAAS,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B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
|
package/build/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = "15.
|
|
1
|
+
export const version = "15.2.0";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/build/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../Tone/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAW,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../Tone/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAW,QAAQ,CAAC"}
|