mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
updating tests to new APIs
This commit is contained in:
parent
3bc48cbb75
commit
64140ed316
1 changed files with 55 additions and 47 deletions
|
@ -183,11 +183,11 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
|
|
||||||
it("can set the frequency", function(){
|
it("can set the frequency", function(){
|
||||||
var oscillator = new Oscillator();
|
var oscillator = new Oscillator();
|
||||||
oscillator.setFrequency(110);
|
oscillator.frequency.value = 110;
|
||||||
expect(oscillator.frequency.getValue()).to.equal(110);
|
expect(oscillator.frequency.value).to.equal(110);
|
||||||
oscillator.start();
|
oscillator.start();
|
||||||
oscillator.setFrequency(220);
|
oscillator.frequency.value = 220;
|
||||||
expect(oscillator.frequency.getValue()).to.equal(220);
|
expect(oscillator.frequency.value).to.equal(220);
|
||||||
oscillator.dispose();
|
oscillator.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -196,8 +196,8 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
"frequency" : 200,
|
"frequency" : 200,
|
||||||
"detune" : -20
|
"detune" : -20
|
||||||
});
|
});
|
||||||
expect(osc.frequency.getValue()).to.equal(200);
|
expect(osc.frequency.value).to.equal(200);
|
||||||
expect(osc.detune.getValue()).to.equal(-20);
|
expect(osc.detune.value).to.equal(-20);
|
||||||
osc.dispose();
|
osc.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -208,9 +208,9 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
"detune" : -21,
|
"detune" : -21,
|
||||||
"type" : "square"
|
"type" : "square"
|
||||||
});
|
});
|
||||||
expect(osc.frequency.getValue()).to.equal(231);
|
expect(osc.frequency.value).to.equal(231);
|
||||||
expect(osc.detune.getValue()).to.equal(-21);
|
expect(osc.detune.value).to.equal(-21);
|
||||||
expect(osc.getType()).to.equal("square");
|
expect(osc.type).to.equal("square");
|
||||||
osc.dispose();
|
osc.dispose();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -312,14 +312,14 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
|
|
||||||
it("can set the noise types", function(){
|
it("can set the noise types", function(){
|
||||||
var noise = new Noise();
|
var noise = new Noise();
|
||||||
noise.setType("brown");
|
noise.type = "brown";
|
||||||
noise.setType("white");
|
noise.type = "white";
|
||||||
noise.setType("pink");
|
noise.type = "pink";
|
||||||
//even after started
|
//even after started
|
||||||
noise.start();
|
noise.start();
|
||||||
noise.setType("brown");
|
noise.type = "brown";
|
||||||
noise.setType("white");
|
noise.type = "white";
|
||||||
noise.setType("pink");
|
noise.type = "pink";
|
||||||
noise.stop();
|
noise.stop();
|
||||||
noise.dispose();
|
noise.dispose();
|
||||||
});
|
});
|
||||||
|
@ -328,7 +328,7 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
var noise = new Noise({
|
var noise = new Noise({
|
||||||
"type" : "brown"
|
"type" : "brown"
|
||||||
});
|
});
|
||||||
expect(noise.getType()).to.equal("brown");
|
expect(noise.type).to.equal("brown");
|
||||||
noise.dispose();
|
noise.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
noise.set({
|
noise.set({
|
||||||
"type" : "pink"
|
"type" : "pink"
|
||||||
});
|
});
|
||||||
expect(noise.getType()).to.equal("pink");
|
expect(noise.type).to.equal("pink");
|
||||||
noise.dispose();
|
noise.dispose();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -375,13 +375,13 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
|
|
||||||
it("can set the width", function(){
|
it("can set the width", function(){
|
||||||
var pulse = new PulseOscillator();
|
var pulse = new PulseOscillator();
|
||||||
pulse.setWidth(0.2);
|
pulse.width.value = 0.2;
|
||||||
pulse.dispose();
|
pulse.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can set the frequency", function(){
|
it("can set the frequency", function(){
|
||||||
var pulse = new PulseOscillator();
|
var pulse = new PulseOscillator();
|
||||||
pulse.setFrequency(220);
|
pulse.frequency.value = 220;
|
||||||
pulse.dispose();
|
pulse.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -401,8 +401,8 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
"frequency" : 200,
|
"frequency" : 200,
|
||||||
"detune" : -20,
|
"detune" : -20,
|
||||||
});
|
});
|
||||||
expect(osc.frequency.getValue()).to.equal(200);
|
expect(osc.frequency.value).to.equal(200);
|
||||||
expect(osc.detune.getValue()).to.equal(-20);
|
expect(osc.detune.value).to.equal(-20);
|
||||||
osc.dispose();
|
osc.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -413,9 +413,9 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
"detune" : -21,
|
"detune" : -21,
|
||||||
"width" : 0.2
|
"width" : 0.2
|
||||||
});
|
});
|
||||||
expect(osc.frequency.getValue()).to.equal(231);
|
expect(osc.frequency.value).to.equal(231);
|
||||||
expect(osc.detune.getValue()).to.equal(-21);
|
expect(osc.detune.value).to.equal(-21);
|
||||||
expect(osc.width.getValue()).to.be.closeTo(0.2, 0.001);
|
expect(osc.width.value).to.be.closeTo(0.2, 0.001);
|
||||||
osc.dispose();
|
osc.dispose();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -453,13 +453,13 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
|
|
||||||
it("can set the modulation frequency", function(){
|
it("can set the modulation frequency", function(){
|
||||||
var pwm = new PWMOscillator();
|
var pwm = new PWMOscillator();
|
||||||
pwm.setModulationFrequency(0.2);
|
pwm.modulationFrequency.value = 0.2;
|
||||||
pwm.dispose();
|
pwm.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can set the frequency", function(){
|
it("can set the frequency", function(){
|
||||||
var pwm = new PWMOscillator();
|
var pwm = new PWMOscillator();
|
||||||
pwm.setFrequency(220);
|
pwm.frequency.value = 220;
|
||||||
pwm.dispose();
|
pwm.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -479,8 +479,8 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
"frequency" : 200,
|
"frequency" : 200,
|
||||||
"detune" : -20,
|
"detune" : -20,
|
||||||
});
|
});
|
||||||
expect(osc.frequency.getValue()).to.equal(200);
|
expect(osc.frequency.value).to.equal(200);
|
||||||
expect(osc.detune.getValue()).to.equal(-20);
|
expect(osc.detune.value).to.equal(-20);
|
||||||
osc.dispose();
|
osc.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -491,9 +491,9 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
"detune" : -21,
|
"detune" : -21,
|
||||||
"modulationFrequency" : 0.2
|
"modulationFrequency" : 0.2
|
||||||
});
|
});
|
||||||
expect(osc.frequency.getValue()).to.equal(231);
|
expect(osc.frequency.value).to.equal(231);
|
||||||
expect(osc.detune.getValue()).to.equal(-21);
|
expect(osc.detune.value).to.equal(-21);
|
||||||
expect(osc.modulationFrequency.getValue()).to.be.closeTo(0.2, 0.001);
|
expect(osc.modulationFrequency.value).to.be.closeTo(0.2, 0.001);
|
||||||
osc.dispose();
|
osc.dispose();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -528,7 +528,7 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
Test.outputsAudio(function(dest){
|
Test.outputsAudio(function(dest){
|
||||||
osc = new OmniOscillator();
|
osc = new OmniOscillator();
|
||||||
osc.connect(dest);
|
osc.connect(dest);
|
||||||
osc.setType("square");
|
osc.type = "square";
|
||||||
osc.start();
|
osc.start();
|
||||||
}, function(){
|
}, function(){
|
||||||
osc.dispose();
|
osc.dispose();
|
||||||
|
@ -541,7 +541,7 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
Test.outputsAudio(function(dest){
|
Test.outputsAudio(function(dest){
|
||||||
osc = new OmniOscillator();
|
osc = new OmniOscillator();
|
||||||
osc.connect(dest);
|
osc.connect(dest);
|
||||||
osc.setType("pwm");
|
osc.type = "pwm";
|
||||||
osc.start();
|
osc.start();
|
||||||
}, function(){
|
}, function(){
|
||||||
osc.dispose();
|
osc.dispose();
|
||||||
|
@ -568,19 +568,27 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
|
|
||||||
it("can set the modulation frequency only when type is pwm", function(){
|
it("can set the modulation frequency only when type is pwm", function(){
|
||||||
var omni = new OmniOscillator();
|
var omni = new OmniOscillator();
|
||||||
omni.setType("pwm");
|
omni.type = "pwm";
|
||||||
expect(omni.setModulationFrequency.bind(omni, 0.2)).to.not.throw(Error);
|
expect(function(){
|
||||||
omni.setType("pulse");
|
omni.modulationFrequency.value = 0.2;
|
||||||
expect(omni.setModulationFrequency.bind(omni, 0.2)).to.throw(Error);
|
}).to.not.throw(Error);
|
||||||
|
omni.type = "pulse";
|
||||||
|
expect(function(){
|
||||||
|
omni.modulationFrequency.value = 0.2;
|
||||||
|
}).to.throw(Error);
|
||||||
omni.dispose();
|
omni.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can set the modulation width only when type is pulse", function(){
|
it("can set the modulation width only when type is pulse", function(){
|
||||||
var omni = new OmniOscillator();
|
var omni = new OmniOscillator();
|
||||||
omni.setType("pulse");
|
omni.type = "pulse";
|
||||||
expect(omni.setWidth.bind(omni, 0.2)).to.not.throw(Error);
|
expect(function(){
|
||||||
omni.setType("sine");
|
omni.width.value = 0.2;
|
||||||
expect(omni.setWidth.bind(omni, 0.2)).to.throw(Error);
|
}).to.not.throw(Error);
|
||||||
|
omni.type = "sine";
|
||||||
|
expect(function(){
|
||||||
|
omni.width.value = 0.2;
|
||||||
|
}).to.throw(Error);
|
||||||
omni.dispose();
|
omni.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -590,9 +598,9 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
"detune" : -30,
|
"detune" : -30,
|
||||||
"type" : "square"
|
"type" : "square"
|
||||||
});
|
});
|
||||||
expect(osc.frequency.getValue()).to.equal(210);
|
expect(osc.frequency.value).to.equal(210);
|
||||||
expect(osc.detune.getValue()).to.equal(-30);
|
expect(osc.detune.value).to.equal(-30);
|
||||||
expect(osc.getType()).to.equal("square");
|
expect(osc.type).to.equal("square");
|
||||||
osc.dispose();
|
osc.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -603,9 +611,9 @@ function(chai, Player, Master, Oscillator, Recorder, Noise, core, PulseOscillato
|
||||||
"frequency" : 231,
|
"frequency" : 231,
|
||||||
"detune" : -21,
|
"detune" : -21,
|
||||||
});
|
});
|
||||||
expect(osc.frequency.getValue()).to.equal(231);
|
expect(osc.frequency.value).to.equal(231);
|
||||||
expect(osc.detune.getValue()).to.equal(-21);
|
expect(osc.detune.value).to.equal(-21);
|
||||||
expect(osc.getType()).to.equal("pwm");
|
expect(osc.type).to.equal("pwm");
|
||||||
osc.dispose();
|
osc.dispose();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue