Tone.js/test/core/Bus.js

36 lines
1 KiB
JavaScript
Raw Normal View History

define(["Test", "Tone/core/Bus", "Tone/core/Tone", "helper/Offline",
"helper/PassAudio", "Tone/signal/Signal", "Tone/core/Gain", "Tone/core/Master"],
function (Test, Bus, Tone, Offline, PassAudio, Signal, Gain) {
2015-08-16 18:23:40 +00:00
describe("Bus", function(){
it ("provides a send and receive method", function(){
expect(Tone.prototype.send).is.a("function");
expect(Tone.prototype.receive).is.a("function");
});
it ("passes audio from a send to a receive with the same name", function(){
return PassAudio(function(input){
2015-08-16 18:23:40 +00:00
//make them pass through nodes
var send = new Gain();
var recv = new Gain().toMaster();
2015-08-16 18:23:40 +00:00
input.connect(send);
send.send("test");
recv.receive("test");
});
});
it ("passes audio from a send to a receive at the given level", function(){
return Offline(function(){
var sig = new Signal(1);
var recv = new Gain().toMaster();
sig.send("test", -12);
recv.receive("test");
return function(sample){
expect(sample).to.be.closeTo(0.25, 0.1);
};
}, 0.2);
});
2015-08-16 18:23:40 +00:00
});
});