mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
fixing and testing start offset for non-looping parts
This commit is contained in:
parent
f545fcdf90
commit
8231fc5cf3
2 changed files with 30 additions and 1 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(){
|
||||
|
|
Loading…
Reference in a new issue