2018-02-05 18:55:37 +00:00
|
|
|
define(["Tone/instrument/PluckSynth", "helper/Basic",
|
2018-02-05 19:36:58 +00:00
|
|
|
"helper/InstrumentTests", "helper/CompareToFile", "helper/Supports"],
|
2018-05-28 22:01:03 +00:00
|
|
|
function(PluckSynth, Basic, InstrumentTest, CompareToFile, Supports){
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2018-02-05 18:55:37 +00:00
|
|
|
describe("PluckSynth", function(){
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2018-02-05 18:55:37 +00:00
|
|
|
Basic(PluckSynth);
|
2016-03-16 17:13:32 +00:00
|
|
|
|
2018-02-05 18:55:37 +00:00
|
|
|
InstrumentTest(PluckSynth, "C3");
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2018-02-05 19:36:58 +00:00
|
|
|
if (Supports.CHROME_AUDIO_RENDERING){
|
|
|
|
it("matches a file", function(){
|
|
|
|
return CompareToFile(function(){
|
2018-06-02 02:02:05 +00:00
|
|
|
var synth = new PluckSynth().toMaster();
|
2018-02-05 19:36:58 +00:00
|
|
|
synth.triggerAttack("C4");
|
2018-06-07 16:28:31 +00:00
|
|
|
}, "pluckSynth.wav", 0.25);
|
2018-02-05 19:36:58 +00:00
|
|
|
});
|
|
|
|
}
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2018-02-05 18:55:37 +00:00
|
|
|
context("API", function(){
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2018-02-05 18:55:37 +00:00
|
|
|
it("can get and set resonance", function(){
|
|
|
|
var pluck = new PluckSynth();
|
|
|
|
pluck.resonance.value = 0.4;
|
|
|
|
expect(pluck.resonance.value).to.be.closeTo(0.4, 0.001);
|
|
|
|
pluck.dispose();
|
|
|
|
});
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2018-02-05 18:55:37 +00:00
|
|
|
it("can get and set dampening", function(){
|
|
|
|
var pluck = new PluckSynth();
|
|
|
|
pluck.dampening.value = 2000;
|
|
|
|
expect(pluck.dampening.value).to.be.closeTo(2000, 0.1);
|
|
|
|
pluck.dispose();
|
|
|
|
});
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2018-02-05 18:55:37 +00:00
|
|
|
it("can get and set the attackNoise", function(){
|
|
|
|
var pluck = new PluckSynth();
|
|
|
|
pluck.attackNoise = 0.2;
|
|
|
|
expect(pluck.attackNoise).to.be.closeTo(0.2, 0.1);
|
|
|
|
pluck.dispose();
|
|
|
|
});
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2018-02-05 18:55:37 +00:00
|
|
|
it("can be constructed with an options object", function(){
|
|
|
|
var pluck = new PluckSynth({
|
|
|
|
"dampening" : 300
|
2015-08-31 15:37:10 +00:00
|
|
|
});
|
2018-02-05 18:55:37 +00:00
|
|
|
expect(pluck.dampening.value).to.be.closeTo(300, 0.1);
|
|
|
|
pluck.dispose();
|
|
|
|
});
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2018-02-05 18:55:37 +00:00
|
|
|
it("can be constructed with an options object", function(){
|
|
|
|
var pluck = new PluckSynth({
|
|
|
|
"resonance" : 0.5
|
|
|
|
});
|
|
|
|
expect(pluck.resonance.value).to.be.closeTo(0.5, 0.001);
|
|
|
|
pluck.dispose();
|
2017-12-30 16:26:29 +00:00
|
|
|
});
|
2018-02-05 18:55:37 +00:00
|
|
|
|
2015-08-31 15:37:10 +00:00
|
|
|
});
|
|
|
|
});
|
2018-02-05 18:55:37 +00:00
|
|
|
});
|