Tone.js/test/instrument/AMSynth.js

68 lines
1.7 KiB
JavaScript
Raw Normal View History

define(["Tone/instrument/AMSynth", "helper/Basic",
"helper/InstrumentTests", "helper/CompareToFile"],
function(AMSynth, Basic, InstrumentTest, CompareToFile){
2015-08-31 15:37:10 +00:00
describe("AMSynth", function(){
Basic(AMSynth);
InstrumentTest(AMSynth, "C4");
it("matches a file", function(){
return CompareToFile(function(){
2018-06-02 02:02:05 +00:00
var synth = new AMSynth().toMaster();
synth.triggerAttackRelease("C5", 0.1, 0.1);
}, "amSynth.wav", 0.15);
});
2015-08-31 15:37:10 +00:00
context("API", function(){
2017-12-30 16:26:29 +00:00
it("can get and set carrier attributes", function(){
2015-08-31 15:37:10 +00:00
var amSynth = new AMSynth();
amSynth.oscillator.type = "triangle";
expect(amSynth.oscillator.type).to.equal("triangle");
2015-08-31 15:37:10 +00:00
amSynth.dispose();
});
2017-12-30 16:26:29 +00:00
it("can get and set modulator attributes", function(){
2015-08-31 15:37:10 +00:00
var amSynth = new AMSynth();
amSynth.envelope.attack = 0.24;
expect(amSynth.envelope.attack).to.equal(0.24);
2015-08-31 15:37:10 +00:00
amSynth.dispose();
});
2017-12-30 16:26:29 +00:00
it("can get and set harmonicity", function(){
2015-08-31 15:37:10 +00:00
var amSynth = new AMSynth();
amSynth.harmonicity.value = 2;
expect(amSynth.harmonicity.value).to.equal(2);
amSynth.dispose();
});
2017-12-30 16:26:29 +00:00
it("can be constructed with an options object", function(){
2015-08-31 15:37:10 +00:00
var amSynth = new AMSynth({
"oscillator" : {
"type" : "square"
},
"modulationEnvelope" : {
"attack" : 0.3
2015-08-31 15:37:10 +00:00
}
});
expect(amSynth.modulationEnvelope.attack).to.equal(0.3);
expect(amSynth.oscillator.type).to.equal("square");
2015-08-31 15:37:10 +00:00
amSynth.dispose();
});
2017-12-30 16:26:29 +00:00
it("can get/set attributes", function(){
2015-08-31 15:37:10 +00:00
var amSynth = new AMSynth();
amSynth.set({
2016-05-15 00:10:31 +00:00
"harmonicity" : 1.5,
"detune" : 1200
2015-08-31 15:37:10 +00:00
});
expect(amSynth.get().harmonicity).to.equal(1.5);
2016-05-15 00:10:31 +00:00
expect(amSynth.get().detune).to.be.closeTo(1200, 1);
2015-08-31 15:37:10 +00:00
amSynth.dispose();
});
});
});
2017-12-30 16:26:29 +00:00
});