Tone.js/test/instrument/Synth.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-09-26 01:58:48 +00:00
define(["Tone/instrument/Synth", "helper/Basic", "helper/InstrumentTests", "helper/APITest"],
function (Synth, Basic, InstrumentTest, APITest) {
2015-08-31 15:37:10 +00:00
2016-05-23 23:49:41 +00:00
describe("Synth", function(){
2015-08-31 15:37:10 +00:00
2016-05-23 23:49:41 +00:00
Basic(Synth);
InstrumentTest(Synth, "C4");
2015-08-31 15:37:10 +00:00
context("API", function(){
it ("can get and set oscillator attributes", function(){
2016-05-23 23:49:41 +00:00
var simple = new Synth();
2015-08-31 15:37:10 +00:00
simple.oscillator.type = "triangle";
expect(simple.oscillator.type).to.equal("triangle");
simple.dispose();
});
it ("can get and set envelope attributes", function(){
2016-05-23 23:49:41 +00:00
var simple = new Synth();
2015-08-31 15:37:10 +00:00
simple.envelope.attack = 0.24;
expect(simple.envelope.attack).to.equal(0.24);
simple.dispose();
});
it ("can be constructed with an options object", function(){
2016-05-23 23:49:41 +00:00
var simple = new Synth({
2015-08-31 15:37:10 +00:00
"envelope" : {
"sustain" : 0.3
}
});
expect(simple.envelope.sustain).to.equal(0.3);
simple.dispose();
});
it ("can get/set attributes", function(){
2016-05-23 23:49:41 +00:00
var simple = new Synth();
2015-08-31 15:37:10 +00:00
simple.set({
"envelope.decay" : 0.24
});
expect(simple.get().envelope.decay).to.equal(0.24);
simple.dispose();
});
2016-09-26 01:58:48 +00:00
APITest.method(Synth, "triggerAttack", ["Frequency", "Time=", "NormalRange="]);
APITest.method(Synth, "triggerRelease", ["Time="]);
APITest.method(Synth, "triggerAttackRelease", ["Frequency", "Time=", "Time=", "NormalRange="]);
2015-08-31 15:37:10 +00:00
});
});
});