2015-08-24 21:29:19 +00:00
|
|
|
define(["helper/Offline", "Tone/signal/EqualPowerGain", "helper/Basic",
|
2017-04-27 04:54:11 +00:00
|
|
|
"Test", "Tone/source/Oscillator", "Tone/signal/Signal", "helper/PassAudio", "Tone/core/Tone"],
|
|
|
|
function (Offline, EqualPowerGain, Basic, Test, Oscillator, Signal, PassAudio, Tone) {
|
2015-08-24 21:29:19 +00:00
|
|
|
|
|
|
|
describe("EqualPowerGain", function(){
|
|
|
|
|
|
|
|
Basic(EqualPowerGain);
|
|
|
|
|
|
|
|
context("Equal Power Gain", function(){
|
|
|
|
|
|
|
|
it("handles input and output connections", function(){
|
|
|
|
var eqGain = new EqualPowerGain();
|
|
|
|
Test.connect(eqGain);
|
|
|
|
eqGain.connect(Test);
|
|
|
|
eqGain.dispose();
|
|
|
|
});
|
|
|
|
|
2017-02-20 21:40:41 +00:00
|
|
|
it ("passes audio through", function(){
|
|
|
|
return PassAudio(function(input){
|
|
|
|
var eqGain = new EqualPowerGain().toMaster();
|
|
|
|
input.connect(eqGain);
|
2015-08-24 21:29:19 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-02-20 21:40:41 +00:00
|
|
|
it("scales the input on an equal power scale", function(){
|
|
|
|
var eqGain;
|
|
|
|
return Offline(function(){
|
|
|
|
var sig = new Signal(0);
|
2015-08-24 21:29:19 +00:00
|
|
|
eqGain = new EqualPowerGain();
|
|
|
|
sig.connect(eqGain);
|
2017-02-20 21:40:41 +00:00
|
|
|
eqGain.toMaster();
|
2015-08-24 21:29:19 +00:00
|
|
|
sig.setValueAtTime(0, 0);
|
2017-02-20 21:40:41 +00:00
|
|
|
sig.linearRampToValueAtTime(1, 0.1);
|
|
|
|
}, 0.1).then(function(buffer){
|
|
|
|
buffer.forEach(function(sample, time){
|
2017-04-27 04:54:11 +00:00
|
|
|
expect(sample).to.be.closeTo(Tone.equalPowerScale(time*10), 0.01);
|
2017-02-20 21:40:41 +00:00
|
|
|
});
|
2015-08-24 21:29:19 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|