mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
using clock seconds
they are accurate even during bpm automation curves
This commit is contained in:
parent
32d5451293
commit
40891fb865
2 changed files with 17 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue