From 1e5606a003bbea3f1c4ed8e30cbee97554311bfc Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Wed, 3 Jan 2018 15:38:04 -0500 Subject: [PATCH] testing cancelAndHold during exponential ramp --- test/core/Param.js | 12 ++++++++++-- test/signal/Signal.js | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/test/core/Param.js b/test/core/Param.js index 291c9660..ee0e9298 100644 --- a/test/core/Param.js +++ b/test/core/Param.js @@ -1,5 +1,5 @@ define(["helper/Basic", "Test", "Tone/core/Param", "Tone/type/Type", "Tone/signal/Signal", "Tone/core/Transport"], - function (Basic, Test, Param, Tone, Signal, Transport) { + function(Basic, Test, Param, Tone, Signal, Transport) { describe("Param", function(){ @@ -252,7 +252,7 @@ define(["helper/Basic", "Test", "Tone/core/Param", "Tone/type/Type", "Tone/signa param.dispose(); }); - it("can cancelAndHold an automation", function(){ + it("can cancelAndHold a linear automation", function(){ var gain = Tone.context.createGain(); var param = new Param(gain.gain); param.linearRampToValueAtTime(0.5, "+0.5"); @@ -260,6 +260,14 @@ define(["helper/Basic", "Test", "Tone/core/Param", "Tone/type/Type", "Tone/signa param.dispose(); }); + it("can cancelAndHold an exponential automation", function(){ + var gain = Tone.context.createGain(); + var param = new Param(gain.gain); + param.exponentialRampToValueAtTime(0.5, "+0.5"); + param.cancelAndHoldAtTime(0); + param.dispose(); + }); + it("can set a linear ramp from the current time", function(){ var gain = Tone.context.createGain(); var param = new Param(gain.gain); diff --git a/test/signal/Signal.js b/test/signal/Signal.js index eb726ed9..fe509f0b 100644 --- a/test/signal/Signal.js +++ b/test/signal/Signal.js @@ -1,6 +1,6 @@ define(["helper/Offline", "helper/Basic", "Test", "Tone/signal/Signal", "Tone/type/Type", "Tone/core/Transport", "helper/ConstantOutput"], -function (Offline, Basic, Test, Signal, Tone, Transport, ConstantOutput) { +function(Offline, Basic, Test, Signal, Tone, Transport, ConstantOutput) { describe("Signal", function(){ @@ -119,7 +119,7 @@ function (Offline, Basic, Test, Signal, Tone, Transport, ConstantOutput) { }, 1); }); - it("can cancel and hold an automation curve", function(){ + it("can cancel and hold a linear automation curve", function(){ return Offline(function(){ var sig = new Signal(0).toMaster(); sig.linearRampTo(2, 1); @@ -132,6 +132,19 @@ function (Offline, Basic, Test, Signal, Tone, Transport, ConstantOutput) { }); }); + it("can cancel and hold an exponential automation curve", function(){ + return Offline(function(){ + var sig = new Signal(1).toMaster(); + sig.exponentialRampTo(2, 1); + sig.cancelAndHoldAtTime(0.5); + }, 1).then(function(buffer){ + expect(buffer.getValueAtTime(0)).to.be.closeTo(1, 0.1); + expect(buffer.getValueAtTime(0.25)).to.be.closeTo(1.2, 0.1); + expect(buffer.getValueAtTime(0.5)).to.be.closeTo(1.4, 0.1); + expect(buffer.getValueAtTime(0.75)).to.be.closeTo(1.4, 0.1); + }); + }); + it("can set a linear ramp from the current time", function(){ return Offline(function(){ var sig = new Signal(0).toMaster();