fixing and testing start offset for non-looping parts

This commit is contained in:
Yotam Mann 2015-11-26 08:42:33 -08:00
parent f545fcdf90
commit 8231fc5cf3
2 changed files with 30 additions and 1 deletions

View file

@ -179,7 +179,7 @@ define(["Tone/core/Tone", "Tone/event/Event", "Tone/core/Type", "Tone/core/Trans
event.start(ticks + "i");
}
} else {
if (event.startOffset < offset){
if (event.startOffset >= offset){
event.start(ticks + "i");
}
}

View file

@ -337,6 +337,17 @@ define(["helper/Basic", "Tone/event/Part", "Tone/core/Tone", "Tone/core/Transpor
Tone.Transport.start(startTime);
});
it("can start with an offset", function(done){
var now = Tone.Transport.now() + 0.1;
var part = new Part(function(time, number){
expect(time - now).to.be.closeTo(0.1, 0.01);
expect(number).to.equal(1);
part.dispose();
done();
}, [[0, 0], [1, 1]]).start(0, 0.9);
Tone.Transport.start(now);
});
});
context("Looping", function(){
@ -486,6 +497,24 @@ define(["helper/Basic", "Tone/event/Part", "Tone/core/Tone", "Tone/core/Transpor
}, 800);
});
it("can start a loop with an offset", function(done){
var iteration = 0;
var part = new Part(function(time, number){
if (iteration === 0){
expect(number).to.equal(1);
} else if (iteration === 1){
expect(number).to.equal(0);
part.dispose();
done();
}
iteration++;
}, [[0, 0], [0.25, 1]]);
part.loop = true;
part.loopEnd = 0.5;
part.start(0, 0.25);
Tone.Transport.start();
});
});
context("playbackRate", function(){