mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
Clock.start with undefined arg is scheduled into the future
if there is no argument passed into the first argument of Clock.start / Transport.start, the currentTime + Clock’s lookAhead time will be used as the start time.
This commit is contained in:
parent
f685bcd5ae
commit
8911dce68a
8 changed files with 24 additions and 20 deletions
|
@ -115,7 +115,11 @@ define(["Tone/core/Tone", "Tone/signal/TimelineSignal", "Tone/core/TimelineState
|
|||
* @return {Tone.Clock} this
|
||||
*/
|
||||
Tone.Clock.prototype.start = function(time, offset){
|
||||
time = this.toSeconds(time);
|
||||
if (this.isUndef(time)){
|
||||
time = this.toSeconds(time) + Tone.Clock.lookAhead;
|
||||
} else {
|
||||
time = this.toSeconds(time);
|
||||
}
|
||||
if (this._state.getStateAtTime(time) !== Tone.State.Started){
|
||||
this._state.addEvent({
|
||||
"state" : Tone.State.Started,
|
||||
|
|
|
@ -54,7 +54,7 @@ define(["Test", "Tone/core/Clock", "helper/Offline2"], function (Test, Clock, Of
|
|||
Offline(function(output, testFn, tearDown){
|
||||
var clock = new Clock();
|
||||
expect(clock.state).to.equal("stopped");
|
||||
clock.start().stop(0.5);
|
||||
clock.start(0).stop(0.5);
|
||||
expect(clock.state).to.equal("started");
|
||||
|
||||
tearDown(function(){
|
||||
|
@ -69,7 +69,7 @@ define(["Test", "Tone/core/Clock", "helper/Offline2"], function (Test, Clock, Of
|
|||
Offline(function(output, testFn, tearDown){
|
||||
var clock = new Clock();
|
||||
expect(clock.state).to.equal("stopped");
|
||||
clock.start().pause(0.2).stop(0.4);
|
||||
clock.start(0).pause(0.2).stop(0.4);
|
||||
expect(clock.state).to.equal("started");
|
||||
|
||||
testFn(function(sample, time){
|
||||
|
@ -115,7 +115,7 @@ define(["Test", "Tone/core/Clock", "helper/Offline2"], function (Test, Clock, Of
|
|||
Offline(function(output, testFn, tearDown){
|
||||
var clock = new Clock();
|
||||
expect(clock.state).to.equal("stopped");
|
||||
clock.start().pause(0.2).stop(0.4).start(0.6).stop(0.8);
|
||||
clock.start(0).pause(0.2).stop(0.4).start(0.6).stop(0.8);
|
||||
expect(clock.state).to.equal("started");
|
||||
|
||||
testFn(function(sample, time){
|
||||
|
|
|
@ -67,7 +67,7 @@ function (Test, Transport, Tone, Offline, TransportTime) {
|
|||
Tone.Transport.schedule(function(){
|
||||
invocations++;
|
||||
}, 0);
|
||||
Tone.Transport.setLoopPoints(0, "4n").start();
|
||||
Tone.Transport.setLoopPoints(0, "4n").start(0);
|
||||
Tone.Transport.loop = true;
|
||||
after(function(){
|
||||
expect(invocations).to.be.greaterThan(1);
|
||||
|
@ -137,7 +137,7 @@ function (Test, Transport, Tone, Offline, TransportTime) {
|
|||
Offline(function(dest, test, after){
|
||||
Tone.Transport.ticks = 200;
|
||||
expect(Tone.Transport.ticks).to.equal(200);
|
||||
Tone.Transport.start();
|
||||
Tone.Transport.start(0);
|
||||
after(function(){
|
||||
expect(Tone.Transport.ticks).to.at.least(200);
|
||||
Tone.Transport.stop();
|
||||
|
@ -149,7 +149,7 @@ function (Test, Transport, Tone, Offline, TransportTime) {
|
|||
it("can get the current position in BarsBeatsSixteenths", function(done){
|
||||
Offline(function(dest, test, after){
|
||||
expect(Tone.Transport.position).to.equal("0:0:0");
|
||||
Tone.Transport.start();
|
||||
Tone.Transport.start(0);
|
||||
after(function(){
|
||||
expect(Tone.Transport.position).to.not.equal("0:0:0");
|
||||
Tone.Transport.stop();
|
||||
|
@ -161,7 +161,7 @@ function (Test, Transport, Tone, Offline, TransportTime) {
|
|||
it("can get the current position in seconds", function(done){
|
||||
Offline(function(dest, test, after){
|
||||
expect(Tone.Transport.seconds).to.equal(0);
|
||||
Tone.Transport.start();
|
||||
Tone.Transport.start(0);
|
||||
test(function(sample, time){
|
||||
expect(Tone.Transport.seconds).to.be.closeTo(time, 0.05);
|
||||
});
|
||||
|
@ -235,7 +235,7 @@ function (Test, Transport, Tone, Offline, TransportTime) {
|
|||
|
||||
it("resets ticks on stop but not on pause", function(done){
|
||||
Offline(function(dest, test, after){
|
||||
Tone.Transport.start().pause(0.1).stop(0.2);
|
||||
Tone.Transport.start(0).pause(0.1).stop(0.2);
|
||||
|
||||
var pausedTicks = 0;
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ define(["helper/Basic", "Tone/event/Event", "Tone/core/Tone", "Tone/core/Transpo
|
|||
Offline(function(output, test, after){
|
||||
var note = new Event().start(0).stop(0.4);
|
||||
|
||||
Tone.Transport.start().stop(0.5).start(0.55);
|
||||
Tone.Transport.start(0).stop(0.5).start(0.55);
|
||||
|
||||
test(function(sample, time){
|
||||
if (time > 0 && time < 0.38){
|
||||
|
|
|
@ -111,14 +111,14 @@ define(["helper/Basic", "Tone/event/Loop", "Tone/core/Tone",
|
|||
});
|
||||
|
||||
it ("passes in the scheduled time to the callback", function(done){
|
||||
var now = Tone.Transport.now();
|
||||
var now = Tone.Transport.now() + 0.1;
|
||||
var loop = new Loop(function(time){
|
||||
expect(time).to.be.a.number;
|
||||
expect(time - now).to.be.closeTo(0.3, 0.01);
|
||||
loop.dispose();
|
||||
done();
|
||||
});
|
||||
Tone.Transport.start();
|
||||
Tone.Transport.start(now);
|
||||
loop.start(0.3);
|
||||
});
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ define(["helper/Basic", "Tone/event/Pattern", "Tone/core/Tone", "Tone/core/Trans
|
|||
it ("passes in the scheduled time and pattern index to the callback", function(done){
|
||||
Offline(function(output, test, after){
|
||||
|
||||
var now = Tone.Transport.now();
|
||||
var now = Tone.Transport.now() + 0.05;
|
||||
|
||||
var pattern = new Pattern(function(time, note){
|
||||
expect(time).to.be.a.number;
|
||||
|
@ -116,7 +116,7 @@ define(["helper/Basic", "Tone/event/Pattern", "Tone/core/Tone", "Tone/core/Trans
|
|||
expect(note).to.be.equal("a");
|
||||
}, ["a"], "up");
|
||||
|
||||
Tone.Transport.start();
|
||||
Tone.Transport.start(now);
|
||||
|
||||
pattern.start(0.3);
|
||||
after(function(){
|
||||
|
@ -137,7 +137,7 @@ define(["helper/Basic", "Tone/event/Pattern", "Tone/core/Tone", "Tone/core/Trans
|
|||
|
||||
pattern.interval = "16n";
|
||||
|
||||
Tone.Transport.start();
|
||||
Tone.Transport.start(0);
|
||||
after(function(){
|
||||
pattern.dispose();
|
||||
done();
|
||||
|
|
|
@ -196,7 +196,7 @@ define(["helper/Basic", "Tone/event/Sequence", "Tone/core/Tone",
|
|||
}, [0, [1, 2], [3, 4]], "16n").start();
|
||||
|
||||
seq.loop = false;
|
||||
Tone.Transport.start();
|
||||
Tone.Transport.start(0);
|
||||
|
||||
after(function(){
|
||||
seq.dispose();
|
||||
|
@ -219,7 +219,7 @@ define(["helper/Basic", "Tone/event/Sequence", "Tone/core/Tone",
|
|||
}, [0, [1, 2], [3, 4, 5]], "8n").start(0);
|
||||
|
||||
seq.loop = false;
|
||||
Tone.Transport.start();
|
||||
Tone.Transport.start(0);
|
||||
|
||||
after(function(){
|
||||
seq.dispose();
|
||||
|
@ -241,7 +241,7 @@ define(["helper/Basic", "Tone/event/Sequence", "Tone/core/Tone",
|
|||
}, [0, null, [null, 1]], "8n").start(0);
|
||||
|
||||
seq.loop = false;
|
||||
Tone.Transport.start();
|
||||
Tone.Transport.start(0);
|
||||
|
||||
after(function(){
|
||||
seq.dispose();
|
||||
|
|
|
@ -116,7 +116,7 @@ function (Test, Source, Transport, OfflineTest, Tone) {
|
|||
var source = new Source();
|
||||
source.sync().start(0);
|
||||
expect(source.state).to.equal("stopped");
|
||||
Tone.Transport.start();
|
||||
Tone.Transport.start(Tone.now());
|
||||
expect(source.state).to.equal("started");
|
||||
source.dispose();
|
||||
Tone.Transport.stop();
|
||||
|
@ -136,7 +136,7 @@ function (Test, Source, Transport, OfflineTest, Tone) {
|
|||
var source = new Source();
|
||||
source.sync().start(0);
|
||||
expect(source.state).to.equal("stopped");
|
||||
Tone.Transport.start().stop(0.4);
|
||||
Tone.Transport.start(0).stop(0.4);
|
||||
expect(source.state).to.equal("started");
|
||||
|
||||
testFn(function(sample, time){
|
||||
|
|
Loading…
Reference in a new issue