tone 14.9.15 → 14.9.16
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/context/ToneWithContext.ts +45 -14
- package/Tone/event/Part.ts +2 -2
- package/Tone/event/Sequence.ts +2 -2
- package/Tone/index.ts +13 -9
- package/Tone/signal/SyncedSignal.ts +1 -0
- package/Tone/signal/WaveShaper.ts +1 -1
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/core/context/ToneWithContext.js +15 -8
- package/build/esm/core/context/ToneWithContext.js.map +1 -1
- package/build/esm/event/Part.d.ts +2 -2
- package/build/esm/event/Sequence.d.ts +2 -2
- package/build/esm/index.d.ts +13 -9
- package/build/esm/index.js.map +1 -1
- package/build/esm/signal/SyncedSignal.js.map +1 -1
- package/build/esm/signal/WaveShaper.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -5,10 +5,21 @@ import { TimeClass } from "../type/Time";
|
|
|
5
5
|
import { TransportTimeClass } from "../type/TransportTime";
|
|
6
6
|
import { Frequency, Hertz, Seconds, Ticks, Time } from "../type/Units";
|
|
7
7
|
import { assertUsedScheduleTime } from "../util/Debug";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
getDefaultsFromInstance,
|
|
10
|
+
optionsFromArguments,
|
|
11
|
+
} from "../util/Defaults";
|
|
9
12
|
import { RecursivePartial } from "../util/Interface";
|
|
10
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
isArray,
|
|
15
|
+
isBoolean,
|
|
16
|
+
isDefined,
|
|
17
|
+
isNumber,
|
|
18
|
+
isString,
|
|
19
|
+
isUndef,
|
|
20
|
+
} from "../util/TypeCheck";
|
|
11
21
|
import { BaseContext } from "./BaseContext";
|
|
22
|
+
import type { TransportClass } from "../clock/Transport";
|
|
12
23
|
|
|
13
24
|
/**
|
|
14
25
|
* A unit which process audio
|
|
@@ -20,8 +31,9 @@ export interface ToneWithContextOptions {
|
|
|
20
31
|
/**
|
|
21
32
|
* The Base class for all nodes that have an AudioContext.
|
|
22
33
|
*/
|
|
23
|
-
export abstract class ToneWithContext<
|
|
24
|
-
|
|
34
|
+
export abstract class ToneWithContext<
|
|
35
|
+
Options extends ToneWithContextOptions
|
|
36
|
+
> extends Tone {
|
|
25
37
|
/**
|
|
26
38
|
* The context belonging to the node.
|
|
27
39
|
*/
|
|
@@ -37,11 +49,15 @@ export abstract class ToneWithContext<Options extends ToneWithContextOptions> ex
|
|
|
37
49
|
/**
|
|
38
50
|
* Pass in a constructor as the first argument
|
|
39
51
|
*/
|
|
40
|
-
constructor(context?: BaseContext)
|
|
52
|
+
constructor(context?: BaseContext);
|
|
41
53
|
constructor(options?: Partial<ToneWithContextOptions>);
|
|
42
54
|
constructor() {
|
|
43
55
|
super();
|
|
44
|
-
const options = optionsFromArguments(
|
|
56
|
+
const options = optionsFromArguments(
|
|
57
|
+
ToneWithContext.getDefaults(),
|
|
58
|
+
arguments,
|
|
59
|
+
["context"]
|
|
60
|
+
);
|
|
45
61
|
if (this.defaultContext) {
|
|
46
62
|
this.context = this.defaultContext;
|
|
47
63
|
} else {
|
|
@@ -94,7 +110,7 @@ export abstract class ToneWithContext<Options extends ToneWithContextOptions> ex
|
|
|
94
110
|
}
|
|
95
111
|
|
|
96
112
|
/**
|
|
97
|
-
* Convert the incoming time to seconds.
|
|
113
|
+
* Convert the incoming time to seconds.
|
|
98
114
|
* This is calculated against the current {@link TransportClass} bpm
|
|
99
115
|
* @example
|
|
100
116
|
* const gain = new Tone.Gain();
|
|
@@ -137,7 +153,7 @@ export abstract class ToneWithContext<Options extends ToneWithContextOptions> ex
|
|
|
137
153
|
protected _getPartialProperties(props: Options): Partial<Options> {
|
|
138
154
|
const options = this.get();
|
|
139
155
|
// remove attributes from the prop that are not in the partial
|
|
140
|
-
Object.keys(options).forEach(name => {
|
|
156
|
+
Object.keys(options).forEach((name) => {
|
|
141
157
|
if (isUndef(props[name])) {
|
|
142
158
|
delete options[name];
|
|
143
159
|
}
|
|
@@ -153,15 +169,26 @@ export abstract class ToneWithContext<Options extends ToneWithContextOptions> ex
|
|
|
153
169
|
*/
|
|
154
170
|
get(): Options {
|
|
155
171
|
const defaults = getDefaultsFromInstance(this) as Options;
|
|
156
|
-
Object.keys(defaults).forEach(attribute => {
|
|
172
|
+
Object.keys(defaults).forEach((attribute) => {
|
|
157
173
|
if (Reflect.has(this, attribute)) {
|
|
158
174
|
const member = this[attribute];
|
|
159
|
-
if (
|
|
175
|
+
if (
|
|
176
|
+
isDefined(member) &&
|
|
177
|
+
isDefined(member.value) &&
|
|
178
|
+
isDefined(member.setValueAtTime)
|
|
179
|
+
) {
|
|
160
180
|
defaults[attribute] = member.value;
|
|
161
181
|
} else if (member instanceof ToneWithContext) {
|
|
162
|
-
defaults[attribute] = member._getPartialProperties(
|
|
182
|
+
defaults[attribute] = member._getPartialProperties(
|
|
183
|
+
defaults[attribute]
|
|
184
|
+
);
|
|
163
185
|
// otherwise make sure it's a serializable type
|
|
164
|
-
} else if (
|
|
186
|
+
} else if (
|
|
187
|
+
isArray(member) ||
|
|
188
|
+
isNumber(member) ||
|
|
189
|
+
isString(member) ||
|
|
190
|
+
isBoolean(member)
|
|
191
|
+
) {
|
|
165
192
|
defaults[attribute] = member;
|
|
166
193
|
} else {
|
|
167
194
|
// remove all undefined and unserializable attributes
|
|
@@ -186,9 +213,13 @@ export abstract class ToneWithContext<Options extends ToneWithContextOptions> ex
|
|
|
186
213
|
* player.autostart = true;
|
|
187
214
|
*/
|
|
188
215
|
set(props: RecursivePartial<Options>): this {
|
|
189
|
-
Object.keys(props).forEach(attribute => {
|
|
216
|
+
Object.keys(props).forEach((attribute) => {
|
|
190
217
|
if (Reflect.has(this, attribute) && isDefined(this[attribute])) {
|
|
191
|
-
if (
|
|
218
|
+
if (
|
|
219
|
+
this[attribute] &&
|
|
220
|
+
isDefined(this[attribute].value) &&
|
|
221
|
+
isDefined(this[attribute].setValueAtTime)
|
|
222
|
+
) {
|
|
192
223
|
// small optimization
|
|
193
224
|
if (this[attribute].value !== props[attribute]) {
|
|
194
225
|
this[attribute].value = props[attribute];
|
package/Tone/event/Part.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* @param callback The callback to invoke on each event
|
|
63
|
-
* @param
|
|
63
|
+
* @param value the array of events
|
|
64
64
|
*/
|
|
65
65
|
constructor(callback?: ToneEventCallback<CallbackType<ValueType>>, value?: ValueType[]);
|
|
66
66
|
constructor(options?: Partial<PartOptions<ValueType>>);
|
|
@@ -209,7 +209,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
|
|
|
209
209
|
* Add a an event to the part.
|
|
210
210
|
* @param time The time the note should start. If an object is passed in, it should
|
|
211
211
|
* have a 'time' attribute and the rest of the object will be used as the 'value'.
|
|
212
|
-
* @param value
|
|
212
|
+
* @param value Any value to add to the timeline
|
|
213
213
|
* @example
|
|
214
214
|
* const part = new Tone.Part();
|
|
215
215
|
* part.add("1m", "C#+11");
|
package/Tone/event/Sequence.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { isArray, isString } from "../core/util/TypeCheck";
|
|
|
5
5
|
import { Part } from "./Part";
|
|
6
6
|
import { ToneEvent, ToneEventCallback, ToneEventOptions } from "./ToneEvent";
|
|
7
7
|
|
|
8
|
-
type SequenceEventDescription<T> = Array<T |
|
|
8
|
+
type SequenceEventDescription<T> = Array<T | SequenceEventDescription<T>>;
|
|
9
9
|
|
|
10
10
|
interface SequenceOptions<T> extends Omit<ToneEventOptions<T>, "value"> {
|
|
11
11
|
loopStart: number;
|
|
@@ -59,7 +59,7 @@ export class Sequence<ValueType = any> extends ToneEvent<ValueType> {
|
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* @param callback The callback to invoke with every note
|
|
62
|
-
* @param
|
|
62
|
+
* @param events The sequence of events
|
|
63
63
|
* @param subdivision The subdivision between which events are placed.
|
|
64
64
|
*/
|
|
65
65
|
constructor(
|
package/Tone/index.ts
CHANGED
|
@@ -7,9 +7,13 @@ import { ToneAudioBuffer } from "./core/context/ToneAudioBuffer";
|
|
|
7
7
|
export { start } from "./core/Global";
|
|
8
8
|
import { Seconds } from "./core/type/Units";
|
|
9
9
|
export { supported } from "./core/context/AudioContext";
|
|
10
|
+
import type { TransportClass } from "./core/clock/Transport";
|
|
11
|
+
import type { DestinationClass } from "./core/context/Destination";
|
|
12
|
+
import type { DrawClass } from "./core/util/Draw";
|
|
13
|
+
import type { ListenerClass } from "./core/context/Listener";
|
|
10
14
|
|
|
11
15
|
/**
|
|
12
|
-
* The current audio context time of the global {@link BaseContext}.
|
|
16
|
+
* The current audio context time of the global {@link BaseContext}.
|
|
13
17
|
* @see {@link Context.now}
|
|
14
18
|
* @category Core
|
|
15
19
|
*/
|
|
@@ -39,7 +43,7 @@ export const Transport = getContext().transport;
|
|
|
39
43
|
* @see {@link TransportClass}
|
|
40
44
|
* @category Core
|
|
41
45
|
*/
|
|
42
|
-
export function getTransport():
|
|
46
|
+
export function getTransport(): TransportClass {
|
|
43
47
|
return getContext().transport;
|
|
44
48
|
}
|
|
45
49
|
|
|
@@ -61,7 +65,7 @@ export const Master = getContext().destination;
|
|
|
61
65
|
* @see {@link DestinationClass}
|
|
62
66
|
* @category Core
|
|
63
67
|
*/
|
|
64
|
-
export function getDestination():
|
|
68
|
+
export function getDestination(): DestinationClass {
|
|
65
69
|
return getContext().destination;
|
|
66
70
|
}
|
|
67
71
|
|
|
@@ -76,12 +80,12 @@ export const Listener = getContext().listener;
|
|
|
76
80
|
* The {@link ListenerClass} belonging to the global Tone.js Context.
|
|
77
81
|
* @category Core
|
|
78
82
|
*/
|
|
79
|
-
export function getListener():
|
|
83
|
+
export function getListener(): ListenerClass {
|
|
80
84
|
return getContext().listener;
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
/**
|
|
84
|
-
* Draw is used to synchronize the draw frame with the Transport's callbacks.
|
|
88
|
+
* Draw is used to synchronize the draw frame with the Transport's callbacks.
|
|
85
89
|
* @see {@link DrawClass}
|
|
86
90
|
* @category Core
|
|
87
91
|
* @deprecated Use {@link getDraw} instead
|
|
@@ -89,12 +93,12 @@ export function getListener(): import("./core/context/Listener").ListenerClass {
|
|
|
89
93
|
export const Draw = getContext().draw;
|
|
90
94
|
|
|
91
95
|
/**
|
|
92
|
-
* Get the singleton attached to the global context.
|
|
93
|
-
* Draw is used to synchronize the draw frame with the Transport's callbacks.
|
|
96
|
+
* Get the singleton attached to the global context.
|
|
97
|
+
* Draw is used to synchronize the draw frame with the Transport's callbacks.
|
|
94
98
|
* @see {@link DrawClass}
|
|
95
99
|
* @category Core
|
|
96
100
|
*/
|
|
97
|
-
export function getDraw():
|
|
101
|
+
export function getDraw(): DrawClass {
|
|
98
102
|
return getContext().draw;
|
|
99
103
|
}
|
|
100
104
|
|
|
@@ -106,7 +110,7 @@ export function getDraw(): import("./core/util/Draw").DrawClass {
|
|
|
106
110
|
export const context = getContext();
|
|
107
111
|
|
|
108
112
|
/**
|
|
109
|
-
* Promise which resolves when all of the loading promises are resolved.
|
|
113
|
+
* Promise which resolves when all of the loading promises are resolved.
|
|
110
114
|
* Alias for static {@link ToneAudioBuffer.loaded} method.
|
|
111
115
|
* @category Core
|
|
112
116
|
*/
|
|
@@ -4,6 +4,7 @@ import { optionsFromArguments } from "../core/util/Defaults";
|
|
|
4
4
|
import { TransportTimeClass } from "../core/type/TransportTime";
|
|
5
5
|
import { ToneConstantSource } from "./ToneConstantSource";
|
|
6
6
|
import { OutputNode } from "../core/context/ToneAudioNode";
|
|
7
|
+
import type { TransportClass } from "../core/clock/Transport";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Adds the ability to synchronize the signal to the {@link TransportClass}
|
|
@@ -55,7 +55,7 @@ export class WaveShaper extends SignalOperator<WaveShaperOptions> {
|
|
|
55
55
|
* signal is an AudioRange [-1, 1] value and the output
|
|
56
56
|
* signal can take on any numerical values.
|
|
57
57
|
*
|
|
58
|
-
* @param
|
|
58
|
+
* @param length The length of the WaveShaperNode buffer.
|
|
59
59
|
*/
|
|
60
60
|
constructor(mapping?: WaveShaperMapping, length?: number);
|
|
61
61
|
constructor(options?: Partial<WaveShaperOptions>);
|
package/Tone/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version: string = "14.9.
|
|
1
|
+
export const version: string = "14.9.16";
|