2017-02-19 16:54:29 +00:00
|
|
|
define(["Test", "Tone/core/Bus", "Tone/core/Tone", "helper/Offline",
|
|
|
|
"helper/PassAudio", "Tone/signal/Signal", "Tone/core/Gain", "Tone/core/Master"],
|
2016-09-20 03:30:43 +00:00
|
|
|
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");
|
|
|
|
});
|
|
|
|
|
2017-02-19 16:54:29 +00:00
|
|
|
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
|
2017-02-19 16:54:29 +00:00
|
|
|
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");
|
|
|
|
});
|
|
|
|
});
|
2016-09-20 03:30:43 +00:00
|
|
|
|
2017-02-19 16:54:29 +00:00
|
|
|
it ("passes audio from a send to a receive at the given level", function(){
|
|
|
|
return Offline(function(){
|
2016-09-20 03:30:43 +00:00
|
|
|
|
|
|
|
var sig = new Signal(1);
|
2017-02-19 16:54:29 +00:00
|
|
|
var recv = new Gain().toMaster();
|
2016-09-20 03:30:43 +00:00
|
|
|
sig.send("test", -12);
|
|
|
|
recv.receive("test");
|
|
|
|
|
2017-02-19 16:54:29 +00:00
|
|
|
return function(sample){
|
2016-09-20 03:30:43 +00:00
|
|
|
expect(sample).to.be.closeTo(0.25, 0.1);
|
2017-02-19 16:54:29 +00:00
|
|
|
};
|
2016-09-20 03:30:43 +00:00
|
|
|
}, 0.2);
|
|
|
|
});
|
2015-08-16 18:23:40 +00:00
|
|
|
});
|
|
|
|
});
|