Tone.js/test/component/PanVol.js

75 lines
1.9 KiB
JavaScript
Raw Normal View History

import PanVol from "Tone/component/PanVol";
import Basic from "helper/Basic";
import Offline from "helper/Offline";
import Test from "helper/Test";
import Signal from "Tone/signal/Signal";
import PassAudio from "helper/PassAudio";
import PassAudioStereo from "helper/PassAudioStereo";
import Merge from "Tone/component/Merge";
describe("PanVol", function(){
2015-08-28 22:42:44 +00:00
Basic(PanVol);
2015-08-28 22:42:44 +00:00
context("Pan and Volume", function(){
2015-08-28 22:42:44 +00:00
it("handles input and output connections", function(){
var panVol = new PanVol();
Test.connect(panVol);
panVol.connect(Test);
panVol.dispose();
});
2015-08-28 22:42:44 +00:00
it("can be constructed with the panning and volume value", function(){
var panVol = new PanVol(0.3, -12);
expect(panVol.pan.value).to.be.closeTo(0.3, 0.001);
expect(panVol.volume.value).to.be.closeTo(-12, 0.1);
panVol.dispose();
});
2015-08-28 22:42:44 +00:00
it("can be constructed with an options object", function(){
var panVol = new PanVol({
"pan" : 0.2,
"mute" : true
2015-08-28 22:42:44 +00:00
});
expect(panVol.pan.value).to.be.closeTo(0.2, 0.001);
expect(panVol.mute).to.be.true;
panVol.dispose();
});
2015-08-28 22:42:44 +00:00
it("can set/get with an object", function(){
var panVol = new PanVol();
panVol.set({
"volume" : -10
2015-08-28 22:42:44 +00:00
});
expect(panVol.get().volume).to.be.closeTo(-10, 0.1);
panVol.dispose();
});
2015-08-28 22:42:44 +00:00
it("passes the incoming signal through", function(){
return PassAudio(function(input){
var panVol = new PanVol().toMaster();
input.connect(panVol);
2015-08-28 22:42:44 +00:00
});
});
2015-08-28 22:42:44 +00:00
it("passes the incoming stereo signal through", function(){
return PassAudioStereo(function(input){
var panVol = new PanVol().toMaster();
input.connect(panVol);
2015-08-28 22:42:44 +00:00
});
});
2015-08-28 22:42:44 +00:00
it("can mute the volume", function(){
return Offline(function(){
var vol = new PanVol(0).toMaster();
new Signal(1).connect(vol);
vol.mute = true;
}).then(function(buffer){
expect(buffer.isSilent()).to.be.true;
2017-08-27 17:57:50 +00:00
});
2015-08-28 22:42:44 +00:00
});
2015-08-28 22:42:44 +00:00
});
2017-08-27 17:57:50 +00:00
});