Tone.js/test/signal/AudioToGain.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-08-24 15:17:21 +00:00
define(["helper/Offline", "Tone/signal/AudioToGain", "helper/Basic",
2018-05-18 16:07:20 +00:00
"helper/Test", "Tone/source/Oscillator", "Tone/signal/Signal", "Tone/signal/Zero", "helper/ConstantOutput"],
function(Offline, AudioToGain, Basic, Test, Oscillator, Signal, Zero, ConstantOutput){
2015-08-24 15:17:21 +00:00
describe("AudioToGain", function(){
Basic(AudioToGain);
it("handles input and output connections", function(){
var a2g = new AudioToGain();
a2g.connect(Test);
Test.connect(a2g);
a2g.dispose();
});
2017-02-20 21:40:41 +00:00
it("normalizes an oscillator to 0,1", function(){
return Offline(function(){
var osc = new Oscillator(1000);
var a2g = new AudioToGain();
2015-08-24 15:17:21 +00:00
osc.connect(a2g);
2017-02-20 21:40:41 +00:00
a2g.toMaster();
}).then(function(buffer){
buffer.forEach(function(sample){
expect(sample).to.be.within(0, 1);
});
2015-08-24 15:17:21 +00:00
});
});
2017-02-20 21:40:41 +00:00
it("outputs 0.5 for an input value of 0", function(){
return ConstantOutput(function(){
var sig = new Zero();
var a2g = new AudioToGain();
2015-08-24 15:17:21 +00:00
sig.connect(a2g);
2017-02-20 21:40:41 +00:00
a2g.toMaster();
}, 0.5);
2015-08-24 15:17:21 +00:00
});
2017-02-20 21:40:41 +00:00
it("outputs 1 for an input value of 1", function(){
return ConstantOutput(function(){
var sig = new Signal(1);
var a2g = new AudioToGain();
2015-08-24 15:17:21 +00:00
sig.connect(a2g);
2017-02-20 21:40:41 +00:00
a2g.toMaster();
}, 1);
2015-08-24 15:17:21 +00:00
});
2017-02-20 21:40:41 +00:00
it("outputs 0 for an input value of -1", function(){
return ConstantOutput(function(){
var sig = new Signal(-1);
var a2g = new AudioToGain();
2015-08-24 15:17:21 +00:00
sig.connect(a2g);
2017-02-20 21:40:41 +00:00
a2g.toMaster();
}, 0);
2015-08-24 15:17:21 +00:00
});
});
2017-12-30 16:26:29 +00:00
});