Tone.js/test/signal/GainToAudio.js

82 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-08-24 21:29:19 +00:00
define(["helper/Offline", "Tone/signal/GainToAudio", "helper/Basic",
"Test", "Tone/signal/Signal", "Tone/signal/Zero"],
function (Offline, GainToAudio, Basic, Test, Signal, Zero) {
2015-08-24 21:29:19 +00:00
describe("GainToAudio", function(){
Basic(GainToAudio);
context("Gain To Audio", function(){
it("handles input and output connections", function(){
var g2a = new GainToAudio();
Test.connect(g2a);
g2a.connect(Test);
g2a.dispose();
});
it("outputs 0 for an input value of 0.5", function(done){
//make an oscillator to drive the signal
var sig, g2a;
var offline = new Offline();
offline.before(function(dest){
sig = new Signal(0.5);
g2a = new GainToAudio();
sig.connect(g2a);
g2a.connect(dest);
});
offline.test(function(sample){
expect(sample).to.be.closeTo(0, 0.01);
});
offline.after(function(){
sig.dispose();
g2a.dispose();
done();
});
offline.run();
});
it("outputs 1 for an input value of 1", function(done){
//make an oscillator to drive the signal
var sig, g2a;
var offline = new Offline();
offline.before(function(dest){
sig = new Signal(1);
g2a = new GainToAudio();
sig.connect(g2a);
g2a.connect(dest);
});
offline.test(function(sample){
expect(sample).to.be.closeTo(1, 0.01);
});
offline.after(function(){
sig.dispose();
g2a.dispose();
done();
});
offline.run();
});
it("outputs -1 for an input value of 0", function(done){
//make an oscillator to drive the signal
var sig, g2a;
var offline = new Offline();
offline.before(function(dest){
sig = new Zero();
2015-08-24 21:29:19 +00:00
g2a = new GainToAudio();
sig.connect(g2a);
g2a.connect(dest);
});
offline.test(function(sample){
expect(sample).to.be.closeTo(-1, 0.01);
});
offline.after(function(){
sig.dispose();
g2a.dispose();
done();
});
offline.run();
});
});
});
});