Tone.js/test/core/Master.js

51 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-02-20 03:50:39 +00:00
define(["Test", "Tone/core/Master", "Tone/core/Tone", "helper/Offline", "helper/PassAudio", "Tone/source/Oscillator"],
function (Test, Master, Tone, Offline, PassAudio, Oscillator) {
2015-08-16 18:23:40 +00:00
describe("Master", function(){
it ("exists", function(){
expect(Tone.Master).to.exist;
});
it ("provides a toMaster method", function(){
expect(Tone.prototype.toMaster).is.a("function");
expect(AudioNode.prototype.toMaster).is.a("function");
});
it ("can be muted and unmuted", function(){
Tone.Master.mute = false;
expect(Tone.Master.mute).to.be.false;
Tone.Master.mute = true;
expect(Tone.Master.mute).to.be.true;
});
2017-02-19 20:29:01 +00:00
it ("passes audio through", function(){
return PassAudio(function(input){
2015-08-16 18:23:40 +00:00
input.toMaster();
2017-02-19 20:29:01 +00:00
});
2015-08-16 18:23:40 +00:00
});
2017-02-19 20:29:01 +00:00
it ("passes no audio when muted", function(){
return Offline(function(){
new Oscillator().toMaster().start(0);
2015-08-16 18:23:40 +00:00
Tone.Master.mute = true;
2017-02-20 03:50:39 +00:00
}).then(function(buffer){
expect(buffer.isSilent()).to.be.true;
2015-08-16 18:23:40 +00:00
});
});
it ("has a master volume control", function(){
2017-02-19 20:29:01 +00:00
return Offline(function(){
Tone.Master.volume.value = -20;
expect(Tone.Master.volume.value).to.be.closeTo(-20, 0.1);
});
2015-08-16 18:23:40 +00:00
});
2017-02-19 20:29:01 +00:00
it ("can pass audio through chained nodes", function(){
return PassAudio(function(input){
var gain = Tone.context.createGain();
2015-08-16 18:23:40 +00:00
input.connect(gain);
Tone.Master.chain(gain);
});
});
});
});