From e61a4c5fe29b9d3799c9c20d0e8d5ee7af611cdf Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Thu, 21 Dec 2017 15:13:43 -0500 Subject: [PATCH] renaming to getTicksAtTime --- Tone/signal/TickSignal.js | 10 ++--- test/signal/TickSignal.js | 84 +++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Tone/signal/TickSignal.js b/Tone/signal/TickSignal.js index 9d1d2057..b40be90d 100644 --- a/Tone/signal/TickSignal.js +++ b/Tone/signal/TickSignal.js @@ -39,7 +39,7 @@ define(["Tone/core/Tone", "Tone/signal/TimelineSignal"], function (Tone) { method.apply(this, arguments); var event = this._events.get(time); var previousEvent = this._events.previousEvent(event); - var ticksUntilTime = this._getTickUntilEvent(previousEvent, time - this.sampleTime); + var ticksUntilTime = this._getTicksUntilEvent(previousEvent, time - this.sampleTime); event.ticks = Math.max(ticksUntilTime, 0); return this; }; @@ -111,7 +111,7 @@ define(["Tone/core/Tone", "Tone/signal/TimelineSignal"], function (Tone) { * @return {Ticks} The number of ticks which have elapsed at the time * given any automations. */ - Tone.TickSignal.prototype._getTickUntilEvent = function(event, time){ + Tone.TickSignal.prototype._getTicksUntilEvent = function(event, time){ if (event === null){ event = { "ticks" : 0, @@ -130,10 +130,10 @@ define(["Tone/core/Tone", "Tone/signal/TimelineSignal"], function (Tone) { * @return {Ticks} The number of ticks which have elapsed at the time * given any automations. */ - Tone.TickSignal.prototype.getTickAtTime = function(time){ + Tone.TickSignal.prototype.getTicksAtTime = function(time){ time = this.toSeconds(time); var event = this._events.get(time); - return this._getTickUntilEvent(event, time); + return this._getTicksUntilEvent(event, time); }; /** @@ -144,7 +144,7 @@ define(["Tone/core/Tone", "Tone/signal/TimelineSignal"], function (Tone) { */ Tone.TickSignal.prototype.getDurationOfTicks = function(ticks, time){ time = this.toSeconds(time); - var currentTick = this.getTickAtTime(time); + var currentTick = this.getTicksAtTime(time); return this.getTimeOfTick(currentTick + ticks) - time; }; diff --git a/test/signal/TickSignal.js b/test/signal/TickSignal.js index 61df24e3..1bd3b6a8 100644 --- a/test/signal/TickSignal.js +++ b/test/signal/TickSignal.js @@ -1,4 +1,4 @@ -define(["Test", "Tone/signal/TickSignal", "helper/Offline"], +define(["Test", "Tone/signal/TickSignal", "helper/Offline"], function (Test, TickSignal, Offline) { describe("TickSignal", function(){ @@ -25,23 +25,23 @@ define(["Test", "Tone/signal/TickSignal", "helper/Offline"], it("calculates the ticks when no changes are scheduled", function(){ var tickSignal0 = new TickSignal(2); - expect(tickSignal0.getTickAtTime(1)).to.be.closeTo(2, 0.01); - expect(tickSignal0.getTickAtTime(2)).to.be.closeTo(4, 0.01); + expect(tickSignal0.getTicksAtTime(1)).to.be.closeTo(2, 0.01); + expect(tickSignal0.getTicksAtTime(2)).to.be.closeTo(4, 0.01); tickSignal0.dispose(); var tickSignal1 = new TickSignal(1); - expect(tickSignal1.getTickAtTime(1)).to.be.closeTo(1, 0.01); - expect(tickSignal1.getTickAtTime(2)).to.be.closeTo(2, 0.01); + expect(tickSignal1.getTicksAtTime(1)).to.be.closeTo(1, 0.01); + expect(tickSignal1.getTicksAtTime(2)).to.be.closeTo(2, 0.01); tickSignal1.dispose(); }); it("calculates the ticks in the future when a setValueAtTime is scheduled", function(){ var tickSignal = new TickSignal(1); tickSignal.setValueAtTime(2, 0.5); - expect(tickSignal.getTickAtTime(0)).to.be.closeTo(0, 0.01); - expect(tickSignal.getTickAtTime(0.5)).to.be.closeTo(0.5, 0.01); - expect(tickSignal.getTickAtTime(0.75)).to.be.closeTo(1, 0.01); - expect(tickSignal.getTickAtTime(1)).to.be.closeTo(1.5, 0.01); + expect(tickSignal.getTicksAtTime(0)).to.be.closeTo(0, 0.01); + expect(tickSignal.getTicksAtTime(0.5)).to.be.closeTo(0.5, 0.01); + expect(tickSignal.getTicksAtTime(0.75)).to.be.closeTo(1, 0.01); + expect(tickSignal.getTicksAtTime(1)).to.be.closeTo(1.5, 0.01); tickSignal.dispose(); }); @@ -49,24 +49,24 @@ define(["Test", "Tone/signal/TickSignal", "helper/Offline"], var tickSignal = new TickSignal(1); tickSignal.setValueAtTime(2, 1); tickSignal.setValueAtTime(4, 2); - expect(tickSignal.getTickAtTime(0)).to.be.closeTo(0, 0.01); - expect(tickSignal.getTickAtTime(0.5)).to.be.closeTo(0.5, 0.01); - expect(tickSignal.getTickAtTime(1)).to.be.closeTo(1, 0.01); - expect(tickSignal.getTickAtTime(1.5)).to.be.closeTo(2, 0.01); - expect(tickSignal.getTickAtTime(2)).to.be.closeTo(3, 0.01); - expect(tickSignal.getTickAtTime(2.5)).to.be.closeTo(5, 0.01); - expect(tickSignal.getTickAtTime(3)).to.be.closeTo(7, 0.01); + expect(tickSignal.getTicksAtTime(0)).to.be.closeTo(0, 0.01); + expect(tickSignal.getTicksAtTime(0.5)).to.be.closeTo(0.5, 0.01); + expect(tickSignal.getTicksAtTime(1)).to.be.closeTo(1, 0.01); + expect(tickSignal.getTicksAtTime(1.5)).to.be.closeTo(2, 0.01); + expect(tickSignal.getTicksAtTime(2)).to.be.closeTo(3, 0.01); + expect(tickSignal.getTicksAtTime(2.5)).to.be.closeTo(5, 0.01); + expect(tickSignal.getTicksAtTime(3)).to.be.closeTo(7, 0.01); tickSignal.dispose(); }); - it("if ticks are 0, getTickAtTime will return 0", function(){ + it("if ticks are 0, getTicksAtTime will return 0", function(){ var tickSignal = new TickSignal(0); tickSignal.setValueAtTime(0, 1); tickSignal.linearRampToValueAtTime(0, 2); - expect(tickSignal.getTickAtTime(0)).to.equal(0); - expect(tickSignal.getTickAtTime(1)).to.equal(0); - expect(tickSignal.getTickAtTime(2)).to.equal(0); - expect(tickSignal.getTickAtTime(3)).to.equal(0); + expect(tickSignal.getTicksAtTime(0)).to.equal(0); + expect(tickSignal.getTicksAtTime(1)).to.equal(0); + expect(tickSignal.getTicksAtTime(2)).to.equal(0); + expect(tickSignal.getTicksAtTime(3)).to.equal(0); tickSignal.dispose(); }); @@ -74,10 +74,10 @@ define(["Test", "Tone/signal/TickSignal", "helper/Offline"], var tickSignal = new TickSignal(1); tickSignal.setValueAtTime(1, 0); tickSignal.linearRampToValueAtTime(2, 1); - expect(tickSignal.getTickAtTime(0)).to.be.closeTo(0, 0.01); - expect(tickSignal.getTickAtTime(0.5)).to.be.closeTo(0.62, 0.01); - expect(tickSignal.getTickAtTime(1)).to.be.closeTo(1.5, 0.01); - expect(tickSignal.getTickAtTime(2)).to.be.closeTo(3.5, 0.01); + expect(tickSignal.getTicksAtTime(0)).to.be.closeTo(0, 0.01); + expect(tickSignal.getTicksAtTime(0.5)).to.be.closeTo(0.62, 0.01); + expect(tickSignal.getTicksAtTime(1)).to.be.closeTo(1.5, 0.01); + expect(tickSignal.getTicksAtTime(2)).to.be.closeTo(3.5, 0.01); tickSignal.dispose(); }); @@ -86,11 +86,11 @@ define(["Test", "Tone/signal/TickSignal", "helper/Offline"], tickSignal.setValueAtTime(1, 0); tickSignal.linearRampToValueAtTime(2, 1); tickSignal.linearRampToValueAtTime(0, 2); - expect(tickSignal.getTickAtTime(0)).to.be.closeTo(0, 0.01); - expect(tickSignal.getTickAtTime(0.5)).to.be.closeTo(0.62, 0.01); - expect(tickSignal.getTickAtTime(1)).to.be.closeTo(1.5, 0.01); - expect(tickSignal.getTickAtTime(2)).to.be.closeTo(2.5, 0.01); - expect(tickSignal.getTickAtTime(3)).to.be.closeTo(2.5, 0.01); + expect(tickSignal.getTicksAtTime(0)).to.be.closeTo(0, 0.01); + expect(tickSignal.getTicksAtTime(0.5)).to.be.closeTo(0.62, 0.01); + expect(tickSignal.getTicksAtTime(1)).to.be.closeTo(1.5, 0.01); + expect(tickSignal.getTicksAtTime(2)).to.be.closeTo(2.5, 0.01); + expect(tickSignal.getTicksAtTime(3)).to.be.closeTo(2.5, 0.01); tickSignal.dispose(); }); @@ -98,11 +98,11 @@ define(["Test", "Tone/signal/TickSignal", "helper/Offline"], var tickSignal = new TickSignal(1); tickSignal.setValueAtTime(1, 0); tickSignal.exponentialRampToValueAtTime(2, 1); - expect(tickSignal.getTickAtTime(0)).to.be.closeTo(0, 0.01); - expect(tickSignal.getTickAtTime(0.5)).to.be.closeTo(0.6, 0.01); - expect(tickSignal.getTickAtTime(1)).to.be.closeTo(1.5, 0.1); - expect(tickSignal.getTickAtTime(2)).to.be.closeTo(3.5, 0.1); - expect(tickSignal.getTickAtTime(3)).to.be.closeTo(5.5, 0.1); + expect(tickSignal.getTicksAtTime(0)).to.be.closeTo(0, 0.01); + expect(tickSignal.getTicksAtTime(0.5)).to.be.closeTo(0.6, 0.01); + expect(tickSignal.getTicksAtTime(1)).to.be.closeTo(1.5, 0.1); + expect(tickSignal.getTicksAtTime(2)).to.be.closeTo(3.5, 0.1); + expect(tickSignal.getTicksAtTime(3)).to.be.closeTo(5.5, 0.1); tickSignal.dispose(); }); @@ -111,11 +111,11 @@ define(["Test", "Tone/signal/TickSignal", "helper/Offline"], tickSignal.setValueAtTime(1, 0); tickSignal.exponentialRampToValueAtTime(2, 1); tickSignal.exponentialRampToValueAtTime(0, 2); - expect(tickSignal.getTickAtTime(0)).to.be.closeTo(0, 0.01); - expect(tickSignal.getTickAtTime(0.5)).to.be.closeTo(0.6, 0.01); - expect(tickSignal.getTickAtTime(1)).to.be.closeTo(1.5, 0.1); - expect(tickSignal.getTickAtTime(2)).to.be.closeTo(1.66, 0.1); - expect(tickSignal.getTickAtTime(3)).to.be.closeTo(1.66, 0.1); + expect(tickSignal.getTicksAtTime(0)).to.be.closeTo(0, 0.01); + expect(tickSignal.getTicksAtTime(0.5)).to.be.closeTo(0.6, 0.01); + expect(tickSignal.getTicksAtTime(1)).to.be.closeTo(1.5, 0.1); + expect(tickSignal.getTicksAtTime(2)).to.be.closeTo(1.66, 0.1); + expect(tickSignal.getTicksAtTime(3)).to.be.closeTo(1.66, 0.1); tickSignal.dispose(); }); @@ -235,7 +235,7 @@ define(["Test", "Tone/signal/TickSignal", "helper/Offline"], tickSignal.setTargetAtTime(8, 5, 0.2); for (var time = 0; time < 5; time+=0.2){ - var tick = tickSignal.getTickAtTime(time); + var tick = tickSignal.getTicksAtTime(time); expect(tickSignal.getTimeOfTick(tick)).to.be.closeTo(time, 0.1); } @@ -265,4 +265,4 @@ define(["Test", "Tone/signal/TickSignal", "helper/Offline"], }); }); -}); \ No newline at end of file +});