tone 14.9.8 → 14.9.10
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/README.md +15 -18
- package/Tone/core/clock/Transport.test.ts +60 -60
- package/Tone/core/clock/Transport.ts +22 -22
- package/Tone/core/clock/TransportEvent.test.ts +4 -4
- package/Tone/core/clock/TransportEvent.ts +2 -2
- package/Tone/core/clock/TransportRepeatEvent.test.ts +4 -4
- package/Tone/core/clock/TransportRepeatEvent.ts +1 -1
- package/Tone/core/context/BaseContext.ts +4 -4
- package/Tone/core/context/Context.test.ts +8 -8
- package/Tone/core/context/Context.ts +4 -4
- package/Tone/core/context/Destination.test.ts +2 -2
- package/Tone/core/context/Destination.ts +4 -4
- package/Tone/core/context/DummyContext.ts +4 -4
- package/Tone/core/context/Listener.test.ts +2 -2
- package/Tone/core/context/Listener.ts +2 -2
- package/Tone/core/context/ToneWithContext.ts +1 -3
- package/Tone/core/util/Draw.test.ts +2 -2
- package/Tone/core/util/Draw.ts +2 -2
- package/Tone/core/util/IntervalTimeline.ts +1 -0
- package/Tone/core/util/StateTimeline.ts +1 -0
- package/Tone/core/util/Timeline.ts +1 -0
- package/Tone/fromContext.ts +8 -8
- package/Tone/index.test.ts +9 -9
- package/Tone/index.ts +21 -13
- package/Tone/signal/SyncedSignal.ts +2 -1
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/core/clock/Transport.d.ts +18 -18
- package/build/esm/core/clock/Transport.js +18 -18
- package/build/esm/core/clock/Transport.js.map +1 -1
- package/build/esm/core/clock/TransportEvent.d.ts +2 -2
- package/build/esm/core/clock/TransportEvent.js +1 -1
- package/build/esm/core/clock/TransportRepeatEvent.d.ts +1 -1
- package/build/esm/core/context/BaseContext.d.ts +4 -4
- package/build/esm/core/context/Context.d.ts +4 -4
- package/build/esm/core/context/Destination.d.ts +1 -1
- package/build/esm/core/context/Destination.js +4 -4
- package/build/esm/core/context/Destination.js.map +1 -1
- package/build/esm/core/context/DummyContext.d.ts +4 -4
- package/build/esm/core/context/Listener.d.ts +1 -1
- package/build/esm/core/context/Listener.js +2 -2
- package/build/esm/core/context/Listener.js.map +1 -1
- package/build/esm/core/context/ToneWithContext.d.ts +1 -3
- package/build/esm/core/context/ToneWithContext.js +1 -3
- package/build/esm/core/context/ToneWithContext.js.map +1 -1
- package/build/esm/core/util/Draw.d.ts +1 -1
- package/build/esm/core/util/Draw.js +2 -2
- package/build/esm/core/util/Draw.js.map +1 -1
- package/build/esm/core/util/IntervalTimeline.d.ts +1 -0
- package/build/esm/core/util/IntervalTimeline.js +1 -0
- package/build/esm/core/util/IntervalTimeline.js.map +1 -1
- package/build/esm/core/util/StateTimeline.d.ts +1 -0
- package/build/esm/core/util/StateTimeline.js +1 -0
- package/build/esm/core/util/StateTimeline.js.map +1 -1
- package/build/esm/core/util/Timeline.d.ts +1 -0
- package/build/esm/core/util/Timeline.js +1 -0
- package/build/esm/core/util/Timeline.js.map +1 -1
- package/build/esm/fromContext.d.ts +8 -8
- package/build/esm/index.d.ts +26 -18
- package/build/esm/index.js +17 -9
- package/build/esm/index.js.map +1 -1
- package/build/esm/signal/SyncedSignal.d.ts +2 -1
- package/build/esm/signal/SyncedSignal.js +2 -1
- package/build/esm/signal/SyncedSignal.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -79,15 +79,15 @@ type TransportCallback = (time: Seconds) => void;
|
|
|
79
79
|
* @example
|
|
80
80
|
* const osc = new Tone.Oscillator().toDestination();
|
|
81
81
|
* // repeated event every 8th note
|
|
82
|
-
* Tone.
|
|
82
|
+
* Tone.getTransport().scheduleRepeat((time) => {
|
|
83
83
|
* // use the callback time to schedule events
|
|
84
84
|
* osc.start(time).stop(time + 0.1);
|
|
85
85
|
* }, "8n");
|
|
86
86
|
* // transport must be started before it starts invoking events
|
|
87
|
-
* Tone.
|
|
87
|
+
* Tone.getTransport().start();
|
|
88
88
|
* @category Core
|
|
89
89
|
*/
|
|
90
|
-
export class
|
|
90
|
+
export class TransportClass
|
|
91
91
|
extends ToneWithContext<TransportOptions>
|
|
92
92
|
implements Emitter<TransportEventNames> {
|
|
93
93
|
readonly name: string = "Transport";
|
|
@@ -130,14 +130,14 @@ export class Transport
|
|
|
130
130
|
* The Beats Per Minute of the Transport.
|
|
131
131
|
* @example
|
|
132
132
|
* const osc = new Tone.Oscillator().toDestination();
|
|
133
|
-
* Tone.
|
|
133
|
+
* Tone.getTransport().bpm.value = 80;
|
|
134
134
|
* // start/stop the oscillator every quarter note
|
|
135
|
-
* Tone.
|
|
135
|
+
* Tone.getTransport().scheduleRepeat(time => {
|
|
136
136
|
* osc.start(time).stop(time + 0.1);
|
|
137
137
|
* }, "4n");
|
|
138
|
-
* Tone.
|
|
138
|
+
* Tone.getTransport().start();
|
|
139
139
|
* // ramp the bpm to 120 over 10 seconds
|
|
140
|
-
* Tone.
|
|
140
|
+
* Tone.getTransport().bpm.rampTo(120, 10);
|
|
141
141
|
*/
|
|
142
142
|
bpm: TickParam<"bpm">;
|
|
143
143
|
|
|
@@ -187,9 +187,9 @@ export class Transport
|
|
|
187
187
|
|
|
188
188
|
constructor(options?: Partial<TransportOptions>);
|
|
189
189
|
constructor() {
|
|
190
|
-
super(optionsFromArguments(
|
|
190
|
+
super(optionsFromArguments(TransportClass.getDefaults(), arguments));
|
|
191
191
|
const options = optionsFromArguments(
|
|
192
|
-
|
|
192
|
+
TransportClass.getDefaults(),
|
|
193
193
|
arguments
|
|
194
194
|
);
|
|
195
195
|
|
|
@@ -280,7 +280,7 @@ export class Transport
|
|
|
280
280
|
* @return The id of the event which can be used for canceling the event.
|
|
281
281
|
* @example
|
|
282
282
|
* // schedule an event on the 16th measure
|
|
283
|
-
* Tone.
|
|
283
|
+
* Tone.getTransport().schedule((time) => {
|
|
284
284
|
* // invoked on measure 16
|
|
285
285
|
* console.log("measure 16!");
|
|
286
286
|
* }, "16:0:0");
|
|
@@ -308,7 +308,7 @@ export class Transport
|
|
|
308
308
|
* @example
|
|
309
309
|
* const osc = new Tone.Oscillator().toDestination().start();
|
|
310
310
|
* // a callback invoked every eighth note after the first measure
|
|
311
|
-
* Tone.
|
|
311
|
+
* Tone.getTransport().scheduleRepeat((time) => {
|
|
312
312
|
* osc.start(time).stop(time + 0.1);
|
|
313
313
|
* }, "8n", "1m");
|
|
314
314
|
*/
|
|
@@ -427,7 +427,7 @@ export class Transport
|
|
|
427
427
|
* @param offset The timeline offset to start the transport.
|
|
428
428
|
* @example
|
|
429
429
|
* // start the transport in one second starting at beginning of the 5th measure.
|
|
430
|
-
* Tone.
|
|
430
|
+
* Tone.getTransport().start("+1", "4:0:0");
|
|
431
431
|
*/
|
|
432
432
|
start(time?: Time, offset?: TransportTime): this {
|
|
433
433
|
// start the context
|
|
@@ -445,7 +445,7 @@ export class Transport
|
|
|
445
445
|
* Stop the transport and all sources synced to the transport.
|
|
446
446
|
* @param time The time when the transport should stop.
|
|
447
447
|
* @example
|
|
448
|
-
* Tone.
|
|
448
|
+
* Tone.getTransport().stop();
|
|
449
449
|
*/
|
|
450
450
|
stop(time?: Time): this {
|
|
451
451
|
this._clock.stop(time);
|
|
@@ -484,11 +484,11 @@ export class Transport
|
|
|
484
484
|
* For example 4/4 would be just 4 and 6/8 would be 3.
|
|
485
485
|
* @example
|
|
486
486
|
* // common time
|
|
487
|
-
* Tone.
|
|
487
|
+
* Tone.getTransport().timeSignature = 4;
|
|
488
488
|
* // 7/8
|
|
489
|
-
* Tone.
|
|
489
|
+
* Tone.getTransport().timeSignature = [7, 8];
|
|
490
490
|
* // this will be reduced to a single number
|
|
491
|
-
* Tone.
|
|
491
|
+
* Tone.getTransport().timeSignature; // returns 3.5
|
|
492
492
|
*/
|
|
493
493
|
get timeSignature(): TimeSignature {
|
|
494
494
|
return this._timeSignature;
|
|
@@ -534,8 +534,8 @@ export class Transport
|
|
|
534
534
|
* Set the loop start and stop at the same time.
|
|
535
535
|
* @example
|
|
536
536
|
* // loop over the first measure
|
|
537
|
-
* Tone.
|
|
538
|
-
* Tone.
|
|
537
|
+
* Tone.getTransport().setLoopPoints(0, "1m");
|
|
538
|
+
* Tone.getTransport().loop = true;
|
|
539
539
|
*/
|
|
540
540
|
setLoopPoints(
|
|
541
541
|
startPosition: TransportTime,
|
|
@@ -682,8 +682,8 @@ export class Transport
|
|
|
682
682
|
* @return The context time of the next subdivision.
|
|
683
683
|
* @example
|
|
684
684
|
* // the transport must be started, otherwise returns 0
|
|
685
|
-
* Tone.
|
|
686
|
-
* Tone.
|
|
685
|
+
* Tone.getTransport().start();
|
|
686
|
+
* Tone.getTransport().nextSubdivision("4n");
|
|
687
687
|
*/
|
|
688
688
|
nextSubdivision(subdivision?: Time): Seconds {
|
|
689
689
|
subdivision = this.toTicks(subdivision);
|
|
@@ -801,14 +801,14 @@ export class Transport
|
|
|
801
801
|
emit!: (event: any, ...args: any[]) => this;
|
|
802
802
|
}
|
|
803
803
|
|
|
804
|
-
Emitter.mixin(
|
|
804
|
+
Emitter.mixin(TransportClass);
|
|
805
805
|
|
|
806
806
|
//-------------------------------------
|
|
807
807
|
// INITIALIZATION
|
|
808
808
|
//-------------------------------------
|
|
809
809
|
|
|
810
810
|
onContextInit((context) => {
|
|
811
|
-
context.transport = new
|
|
811
|
+
context.transport = new TransportClass({ context });
|
|
812
812
|
});
|
|
813
813
|
|
|
814
814
|
onContextClose((context) => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
2
|
import { Offline } from "test/helper/Offline";
|
|
3
|
-
import {
|
|
3
|
+
import { TransportClass } from "./Transport";
|
|
4
4
|
import { TransportEvent } from "./TransportEvent";
|
|
5
5
|
|
|
6
6
|
describe("TransportEvent", () => {
|
|
7
7
|
|
|
8
8
|
it("can be created and disposed", () => {
|
|
9
9
|
return Offline((context) => {
|
|
10
|
-
const transport = new
|
|
10
|
+
const transport = new TransportClass({ context });
|
|
11
11
|
const event = new TransportEvent(transport, {
|
|
12
12
|
time: 0,
|
|
13
13
|
});
|
|
@@ -17,7 +17,7 @@ describe("TransportEvent", () => {
|
|
|
17
17
|
|
|
18
18
|
it("has a unique id", () => {
|
|
19
19
|
return Offline((context) => {
|
|
20
|
-
const transport = new
|
|
20
|
+
const transport = new TransportClass({ context });
|
|
21
21
|
const event = new TransportEvent(transport, {
|
|
22
22
|
time: 0,
|
|
23
23
|
});
|
|
@@ -29,7 +29,7 @@ describe("TransportEvent", () => {
|
|
|
29
29
|
it("can invoke the callback", () => {
|
|
30
30
|
let wasInvoked = false;
|
|
31
31
|
return Offline((context) => {
|
|
32
|
-
const transport = new
|
|
32
|
+
const transport = new TransportClass({ context });
|
|
33
33
|
const event = new TransportEvent(transport, {
|
|
34
34
|
callback: (time) => {
|
|
35
35
|
expect(time).to.equal(100);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Seconds, Ticks } from "../type/Units";
|
|
2
2
|
import { noOp } from "../util/Interface";
|
|
3
3
|
|
|
4
|
-
type Transport = import("../clock/Transport").
|
|
4
|
+
type Transport = import("../clock/Transport").TransportClass;
|
|
5
5
|
|
|
6
6
|
export interface TransportEventOptions {
|
|
7
7
|
callback: (time: number) => void;
|
|
@@ -10,7 +10,7 @@ export interface TransportEventOptions {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* TransportEvent is an internal class used by [[
|
|
13
|
+
* TransportEvent is an internal class used by [[TransportClass]]
|
|
14
14
|
* to schedule events. Do no invoke this class directly, it is
|
|
15
15
|
* handled from within Tone.Transport.
|
|
16
16
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
2
|
import { Offline } from "test/helper/Offline";
|
|
3
|
-
import {
|
|
3
|
+
import { TransportClass } from "./Transport";
|
|
4
4
|
import { TransportRepeatEvent } from "./TransportRepeatEvent";
|
|
5
5
|
|
|
6
6
|
describe("TransportRepeatEvent", () => {
|
|
7
7
|
|
|
8
8
|
it("can be created and disposed", () => {
|
|
9
9
|
return Offline((context) => {
|
|
10
|
-
const transport = new
|
|
10
|
+
const transport = new TransportClass({ context });
|
|
11
11
|
const event = new TransportRepeatEvent(transport, {
|
|
12
12
|
duration: 100,
|
|
13
13
|
interval: 4,
|
|
@@ -19,7 +19,7 @@ describe("TransportRepeatEvent", () => {
|
|
|
19
19
|
|
|
20
20
|
it("generates a unique event ID", () => {
|
|
21
21
|
return Offline((context) => {
|
|
22
|
-
const transport = new
|
|
22
|
+
const transport = new TransportClass({ context });
|
|
23
23
|
const event = new TransportRepeatEvent(transport, {
|
|
24
24
|
time: 0,
|
|
25
25
|
});
|
|
@@ -30,7 +30,7 @@ describe("TransportRepeatEvent", () => {
|
|
|
30
30
|
|
|
31
31
|
it("is removed from the Transport when disposed", () => {
|
|
32
32
|
return Offline((context) => {
|
|
33
|
-
const transport = new
|
|
33
|
+
const transport = new TransportClass({ context });
|
|
34
34
|
const event = new TransportRepeatEvent(transport, {
|
|
35
35
|
time: 0,
|
|
36
36
|
});
|
|
@@ -4,7 +4,7 @@ import { Seconds, Ticks, Time } from "../type/Units";
|
|
|
4
4
|
import { TransportEvent, TransportEventOptions } from "./TransportEvent";
|
|
5
5
|
import { GT, LT } from "../util/Math";
|
|
6
6
|
|
|
7
|
-
type Transport = import("../clock/Transport").
|
|
7
|
+
type Transport = import("../clock/Transport").TransportClass;
|
|
8
8
|
|
|
9
9
|
interface TransportRepeatEventOptions extends TransportEventOptions {
|
|
10
10
|
interval: Ticks;
|
|
@@ -2,10 +2,10 @@ import { Seconds } from "../type/Units";
|
|
|
2
2
|
import { Emitter } from "../util/Emitter";
|
|
3
3
|
import { AnyAudioContext } from "./AudioContext";
|
|
4
4
|
|
|
5
|
-
type Draw = import("../util/Draw").
|
|
6
|
-
type Destination = import("./Destination").
|
|
7
|
-
type Transport = import("../clock/Transport").
|
|
8
|
-
type Listener = import("./Listener").
|
|
5
|
+
type Draw = import("../util/Draw").DrawClass;
|
|
6
|
+
type Destination = import("./Destination").DestinationClass;
|
|
7
|
+
type Transport = import("../clock/Transport").TransportClass;
|
|
8
|
+
type Listener = import("./Listener").ListenerClass;
|
|
9
9
|
|
|
10
10
|
// these are either not used in Tone.js or deprecated and not implemented.
|
|
11
11
|
export type ExcludedFromBaseAudioContext =
|
|
@@ -2,13 +2,13 @@ import { expect } from "chai";
|
|
|
2
2
|
import { ConstantOutput } from "test/helper/ConstantOutput";
|
|
3
3
|
import { Offline } from "test/helper/Offline";
|
|
4
4
|
import { ONLINE_TESTING } from "test/helper/Supports";
|
|
5
|
-
import {
|
|
5
|
+
import { TransportClass } from "../clock/Transport";
|
|
6
6
|
import { getContext } from "../Global";
|
|
7
7
|
import { createAudioContext } from "./AudioContext";
|
|
8
8
|
import { Context } from "./Context";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { DestinationClass } from "./Destination";
|
|
10
|
+
import { ListenerClass } from "./Listener";
|
|
11
|
+
import { DrawClass } from "../util/Draw";
|
|
12
12
|
import { connect } from "./ToneAudioNode";
|
|
13
13
|
|
|
14
14
|
describe("Context", () => {
|
|
@@ -19,9 +19,9 @@ describe("Context", () => {
|
|
|
19
19
|
const ctxDraw = context.draw;
|
|
20
20
|
const ctxTransport = context.transport;
|
|
21
21
|
const ctxListener = context.listener;
|
|
22
|
-
expect(context.destination).is.instanceOf(
|
|
23
|
-
expect(context.draw).is.instanceOf(
|
|
24
|
-
expect(context.listener).is.instanceOf(
|
|
22
|
+
expect(context.destination).is.instanceOf(DestinationClass);
|
|
23
|
+
expect(context.draw).is.instanceOf(DrawClass);
|
|
24
|
+
expect(context.listener).is.instanceOf(ListenerClass);
|
|
25
25
|
await context.close();
|
|
26
26
|
expect(ctxDest.disposed).to.be.true;
|
|
27
27
|
expect(ctxDraw.disposed).to.be.true;
|
|
@@ -218,7 +218,7 @@ describe("Context", () => {
|
|
|
218
218
|
|
|
219
219
|
it("is invoked in the offline context", () => {
|
|
220
220
|
return Offline((context) => {
|
|
221
|
-
const transport = new
|
|
221
|
+
const transport = new TransportClass({ context });
|
|
222
222
|
transport.context.setTimeout(() => {
|
|
223
223
|
expect(transport.now()).to.be.closeTo(0.01, 0.005);
|
|
224
224
|
}, 0.01);
|
|
@@ -13,10 +13,10 @@ import { closeContext, initializeContext } from "./ContextInitialization";
|
|
|
13
13
|
import { BaseContext, ContextLatencyHint } from "./BaseContext";
|
|
14
14
|
import { assert } from "../util/Debug";
|
|
15
15
|
|
|
16
|
-
type Transport = import("../clock/Transport").
|
|
17
|
-
type Destination = import("./Destination").
|
|
18
|
-
type Listener = import("./Listener").
|
|
19
|
-
type Draw = import("../util/Draw").
|
|
16
|
+
type Transport = import("../clock/Transport").TransportClass;
|
|
17
|
+
type Destination = import("./Destination").DestinationClass;
|
|
18
|
+
type Listener = import("./Listener").ListenerClass;
|
|
19
|
+
type Draw = import("../util/Draw").DrawClass;
|
|
20
20
|
|
|
21
21
|
export interface ContextOptions {
|
|
22
22
|
clockSource: TickerClockSource;
|
|
@@ -4,12 +4,12 @@ import { Offline } from "test/helper/Offline";
|
|
|
4
4
|
import { PassAudio } from "test/helper/PassAudio";
|
|
5
5
|
import { Oscillator } from "Tone/source/oscillator/Oscillator";
|
|
6
6
|
import { getContext } from "../Global";
|
|
7
|
-
import {
|
|
7
|
+
import { DestinationClass } from "./Destination";
|
|
8
8
|
|
|
9
9
|
describe("Destination", () => {
|
|
10
10
|
|
|
11
11
|
it("creates itself on the context", () => {
|
|
12
|
-
expect(getContext().destination).instanceOf(
|
|
12
|
+
expect(getContext().destination).instanceOf(DestinationClass);
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
it("can be muted and unmuted", () => {
|
|
@@ -26,7 +26,7 @@ interface DestinationOptions extends ToneAudioNodeOptions {
|
|
|
26
26
|
* oscillator.toDestination();
|
|
27
27
|
* @category Core
|
|
28
28
|
*/
|
|
29
|
-
export class
|
|
29
|
+
export class DestinationClass extends ToneAudioNode<DestinationOptions> {
|
|
30
30
|
|
|
31
31
|
readonly name: string = "Destination";
|
|
32
32
|
|
|
@@ -46,8 +46,8 @@ export class Destination extends ToneAudioNode<DestinationOptions> {
|
|
|
46
46
|
constructor(options: Partial<DestinationOptions>);
|
|
47
47
|
constructor() {
|
|
48
48
|
|
|
49
|
-
super(optionsFromArguments(
|
|
50
|
-
const options = optionsFromArguments(
|
|
49
|
+
super(optionsFromArguments(DestinationClass.getDefaults(), arguments));
|
|
50
|
+
const options = optionsFromArguments(DestinationClass.getDefaults(), arguments);
|
|
51
51
|
|
|
52
52
|
connectSeries(this.input, this.output, this.context.rawContext.destination);
|
|
53
53
|
|
|
@@ -120,7 +120,7 @@ export class Destination extends ToneAudioNode<DestinationOptions> {
|
|
|
120
120
|
//-------------------------------------
|
|
121
121
|
|
|
122
122
|
onContextInit(context => {
|
|
123
|
-
context.destination = new
|
|
123
|
+
context.destination = new DestinationClass({ context });
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
onContextClose(context => {
|
|
@@ -2,10 +2,10 @@ import { BaseContext } from "./BaseContext";
|
|
|
2
2
|
import { Seconds } from "../type/Units";
|
|
3
3
|
import { AnyAudioContext } from "./AudioContext";
|
|
4
4
|
|
|
5
|
-
type Draw = import("../util/Draw").
|
|
6
|
-
type Destination = import("./Destination").
|
|
7
|
-
type Transport = import("../clock/Transport").
|
|
8
|
-
type Listener = import("./Listener").
|
|
5
|
+
type Draw = import("../util/Draw").DrawClass;
|
|
6
|
+
type Destination = import("./Destination").DestinationClass;
|
|
7
|
+
type Transport = import("../clock/Transport").TransportClass;
|
|
8
|
+
type Listener = import("./Listener").ListenerClass;
|
|
9
9
|
|
|
10
10
|
export class DummyContext extends BaseContext {
|
|
11
11
|
//---------------------------
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
2
|
import { Offline } from "test/helper/Offline";
|
|
3
3
|
import { getContext } from "../Global";
|
|
4
|
-
import {
|
|
4
|
+
import { ListenerClass } from "./Listener";
|
|
5
5
|
|
|
6
6
|
describe("Listener", () => {
|
|
7
7
|
|
|
8
8
|
it("creates itself on the context", () => {
|
|
9
|
-
expect(getContext().listener).instanceOf(
|
|
9
|
+
expect(getContext().listener).instanceOf(ListenerClass);
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
it("can get and set values as an object", () => {
|
|
@@ -20,7 +20,7 @@ export interface ListenerOptions extends ToneAudioNodeOptions{
|
|
|
20
20
|
* to place sounds in 3D and Listener allows you to navigate the 3D sound environment from
|
|
21
21
|
* a first-person perspective. There is only one listener per audio context.
|
|
22
22
|
*/
|
|
23
|
-
export class
|
|
23
|
+
export class ListenerClass extends ToneAudioNode<ListenerOptions> {
|
|
24
24
|
|
|
25
25
|
readonly name: string = "Listener";
|
|
26
26
|
|
|
@@ -109,7 +109,7 @@ export class Listener extends ToneAudioNode<ListenerOptions> {
|
|
|
109
109
|
//-------------------------------------
|
|
110
110
|
|
|
111
111
|
onContextInit(context => {
|
|
112
|
-
context.listener = new
|
|
112
|
+
context.listener = new ListenerClass({ context });
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
onContextClose(context => {
|
|
@@ -79,8 +79,6 @@ export abstract class ToneWithContext<Options extends ToneWithContextOptions> ex
|
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* The duration in seconds of one sample.
|
|
82
|
-
* @example
|
|
83
|
-
* console.log(Tone.Transport.sampleTime);
|
|
84
82
|
*/
|
|
85
83
|
get sampleTime(): Seconds {
|
|
86
84
|
return 1 / this.context.sampleRate;
|
|
@@ -97,7 +95,7 @@ export abstract class ToneWithContext<Options extends ToneWithContextOptions> ex
|
|
|
97
95
|
|
|
98
96
|
/**
|
|
99
97
|
* Convert the incoming time to seconds.
|
|
100
|
-
* This is calculated against the current [[
|
|
98
|
+
* This is calculated against the current [[TransportClass]] bpm
|
|
101
99
|
* @example
|
|
102
100
|
* const gain = new Tone.Gain();
|
|
103
101
|
* setInterval(() => console.log(gain.toSeconds("4n")), 100);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
2
|
import { ONLINE_TESTING } from "test/helper/Supports";
|
|
3
|
-
import {
|
|
3
|
+
import { DrawClass } from "./Draw";
|
|
4
4
|
|
|
5
5
|
describe("Draw", () => {
|
|
6
6
|
|
|
7
7
|
if (ONLINE_TESTING) {
|
|
8
8
|
|
|
9
|
-
const draw = new
|
|
9
|
+
const draw = new DrawClass();
|
|
10
10
|
|
|
11
11
|
after(() => {
|
|
12
12
|
draw.dispose();
|
package/Tone/core/util/Draw.ts
CHANGED
|
@@ -25,7 +25,7 @@ interface DrawEvent extends TimelineEvent {
|
|
|
25
25
|
* Tone.Transport.start();
|
|
26
26
|
* @category Core
|
|
27
27
|
*/
|
|
28
|
-
export class
|
|
28
|
+
export class DrawClass extends ToneWithContext<ToneWithContextOptions> {
|
|
29
29
|
|
|
30
30
|
readonly name: string = "Draw";
|
|
31
31
|
|
|
@@ -117,7 +117,7 @@ export class Draw extends ToneWithContext<ToneWithContextOptions> {
|
|
|
117
117
|
//-------------------------------------
|
|
118
118
|
|
|
119
119
|
onContextInit(context => {
|
|
120
|
-
context.draw = new
|
|
120
|
+
context.draw = new DrawClass({ context });
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
onContextClose(context => {
|
|
@@ -20,6 +20,7 @@ type IteratorCallback = (event: IntervalTimelineEvent) => void;
|
|
|
20
20
|
* for querying an intersection point with the timeline
|
|
21
21
|
* events. Internally uses an [Interval Tree](https://en.wikipedia.org/wiki/Interval_tree)
|
|
22
22
|
* to represent the data.
|
|
23
|
+
* @internal
|
|
23
24
|
*/
|
|
24
25
|
export class IntervalTimeline extends Tone {
|
|
25
26
|
|
|
@@ -12,6 +12,7 @@ export interface StateTimelineEvent extends TimelineEvent {
|
|
|
12
12
|
/**
|
|
13
13
|
* A Timeline State. Provides the methods: `setStateAtTime("state", time)` and `getValueAtTime(time)`
|
|
14
14
|
* @param initial The initial state of the StateTimeline. Defaults to `undefined`
|
|
15
|
+
* @internal
|
|
15
16
|
*/
|
|
16
17
|
export class StateTimeline<AdditionalOptions extends Record<string, any> = Record<string, any>> extends Timeline<StateTimelineEvent & AdditionalOptions> {
|
|
17
18
|
|
|
@@ -26,6 +26,7 @@ export interface TimelineEvent {
|
|
|
26
26
|
* along a timeline. All events must have a "time" property.
|
|
27
27
|
* Internally, events are stored in time order for fast
|
|
28
28
|
* retrieval.
|
|
29
|
+
* @internal
|
|
29
30
|
*/
|
|
30
31
|
export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
|
|
31
32
|
|
package/Tone/fromContext.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as Classes from "./classes";
|
|
2
|
-
import {
|
|
2
|
+
import { TransportClass } from "./core/clock/Transport";
|
|
3
3
|
import { Context } from "./core/context/Context";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { ListenerClass } from "./core/context/Listener";
|
|
5
|
+
import { DestinationClass } from "./core/context/Destination";
|
|
6
6
|
import { FrequencyClass } from "./core/type/Frequency";
|
|
7
7
|
import { MidiClass } from "./core/type/Midi";
|
|
8
8
|
import { TicksClass } from "./core/type/Ticks";
|
|
@@ -10,7 +10,7 @@ import { TimeClass } from "./core/type/Time";
|
|
|
10
10
|
import { TransportTimeClass } from "./core/type/TransportTime";
|
|
11
11
|
import { isDefined, isFunction } from "./core/util/TypeCheck";
|
|
12
12
|
import { omitFromObject } from "./core/util/Defaults";
|
|
13
|
-
import {
|
|
13
|
+
import { DrawClass } from "./core/util/Draw";
|
|
14
14
|
|
|
15
15
|
type ClassesWithoutSingletons = Omit<typeof Classes, "Transport" | "Destination" | "Draw">;
|
|
16
16
|
|
|
@@ -19,10 +19,10 @@ type ClassesWithoutSingletons = Omit<typeof Classes, "Transport" | "Destination"
|
|
|
19
19
|
* to the same context and contains a singleton Transport and Destination node.
|
|
20
20
|
*/
|
|
21
21
|
type ToneObject = {
|
|
22
|
-
Transport:
|
|
23
|
-
Destination:
|
|
24
|
-
Listener:
|
|
25
|
-
Draw:
|
|
22
|
+
Transport: TransportClass;
|
|
23
|
+
Destination: DestinationClass;
|
|
24
|
+
Listener: ListenerClass;
|
|
25
|
+
Draw: DrawClass;
|
|
26
26
|
context: Context;
|
|
27
27
|
now: () => number;
|
|
28
28
|
immediate: () => number;
|
package/Tone/index.test.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as Tone from "./index";
|
|
2
2
|
import { expect } from "chai";
|
|
3
|
-
import {
|
|
3
|
+
import { DestinationClass } from "./core/context/Destination";
|
|
4
4
|
import { Context } from "./core/context/Context";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { TransportClass } from "./core/clock/Transport";
|
|
6
|
+
import { DrawClass } from "./core/util/Draw";
|
|
7
7
|
|
|
8
8
|
describe("Tone", () => {
|
|
9
9
|
|
|
@@ -15,16 +15,16 @@ describe("Tone", () => {
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it("exports the global singletons", () => {
|
|
18
|
-
expect(Tone.Destination).to.be.an.instanceOf(
|
|
19
|
-
expect(Tone.Draw).to.be.an.instanceOf(
|
|
20
|
-
expect(Tone.Transport).to.be.an.instanceOf(
|
|
18
|
+
expect(Tone.Destination).to.be.an.instanceOf(DestinationClass);
|
|
19
|
+
expect(Tone.Draw).to.be.an.instanceOf(DrawClass);
|
|
20
|
+
expect(Tone.Transport).to.be.an.instanceOf(TransportClass);
|
|
21
21
|
expect(Tone.context).to.be.an.instanceOf(Context);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
it("exports the global singleton getters", () => {
|
|
25
|
-
expect(Tone.getDestination()).to.be.an.instanceOf(
|
|
26
|
-
expect(Tone.getDraw()).to.be.an.instanceOf(
|
|
27
|
-
expect(Tone.getTransport()).to.be.an.instanceOf(
|
|
25
|
+
expect(Tone.getDestination()).to.be.an.instanceOf(DestinationClass);
|
|
26
|
+
expect(Tone.getDraw()).to.be.an.instanceOf(DrawClass);
|
|
27
|
+
expect(Tone.getTransport()).to.be.an.instanceOf(TransportClass);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
it("can start the global context", () => {
|
package/Tone/index.ts
CHANGED
|
@@ -27,75 +27,80 @@ export function immediate(): Seconds {
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* The Transport object belonging to the global Tone.js Context.
|
|
30
|
-
* See [[
|
|
30
|
+
* See [[TransportClass]]
|
|
31
31
|
* @category Core
|
|
32
|
+
* @deprecated Use {@link getTransport} instead
|
|
32
33
|
*/
|
|
33
34
|
export const Transport = getContext().transport;
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* The Transport object belonging to the global Tone.js Context.
|
|
37
|
-
* See [[
|
|
38
|
+
* See [[TransportClass]]
|
|
38
39
|
* @category Core
|
|
39
40
|
*/
|
|
40
|
-
export function getTransport(): import("./core/clock/Transport").
|
|
41
|
+
export function getTransport(): import("./core/clock/Transport").TransportClass {
|
|
41
42
|
return getContext().transport;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* The Destination (output) belonging to the global Tone.js Context.
|
|
46
|
-
* See [[
|
|
47
|
+
* See [[DestinationClass]]
|
|
47
48
|
* @category Core
|
|
49
|
+
* @deprecated Use {@link getDestination} instead
|
|
48
50
|
*/
|
|
49
51
|
export const Destination = getContext().destination;
|
|
50
52
|
|
|
51
53
|
/**
|
|
52
|
-
* @deprecated Use
|
|
54
|
+
* @deprecated Use {@link getDestination} instead
|
|
53
55
|
*/
|
|
54
56
|
export const Master = getContext().destination;
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
59
|
* The Destination (output) belonging to the global Tone.js Context.
|
|
58
|
-
* See [[
|
|
60
|
+
* See [[DestinationClass]]
|
|
59
61
|
* @category Core
|
|
60
62
|
*/
|
|
61
|
-
export function getDestination(): import("./core/context/Destination").
|
|
63
|
+
export function getDestination(): import("./core/context/Destination").DestinationClass {
|
|
62
64
|
return getContext().destination;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
/**
|
|
66
|
-
* The [[
|
|
68
|
+
* The [[ListenerClass]] belonging to the global Tone.js Context.
|
|
67
69
|
* @category Core
|
|
70
|
+
* @deprecated Use {@link getListener} instead
|
|
68
71
|
*/
|
|
69
72
|
export const Listener = getContext().listener;
|
|
70
73
|
|
|
71
74
|
/**
|
|
72
|
-
* The [[
|
|
75
|
+
* The [[ListenerClass]] belonging to the global Tone.js Context.
|
|
73
76
|
* @category Core
|
|
74
77
|
*/
|
|
75
|
-
export function getListener(): import("./core/context/Listener").
|
|
78
|
+
export function getListener(): import("./core/context/Listener").ListenerClass {
|
|
76
79
|
return getContext().listener;
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
/**
|
|
80
83
|
* Draw is used to synchronize the draw frame with the Transport's callbacks.
|
|
81
|
-
* See [[
|
|
84
|
+
* See [[DrawClass]]
|
|
82
85
|
* @category Core
|
|
86
|
+
* @deprecated Use {@link getDraw} instead
|
|
83
87
|
*/
|
|
84
88
|
export const Draw = getContext().draw;
|
|
85
89
|
|
|
86
90
|
/**
|
|
87
91
|
* Get the singleton attached to the global context.
|
|
88
92
|
* Draw is used to synchronize the draw frame with the Transport's callbacks.
|
|
89
|
-
* See [[
|
|
93
|
+
* See [[DrawClass]]
|
|
90
94
|
* @category Core
|
|
91
95
|
*/
|
|
92
|
-
export function getDraw(): import("./core/util/Draw").
|
|
96
|
+
export function getDraw(): import("./core/util/Draw").DrawClass {
|
|
93
97
|
return getContext().draw;
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
/**
|
|
97
101
|
* A reference to the global context
|
|
98
102
|
* See [[Context]]
|
|
103
|
+
* @deprecated Use {@link getContext} instead
|
|
99
104
|
*/
|
|
100
105
|
export const context = getContext();
|
|
101
106
|
|
|
@@ -111,6 +116,9 @@ export function loaded() {
|
|
|
111
116
|
// this fills in name changes from 13.x to 14.x
|
|
112
117
|
import { ToneAudioBuffers } from "./core/context/ToneAudioBuffers";
|
|
113
118
|
import { ToneBufferSource } from "./source/buffer/ToneBufferSource";
|
|
119
|
+
/** @deprecated Use {@link ToneAudioBuffer} */
|
|
114
120
|
export const Buffer: typeof ToneAudioBuffer = ToneAudioBuffer;
|
|
121
|
+
/** @deprecated Use {@link ToneAudioBuffers} */
|
|
115
122
|
export const Buffers: typeof ToneAudioBuffers = ToneAudioBuffers;
|
|
123
|
+
/** @deprecated Use {@link ToneBufferSource} */
|
|
116
124
|
export const BufferSource: typeof ToneBufferSource = ToneBufferSource;
|