tone 15.3.3 → 15.3.5
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/component/envelope/Envelope.test.ts +2 -0
- package/Tone/component/envelope/Envelope.ts +15 -1
- package/Tone/core/clock/Transport.test.ts +57 -0
- package/Tone/core/clock/Transport.ts +22 -0
- package/Tone/core/context/BaseContext.ts +3 -0
- package/Tone/core/context/ToneAudioNode.ts +1 -1
- package/Tone/core/util/Debug.ts +1 -1
- package/Tone/core/util/Emitter.ts +0 -1
- package/Tone/signal/Signal.test.ts +12 -8
- package/Tone/signal/Signal.ts +28 -11
- package/Tone/signal/SignalOperator.test.ts +23 -0
- package/Tone/signal/SignalOperator.ts +8 -1
- package/Tone/source/Source.ts +0 -1
- package/Tone/source/oscillator/LFO.test.ts +2 -0
- package/Tone/source/oscillator/LFO.ts +13 -1
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/component/envelope/Envelope.d.ts +2 -0
- package/build/esm/component/envelope/Envelope.js +6 -1
- package/build/esm/component/envelope/Envelope.js.map +1 -1
- package/build/esm/core/clock/Transport.d.ts +12 -0
- package/build/esm/core/clock/Transport.js +20 -0
- package/build/esm/core/clock/Transport.js.map +1 -1
- package/build/esm/core/context/BaseContext.d.ts +3 -0
- package/build/esm/core/context/BaseContext.js +3 -0
- package/build/esm/core/context/BaseContext.js.map +1 -1
- package/build/esm/core/context/ToneAudioNode.js +1 -1
- package/build/esm/core/context/ToneAudioNode.js.map +1 -1
- package/build/esm/core/util/Debug.js +1 -1
- package/build/esm/core/util/Emitter.d.ts +0 -1
- package/build/esm/core/util/Emitter.js +0 -1
- package/build/esm/core/util/Emitter.js.map +1 -1
- package/build/esm/signal/Signal.d.ts +23 -0
- package/build/esm/signal/Signal.js +26 -2
- package/build/esm/signal/Signal.js.map +1 -1
- package/build/esm/signal/SignalOperator.d.ts +3 -0
- package/build/esm/signal/SignalOperator.js +7 -1
- package/build/esm/signal/SignalOperator.js.map +1 -1
- package/build/esm/source/Source.js +0 -1
- package/build/esm/source/Source.js.map +1 -1
- package/build/esm/source/oscillator/LFO.d.ts +4 -0
- package/build/esm/source/oscillator/LFO.js +8 -1
- package/build/esm/source/oscillator/LFO.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -3,10 +3,12 @@ import { expect } from "chai";
|
|
|
3
3
|
import { BasicTests } from "../../../test/helper/Basic.js";
|
|
4
4
|
import { connectTo } from "../../../test/helper/Connect.js";
|
|
5
5
|
import { Offline } from "../../../test/helper/Offline.js";
|
|
6
|
+
import { SignalConnectAndDisconnect } from "../../../test/helper/SignalTests.js";
|
|
6
7
|
import { Envelope, EnvelopeCurve } from "./Envelope.js";
|
|
7
8
|
|
|
8
9
|
describe("Envelope", () => {
|
|
9
10
|
BasicTests(Envelope);
|
|
11
|
+
SignalConnectAndDisconnect(Envelope);
|
|
10
12
|
|
|
11
13
|
context("Envelope", () => {
|
|
12
14
|
it("has an output connections", () => {
|
|
@@ -9,7 +9,11 @@ import { assert } from "../../core/util/Debug.js";
|
|
|
9
9
|
import { range, timeRange } from "../../core/util/Decorator.js";
|
|
10
10
|
import { optionsFromArguments } from "../../core/util/Defaults.js";
|
|
11
11
|
import { isArray, isObject, isString } from "../../core/util/TypeCheck.js";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
connectSignal,
|
|
14
|
+
disconnectSignal,
|
|
15
|
+
Signal,
|
|
16
|
+
} from "../../signal/Signal.js";
|
|
13
17
|
|
|
14
18
|
type BasicEnvelopeCurve = "linear" | "exponential";
|
|
15
19
|
type InternalEnvelopeCurve = BasicEnvelopeCurve | number[];
|
|
@@ -505,6 +509,16 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
|
|
|
505
509
|
return this;
|
|
506
510
|
}
|
|
507
511
|
|
|
512
|
+
/** @inheritdoc */
|
|
513
|
+
disconnect(
|
|
514
|
+
destination?: InputNode,
|
|
515
|
+
outputNumber = 0,
|
|
516
|
+
inputNumber = 0
|
|
517
|
+
): this {
|
|
518
|
+
disconnectSignal(this, destination, outputNumber, inputNumber);
|
|
519
|
+
return this;
|
|
520
|
+
}
|
|
521
|
+
|
|
508
522
|
/**
|
|
509
523
|
* Render the envelope curve to an array of the given length.
|
|
510
524
|
* Good for visualizing the envelope curve. Rescales the duration of the
|
|
@@ -241,6 +241,33 @@ describe("Transport", () => {
|
|
|
241
241
|
});
|
|
242
242
|
});
|
|
243
243
|
|
|
244
|
+
it("can schedule the current seconds position", () => {
|
|
245
|
+
return Offline((context) => {
|
|
246
|
+
const transport = new TransportInstance({ context });
|
|
247
|
+
transport.start();
|
|
248
|
+
|
|
249
|
+
let scheduled = false;
|
|
250
|
+
|
|
251
|
+
return (time) => {
|
|
252
|
+
if (time > 0.5 && !scheduled) {
|
|
253
|
+
scheduled = true;
|
|
254
|
+
transport.setSecondsAtTime(3, 0.5);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
whenBetween(time, 0, 0.5, () => {
|
|
258
|
+
expect(transport.seconds).to.be.closeTo(time, 0.01);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
whenBetween(time, 0.5, 1, () => {
|
|
262
|
+
expect(transport.seconds).to.be.closeTo(
|
|
263
|
+
2.5 + time,
|
|
264
|
+
0.01
|
|
265
|
+
);
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
}, 1);
|
|
269
|
+
});
|
|
270
|
+
|
|
244
271
|
it("can set the current position in BarsBeatsSixteenths", () => {
|
|
245
272
|
return Offline((context) => {
|
|
246
273
|
const transport = new TransportInstance({ context });
|
|
@@ -423,6 +450,36 @@ describe("Transport", () => {
|
|
|
423
450
|
}, 2.5);
|
|
424
451
|
expect(invocations).to.equal(2);
|
|
425
452
|
});
|
|
453
|
+
|
|
454
|
+
it("can schedule the ticks", () => {
|
|
455
|
+
return Offline((context) => {
|
|
456
|
+
const transport = new TransportInstance({ context });
|
|
457
|
+
transport.start();
|
|
458
|
+
|
|
459
|
+
let scheduled = false;
|
|
460
|
+
|
|
461
|
+
return (time) => {
|
|
462
|
+
if (time > 0.5 && !scheduled) {
|
|
463
|
+
scheduled = true;
|
|
464
|
+
transport.setTicksAtTime(0, 0.5);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
whenBetween(time, 0, 0.5, () => {
|
|
468
|
+
expect(transport.ticks).to.be.closeTo(
|
|
469
|
+
transport.toTicks(time),
|
|
470
|
+
1
|
|
471
|
+
);
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
whenBetween(time, 0.5, 1, () => {
|
|
475
|
+
expect(transport.ticks).to.be.closeTo(
|
|
476
|
+
transport.toTicks(time - 0.5),
|
|
477
|
+
1
|
|
478
|
+
);
|
|
479
|
+
});
|
|
480
|
+
};
|
|
481
|
+
}, 1);
|
|
482
|
+
});
|
|
426
483
|
});
|
|
427
484
|
|
|
428
485
|
context("schedule", () => {
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
TransportTime,
|
|
28
28
|
} from "../type/Units.js";
|
|
29
29
|
import { enterScheduledCallback } from "../util/Debug.js";
|
|
30
|
+
import { assertUsedScheduleTime } from "../util/Debug.js";
|
|
30
31
|
import { optionsFromArguments } from "../util/Defaults.js";
|
|
31
32
|
import { Emitter } from "../util/Emitter.js";
|
|
32
33
|
import { readOnly, writable } from "../util/Interface.js";
|
|
@@ -623,6 +624,7 @@ export class TransportInstance
|
|
|
623
624
|
return this._clock.ticks;
|
|
624
625
|
}
|
|
625
626
|
set ticks(t: Ticks) {
|
|
627
|
+
assertUsedScheduleTime();
|
|
626
628
|
if (this._clock.ticks !== t) {
|
|
627
629
|
const now = this.now();
|
|
628
630
|
// stop everything synced to the transport
|
|
@@ -654,6 +656,16 @@ export class TransportInstance
|
|
|
654
656
|
return this._clock.getTicksAtTime(time);
|
|
655
657
|
}
|
|
656
658
|
|
|
659
|
+
/**
|
|
660
|
+
* Set the Transport's {@link ticks} value at the given time
|
|
661
|
+
* @param ticks The tick value to set
|
|
662
|
+
* @param time The Context time at which to set the seconds value
|
|
663
|
+
*/
|
|
664
|
+
setTicksAtTime(ticks: Ticks, time: Time): this {
|
|
665
|
+
this._clock.setTicksAtTime(ticks, time);
|
|
666
|
+
return this;
|
|
667
|
+
}
|
|
668
|
+
|
|
657
669
|
/**
|
|
658
670
|
* Return the elapsed seconds at the given time.
|
|
659
671
|
* @param time When to get the elapsed seconds
|
|
@@ -663,6 +675,16 @@ export class TransportInstance
|
|
|
663
675
|
return this._clock.getSecondsAtTime(time);
|
|
664
676
|
}
|
|
665
677
|
|
|
678
|
+
/**
|
|
679
|
+
* Set the Transport's {@link seconds} value at the given time.
|
|
680
|
+
* @param seconds The seconds value to set
|
|
681
|
+
* @param time The Context time at which to set the seconds value
|
|
682
|
+
*/
|
|
683
|
+
setSecondsAtTime(seconds: Seconds, time: Time): this {
|
|
684
|
+
this.setTicksAtTime(this.toTicks(seconds), time);
|
|
685
|
+
return this;
|
|
686
|
+
}
|
|
687
|
+
|
|
666
688
|
/**
|
|
667
689
|
* Pulses Per Quarter note. This is the smallest resolution
|
|
668
690
|
* the Transport timing supports. This should be set once
|
|
@@ -25,6 +25,9 @@ export type BaseAudioContextSubset = Omit<
|
|
|
25
25
|
|
|
26
26
|
export type ContextLatencyHint = AudioContextLatencyCategory;
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Shared class for both Offline and Online Audio Context's
|
|
30
|
+
*/
|
|
28
31
|
export abstract class BaseContext
|
|
29
32
|
extends Emitter<"statechange" | "tick">
|
|
30
33
|
implements BaseAudioContextSubset
|
|
@@ -374,7 +374,7 @@ export function disconnect(
|
|
|
374
374
|
): void {
|
|
375
375
|
// resolve the destination node
|
|
376
376
|
if (isDefined(dstNode)) {
|
|
377
|
-
while (dstNode instanceof ToneAudioNode) {
|
|
377
|
+
while (dstNode instanceof ToneAudioNode || dstNode instanceof Param) {
|
|
378
378
|
dstNode = dstNode.input;
|
|
379
379
|
}
|
|
380
380
|
}
|
package/Tone/core/util/Debug.ts
CHANGED
|
@@ -60,7 +60,7 @@ export function assertUsedScheduleTime(time?: Time): void {
|
|
|
60
60
|
) {
|
|
61
61
|
printedScheduledWarning = true;
|
|
62
62
|
warn(
|
|
63
|
-
"
|
|
63
|
+
"Schedulable methods should include the provided time argument to ensure accurate timing. See https://github.com/Tonejs/Tone.js/wiki/Accurate-Timing"
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -10,7 +10,6 @@ export interface EmitterEventObject {
|
|
|
10
10
|
* the ability to listen for and emit events.
|
|
11
11
|
* Inspiration and reference from Jerome Etienne's [MicroEvent](https://github.com/jeromeetienne/microevent.js).
|
|
12
12
|
* MIT (c) 2011 Jerome Etienne.
|
|
13
|
-
* @category Core
|
|
14
13
|
*/
|
|
15
14
|
export class Emitter<EventType extends string = string> extends Tone {
|
|
16
15
|
readonly name: string = "Emitter";
|
|
@@ -3,11 +3,13 @@ import { expect } from "chai";
|
|
|
3
3
|
import { BasicTests } from "../../test/helper/Basic.js";
|
|
4
4
|
import { ConstantOutput } from "../../test/helper/ConstantOutput.js";
|
|
5
5
|
import { Offline } from "../../test/helper/Offline.js";
|
|
6
|
+
import { SignalConnectAndDisconnect } from "../../test/helper/SignalTests.js";
|
|
6
7
|
import { Gain } from "../core/context/Gain.js";
|
|
7
8
|
import { connectSignal, disconnectSignal, Signal } from "./Signal.js";
|
|
8
9
|
|
|
9
10
|
describe("Signal", () => {
|
|
10
11
|
BasicTests(Signal);
|
|
12
|
+
SignalConnectAndDisconnect(Signal);
|
|
11
13
|
|
|
12
14
|
context("Signal Rate Value", () => {
|
|
13
15
|
it("has 1 input and 1 output", () => {
|
|
@@ -605,7 +607,7 @@ describe("Signal", () => {
|
|
|
605
607
|
}, 2);
|
|
606
608
|
});
|
|
607
609
|
|
|
608
|
-
it("can disconnect from all the connected
|
|
610
|
+
it("can disconnect from all the connected nodes", async () => {
|
|
609
611
|
await ConstantOutput(async (context) => {
|
|
610
612
|
// initially destination is 2
|
|
611
613
|
const output0 = new Signal(1).toDestination();
|
|
@@ -621,15 +623,17 @@ describe("Signal", () => {
|
|
|
621
623
|
|
|
622
624
|
it("can disconnect from a specific node", async () => {
|
|
623
625
|
await ConstantOutput(() => {
|
|
624
|
-
// initially destination is
|
|
625
|
-
const
|
|
626
|
+
// initially destination is 3
|
|
627
|
+
const output0 = new Signal(1).toDestination();
|
|
628
|
+
const output1 = new Signal(2).toDestination();
|
|
626
629
|
|
|
627
|
-
|
|
628
|
-
|
|
630
|
+
const sig = new Signal(3);
|
|
631
|
+
sig.connect(output0);
|
|
632
|
+
sig.connect(output1);
|
|
629
633
|
|
|
630
|
-
//
|
|
631
|
-
sig.disconnect(
|
|
632
|
-
},
|
|
634
|
+
// output0 goes back to 1 after disconnecting
|
|
635
|
+
sig.disconnect(output0);
|
|
636
|
+
}, 4); // 1 + 3
|
|
633
637
|
});
|
|
634
638
|
|
|
635
639
|
it("disconnects every input when no input is passed in", async () => {
|
package/Tone/signal/Signal.ts
CHANGED
|
@@ -85,7 +85,7 @@ export class Signal<TypeName extends UnitName = "number">
|
|
|
85
85
|
this._constantSource.start(0);
|
|
86
86
|
this.input = this._param = this._constantSource.offset;
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
/** @inheritdoc */
|
|
89
89
|
static getDefaults(): SignalOptions<any> {
|
|
90
90
|
return Object.assign(ToneAudioNode.getDefaults(), {
|
|
91
91
|
convert: true,
|
|
@@ -93,13 +93,13 @@ export class Signal<TypeName extends UnitName = "number">
|
|
|
93
93
|
value: 0,
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
/** @inheritdoc */
|
|
97
97
|
connect(destination: InputNode, outputNum = 0, inputNum = 0): this {
|
|
98
98
|
// start it only when connected to something
|
|
99
99
|
connectSignal(this, destination, outputNum, inputNum);
|
|
100
100
|
return this;
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
/** @inheritdoc */
|
|
103
103
|
disconnect(
|
|
104
104
|
destination?: InputNode,
|
|
105
105
|
outputNum?: number,
|
|
@@ -109,7 +109,7 @@ export class Signal<TypeName extends UnitName = "number">
|
|
|
109
109
|
disconnectSignal(this, destination, outputNum, inputNum);
|
|
110
110
|
return this;
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
/** @inheritdoc */
|
|
113
113
|
dispose(): this {
|
|
114
114
|
super.dispose();
|
|
115
115
|
this._param.dispose();
|
|
@@ -123,25 +123,31 @@ export class Signal<TypeName extends UnitName = "number">
|
|
|
123
123
|
// all docs are generated from AbstractParam.ts
|
|
124
124
|
//-------------------------------------
|
|
125
125
|
|
|
126
|
+
/** @inheritdoc */
|
|
126
127
|
setValueAtTime(value: UnitMap[TypeName], time: Time): this {
|
|
127
128
|
this._param.setValueAtTime(value, time);
|
|
128
129
|
return this;
|
|
129
130
|
}
|
|
131
|
+
/** @inheritdoc */
|
|
130
132
|
getValueAtTime(time: Time): UnitMap[TypeName] {
|
|
131
133
|
return this._param.getValueAtTime(time);
|
|
132
134
|
}
|
|
135
|
+
/** @inheritdoc */
|
|
133
136
|
setRampPoint(time: Time): this {
|
|
134
137
|
this._param.setRampPoint(time);
|
|
135
138
|
return this;
|
|
136
139
|
}
|
|
140
|
+
/** @inheritdoc */
|
|
137
141
|
linearRampToValueAtTime(value: UnitMap[TypeName], time: Time): this {
|
|
138
142
|
this._param.linearRampToValueAtTime(value, time);
|
|
139
143
|
return this;
|
|
140
144
|
}
|
|
145
|
+
/** @inheritdoc */
|
|
141
146
|
exponentialRampToValueAtTime(value: UnitMap[TypeName], time: Time): this {
|
|
142
147
|
this._param.exponentialRampToValueAtTime(value, time);
|
|
143
148
|
return this;
|
|
144
149
|
}
|
|
150
|
+
/** @inheritdoc */
|
|
145
151
|
exponentialRampTo(
|
|
146
152
|
value: UnitMap[TypeName],
|
|
147
153
|
rampTime: Time,
|
|
@@ -150,6 +156,7 @@ export class Signal<TypeName extends UnitName = "number">
|
|
|
150
156
|
this._param.exponentialRampTo(value, rampTime, startTime);
|
|
151
157
|
return this;
|
|
152
158
|
}
|
|
159
|
+
/** @inheritdoc */
|
|
153
160
|
linearRampTo(
|
|
154
161
|
value: UnitMap[TypeName],
|
|
155
162
|
rampTime: Time,
|
|
@@ -158,6 +165,7 @@ export class Signal<TypeName extends UnitName = "number">
|
|
|
158
165
|
this._param.linearRampTo(value, rampTime, startTime);
|
|
159
166
|
return this;
|
|
160
167
|
}
|
|
168
|
+
/** @inheritdoc */
|
|
161
169
|
targetRampTo(
|
|
162
170
|
value: UnitMap[TypeName],
|
|
163
171
|
rampTime: Time,
|
|
@@ -166,6 +174,7 @@ export class Signal<TypeName extends UnitName = "number">
|
|
|
166
174
|
this._param.targetRampTo(value, rampTime, startTime);
|
|
167
175
|
return this;
|
|
168
176
|
}
|
|
177
|
+
/** @inheritdoc */
|
|
169
178
|
exponentialApproachValueAtTime(
|
|
170
179
|
value: UnitMap[TypeName],
|
|
171
180
|
time: Time,
|
|
@@ -174,6 +183,7 @@ export class Signal<TypeName extends UnitName = "number">
|
|
|
174
183
|
this._param.exponentialApproachValueAtTime(value, time, rampTime);
|
|
175
184
|
return this;
|
|
176
185
|
}
|
|
186
|
+
/** @inheritdoc */
|
|
177
187
|
setTargetAtTime(
|
|
178
188
|
value: UnitMap[TypeName],
|
|
179
189
|
startTime: Time,
|
|
@@ -182,6 +192,7 @@ export class Signal<TypeName extends UnitName = "number">
|
|
|
182
192
|
this._param.setTargetAtTime(value, startTime, timeConstant);
|
|
183
193
|
return this;
|
|
184
194
|
}
|
|
195
|
+
/** @inheritdoc */
|
|
185
196
|
setValueCurveAtTime(
|
|
186
197
|
values: UnitMap[TypeName][],
|
|
187
198
|
startTime: Time,
|
|
@@ -191,44 +202,47 @@ export class Signal<TypeName extends UnitName = "number">
|
|
|
191
202
|
this._param.setValueCurveAtTime(values, startTime, duration, scaling);
|
|
192
203
|
return this;
|
|
193
204
|
}
|
|
205
|
+
/** @inheritdoc */
|
|
194
206
|
cancelScheduledValues(time: Time): this {
|
|
195
207
|
this._param.cancelScheduledValues(time);
|
|
196
208
|
return this;
|
|
197
209
|
}
|
|
210
|
+
/** @inheritdoc */
|
|
198
211
|
cancelAndHoldAtTime(time: Time): this {
|
|
199
212
|
this._param.cancelAndHoldAtTime(time);
|
|
200
213
|
return this;
|
|
201
214
|
}
|
|
215
|
+
/** @inheritdoc */
|
|
202
216
|
rampTo(value: UnitMap[TypeName], rampTime: Time, startTime?: Time): this {
|
|
203
217
|
this._param.rampTo(value, rampTime, startTime);
|
|
204
218
|
return this;
|
|
205
219
|
}
|
|
206
|
-
|
|
220
|
+
/** @inheritdoc */
|
|
207
221
|
get value(): UnitMap[TypeName] {
|
|
208
222
|
return this._param.value;
|
|
209
223
|
}
|
|
210
224
|
set value(value: UnitMap[TypeName]) {
|
|
211
225
|
this._param.value = value;
|
|
212
226
|
}
|
|
213
|
-
|
|
227
|
+
/** @inheritdoc */
|
|
214
228
|
get convert(): boolean {
|
|
215
229
|
return this._param.convert;
|
|
216
230
|
}
|
|
217
231
|
set convert(convert: boolean) {
|
|
218
232
|
this._param.convert = convert;
|
|
219
233
|
}
|
|
220
|
-
|
|
234
|
+
/** @inheritdoc */
|
|
221
235
|
get units(): UnitName {
|
|
222
236
|
return this._param.units;
|
|
223
237
|
}
|
|
224
|
-
|
|
238
|
+
/** @inheritdoc */
|
|
225
239
|
get overridden(): boolean {
|
|
226
240
|
return this._param.overridden;
|
|
227
241
|
}
|
|
228
242
|
set overridden(overridden: boolean) {
|
|
229
243
|
this._param.overridden = overridden;
|
|
230
244
|
}
|
|
231
|
-
|
|
245
|
+
/** @inheritdoc */
|
|
232
246
|
get maxValue(): number {
|
|
233
247
|
return this._param.maxValue;
|
|
234
248
|
}
|
|
@@ -288,7 +302,7 @@ export function connectSignal(
|
|
|
288
302
|
// reset the value
|
|
289
303
|
destination.setValueAtTime(0, 0);
|
|
290
304
|
// mark the value as overridden
|
|
291
|
-
if (destination instanceof Signal) {
|
|
305
|
+
if (destination instanceof Signal || destination instanceof Param) {
|
|
292
306
|
destination.overridden = true;
|
|
293
307
|
}
|
|
294
308
|
// store the connection
|
|
@@ -344,7 +358,10 @@ export function disconnectSignal(
|
|
|
344
358
|
|
|
345
359
|
// restore the value
|
|
346
360
|
connections.forEach((connection) => {
|
|
347
|
-
if (
|
|
361
|
+
if (
|
|
362
|
+
connection.destination instanceof Signal ||
|
|
363
|
+
connection.destination instanceof Param
|
|
364
|
+
) {
|
|
348
365
|
connection.destination.overridden = false;
|
|
349
366
|
}
|
|
350
367
|
connection.destination.setValueAtTime(
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BasicTests } from "../../test/helper/Basic.js";
|
|
2
|
+
import { SignalConnectAndDisconnect } from "../../test/helper/SignalTests.js";
|
|
3
|
+
import { Signal } from "./Signal.js";
|
|
4
|
+
import { SignalOperator, SignalOperatorOptions } from "./SignalOperator.js";
|
|
5
|
+
|
|
6
|
+
describe("SignalOperator", () => {
|
|
7
|
+
class TestSignalOperator extends SignalOperator<SignalOperatorOptions> {
|
|
8
|
+
name = "TestSignalOperator";
|
|
9
|
+
|
|
10
|
+
input: Signal;
|
|
11
|
+
output: Signal;
|
|
12
|
+
|
|
13
|
+
constructor(options: SignalOperatorOptions) {
|
|
14
|
+
super(options);
|
|
15
|
+
this.input = this.output = new Signal({
|
|
16
|
+
context: this.context,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
BasicTests(TestSignalOperator);
|
|
22
|
+
SignalConnectAndDisconnect(TestSignalOperator);
|
|
23
|
+
});
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ToneAudioNodeOptions,
|
|
5
5
|
} from "../core/context/ToneAudioNode.js";
|
|
6
6
|
import { optionsFromArguments } from "../core/util/Defaults.js";
|
|
7
|
-
import { connectSignal } from "./Signal.js";
|
|
7
|
+
import { connectSignal, disconnectSignal } from "./Signal.js";
|
|
8
8
|
|
|
9
9
|
export type SignalOperatorOptions = ToneAudioNodeOptions;
|
|
10
10
|
|
|
@@ -23,8 +23,15 @@ export abstract class SignalOperator<
|
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** @inheritdoc */
|
|
26
27
|
connect(destination: InputNode, outputNum = 0, inputNum = 0): this {
|
|
27
28
|
connectSignal(this, destination, outputNum, inputNum);
|
|
28
29
|
return this;
|
|
29
30
|
}
|
|
31
|
+
|
|
32
|
+
/** @inheritdoc */
|
|
33
|
+
disconnect(destination: InputNode, outputNum = 0, inputNum = 0): this {
|
|
34
|
+
disconnectSignal(this, destination, outputNum, inputNum);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
30
37
|
}
|
package/Tone/source/Source.ts
CHANGED
|
@@ -217,7 +217,6 @@ export abstract class Source<
|
|
|
217
217
|
this.log("restart", computedTime);
|
|
218
218
|
this.restart(computedTime, offset, duration);
|
|
219
219
|
} else {
|
|
220
|
-
this.log("start", computedTime);
|
|
221
220
|
this._state.setStateAtTime("started", computedTime);
|
|
222
221
|
if (this._synced) {
|
|
223
222
|
// add the offset time to the event
|
|
@@ -3,11 +3,13 @@ import { expect } from "chai";
|
|
|
3
3
|
import { BasicTests } from "../../../test/helper/Basic.js";
|
|
4
4
|
import { Offline } from "../../../test/helper/Offline.js";
|
|
5
5
|
import { OutputAudio } from "../../../test/helper/OutputAudio.js";
|
|
6
|
+
import { SignalConnectAndDisconnect } from "../../../test/helper/SignalTests.js";
|
|
6
7
|
import { Signal } from "../../signal/Signal.js";
|
|
7
8
|
import { LFO, LFOOptions } from "./LFO.js";
|
|
8
9
|
|
|
9
10
|
describe("LFO", () => {
|
|
10
11
|
BasicTests(LFO);
|
|
12
|
+
SignalConnectAndDisconnect(LFO);
|
|
11
13
|
|
|
12
14
|
context("API", () => {
|
|
13
15
|
it("can get the current state", () => {
|
|
@@ -17,7 +17,11 @@ import { readOnly } from "../../core/util/Interface.js";
|
|
|
17
17
|
import { BasicPlaybackState } from "../../core/util/StateTimeline.js";
|
|
18
18
|
import { AudioToGain } from "../../signal/AudioToGain.js";
|
|
19
19
|
import { Scale } from "../../signal/Scale.js";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
connectSignal,
|
|
22
|
+
disconnectSignal,
|
|
23
|
+
Signal,
|
|
24
|
+
} from "../../signal/Signal.js";
|
|
21
25
|
import { Zero } from "../../signal/Zero.js";
|
|
22
26
|
import { Oscillator, ToneOscillatorType } from "./Oscillator.js";
|
|
23
27
|
import {
|
|
@@ -325,6 +329,14 @@ export class LFO extends ToneAudioNode<LFOOptions> {
|
|
|
325
329
|
return this;
|
|
326
330
|
}
|
|
327
331
|
|
|
332
|
+
/**
|
|
333
|
+
* Disconnect the LFO.
|
|
334
|
+
*/
|
|
335
|
+
disconnect(destination?: InputNode, outputNum = 0, inputNum = 0): this {
|
|
336
|
+
disconnectSignal(this, destination, outputNum, inputNum);
|
|
337
|
+
return this;
|
|
338
|
+
}
|
|
339
|
+
|
|
328
340
|
/**
|
|
329
341
|
* Private methods borrowed from Param
|
|
330
342
|
*/
|
package/Tone/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version: string = "15.3.
|
|
1
|
+
export const version: string = "15.3.5";
|