tone 15.3.3 → 15.3.4
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/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/util/Debug.ts +1 -1
- package/Tone/core/util/Emitter.ts +0 -1
- package/Tone/source/Source.ts +0 -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 +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/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/source/Source.js +0 -1
- package/build/esm/source/Source.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
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";
|
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
|
package/Tone/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version: string = "15.3.
|
|
1
|
+
export const version: string = "15.3.4";
|