using clock seconds

they are accurate even during bpm automation curves
This commit is contained in:
Yotam Mann 2017-12-27 16:24:27 -05:00
parent 32d5451293
commit 40891fb865
2 changed files with 17 additions and 3 deletions

View file

@ -557,10 +557,11 @@ define(["Tone/core/Tone", "Tone/core/Clock", "Tone/type/Type", "Tone/core/Timeli
*/
Object.defineProperty(Tone.Transport.prototype, "seconds", {
get : function(){
return Tone.Ticks(this.ticks).toSeconds();
return this._clock.seconds;
},
set : function(progress){
var ticks = this.toTicks(progress);
set : function(s){
var now = this.now();
var ticks = this.bpm.timeToTicks(s, now);
this.ticks = ticks;
}
});

View file

@ -199,6 +199,19 @@ function (Test, Transport, Tone, Offline, TransportTime, Signal, BufferTest, Tim
}, 0.1);
});
it("can get the current position in seconds during a bpm ramp", function(){
return Offline(function(Transport){
expect(Transport.seconds).to.equal(0);
Transport.start(0.05);
Transport.bpm.linearRampTo(60, 0.5, 0.5)
return function(time){
if (time > 0.05){
expect(Transport.seconds).to.be.closeTo(time - 0.05, 0.01);
}
};
}, 0.7);
});
it("can set the current position in seconds", function(){
return Offline(function(Transport){
expect(Transport.seconds).to.equal(0);