mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
testing rampTo with additional time
This commit is contained in:
parent
3b9b65bf89
commit
e22ba03642
1 changed files with 64 additions and 2 deletions
|
@ -59,8 +59,6 @@ define(["helper/Offline", "helper/Basic", "Test", "Tone/signal/Signal",
|
|||
|
||||
context("Scheduling", function(){
|
||||
|
||||
this.timeout(3000);
|
||||
|
||||
it ("can be scheduled to set a value in the future", function(done){
|
||||
var sig;
|
||||
var offline = new Offline();
|
||||
|
@ -181,6 +179,28 @@ define(["helper/Offline", "helper/Basic", "Test", "Tone/signal/Signal",
|
|||
offline.run();
|
||||
});
|
||||
|
||||
it ("can set an linear ramp in the future", function(done){
|
||||
var sig;
|
||||
var offline = new Offline(0.6);
|
||||
offline.before(function(dest){
|
||||
sig = new Signal(1).connect(dest);
|
||||
sig.linearRampToValue(50, 0.3, 0.2);
|
||||
});
|
||||
offline.test(function(sample, time){
|
||||
if (time >= 0.6){
|
||||
expect(sample).to.be.closeTo(50, 0.5);
|
||||
} else if (time < 0.2){
|
||||
expect(sample).to.equal(1);
|
||||
}
|
||||
});
|
||||
offline.after(function(){
|
||||
sig.dispose();
|
||||
done();
|
||||
});
|
||||
offline.run();
|
||||
});
|
||||
|
||||
|
||||
it ("can set an exponential ramp from the current time", function(done){
|
||||
var sig;
|
||||
var offline = new Offline(0.5);
|
||||
|
@ -202,6 +222,27 @@ define(["helper/Offline", "helper/Basic", "Test", "Tone/signal/Signal",
|
|||
offline.run();
|
||||
});
|
||||
|
||||
it ("can set an exponential ramp in the future", function(done){
|
||||
var sig;
|
||||
var offline = new Offline(0.6);
|
||||
offline.before(function(dest){
|
||||
sig = new Signal(1).connect(dest);
|
||||
sig.exponentialRampToValue(50, 0.3, 0.2);
|
||||
});
|
||||
offline.test(function(sample, time){
|
||||
if (time >= 0.6){
|
||||
expect(sample).to.be.closeTo(50, 0.5);
|
||||
} else if (time < 0.2){
|
||||
expect(sample).to.equal(1);
|
||||
}
|
||||
});
|
||||
offline.after(function(){
|
||||
sig.dispose();
|
||||
done();
|
||||
});
|
||||
offline.run();
|
||||
});
|
||||
|
||||
it ("rampTo ramps from the current value", function(done){
|
||||
var sig;
|
||||
var offline = new Offline(0.5);
|
||||
|
@ -222,6 +263,27 @@ define(["helper/Offline", "helper/Basic", "Test", "Tone/signal/Signal",
|
|||
});
|
||||
offline.run();
|
||||
});
|
||||
|
||||
it ("rampTo ramps from the current value at a specific time", function(done){
|
||||
var sig;
|
||||
var offline = new Offline(0.6);
|
||||
offline.before(function(dest){
|
||||
sig = new Signal(0).connect(dest);
|
||||
sig.rampTo(2, 0.1, 0.4);
|
||||
});
|
||||
offline.test(function(sample, time){
|
||||
if (time <= 0.4){
|
||||
expect(sample).to.be.closeTo(0, 0.1);
|
||||
} else if (time > 0.5){
|
||||
expect(sample).to.be.closeTo(2, 0.1);
|
||||
}
|
||||
});
|
||||
offline.after(function(){
|
||||
sig.dispose();
|
||||
done();
|
||||
});
|
||||
offline.run();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue