From 86690eccdb319178239a2536b7f5f0a57a70c9b8 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Sat, 5 Mar 2016 10:44:10 -0500 Subject: [PATCH] testing setCurveAtTime --- test/signal/TimelineSignal.js | 39 ++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/test/signal/TimelineSignal.js b/test/signal/TimelineSignal.js index 49725805..ec2ec912 100644 --- a/test/signal/TimelineSignal.js +++ b/test/signal/TimelineSignal.js @@ -1,5 +1,5 @@ -define(["Test", "Tone/signal/TimelineSignal", "helper/Offline", "Tone/core/Type"], - function (Test, TimelineSignal, Offline, Tone) { +define(["Test", "Tone/signal/TimelineSignal", "helper/Offline", "Tone/core/Type", "helper/Offline2"], + function (Test, TimelineSignal, Offline, Tone, Offline2) { describe("TimelineSignal", function(){ @@ -76,7 +76,7 @@ define(["Test", "Tone/signal/TimelineSignal", "helper/Offline", "Tone/core/Type" var offline = new Offline(2); offline.before(function(dest){ sched = new TimelineSignal(1).connect(dest); - sched.setValueAtTime(3, 0); + sched.setValueAtTime(1, 0); sched.setTargetAtTime(0.5, 0.5, 2); }); offline.test(function(sample, time){ @@ -89,6 +89,38 @@ define(["Test", "Tone/signal/TimelineSignal", "helper/Offline", "Tone/core/Type" offline.run(); }); + it("can get set a curve in the future", function(done){ + Offline2(function(dest, test, after){ + var sched = new TimelineSignal(1).connect(dest); + sched.setValueCurveAtTime([0, 1, 0.2, 0.8, 0], 0, 1); + + test(function(sample, time){ + expect(sample).to.be.closeTo(sched.getValueAtTime(time), 0.01); + }); + + after(function(){ + sched.dispose(); + done(); + }); + }, 1); + }); + + it("can scale a curve value", function(done){ + Offline2(function(dest, test, after){ + var sched = new TimelineSignal(1).connect(dest); + sched.setValueCurveAtTime([0, 1, 0], 0, 1, 0.5); + + test(function(sample){ + expect(sample).to.be.at.most(0.5); + }); + + after(function(){ + sched.dispose(); + done(); + }); + }, 1); + }); + it("can match a complex scheduled curve", function(done){ var sched; var offline = new Offline(4); @@ -103,6 +135,7 @@ define(["Test", "Tone/signal/TimelineSignal", "helper/Offline", "Tone/core/Type" sched.linearRampToValueAtTime(2.4, 2.5); sched.linearRampToValueAtTime(5, 3); sched.setTargetAtTime(2, 3.5, 5); + sched.setValueCurveAtTime([0, 1, 0], 3.8, 0.2); }); offline.test(function(sample, time){ expect(sample).to.be.closeTo(sched.getValueAtTime(time), 0.01);