Tone.js/test/instrument/Synth.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-05-23 23:49:41 +00:00
define(["Tone/instrument/Synth", "helper/Basic", "helper/InstrumentTests"], function (Synth, Basic, InstrumentTest) {
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();
});
});
});
});