2019-01-27 18:05:20 +00:00
|
|
|
import NoiseSynth from "Tone/instrument/NoiseSynth";
|
|
|
|
import Basic from "helper/Basic";
|
|
|
|
import InstrumentTest from "helper/InstrumentTests";
|
|
|
|
import CompareToFile from "helper/CompareToFile";
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
describe("NoiseSynth", function(){
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
Basic(NoiseSynth);
|
|
|
|
InstrumentTest(NoiseSynth, undefined, {
|
|
|
|
envelope : {
|
|
|
|
release : 0.2,
|
|
|
|
decay : 0.1,
|
|
|
|
sustain : 0.5
|
|
|
|
}
|
|
|
|
});
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("matches a file", function(){
|
|
|
|
return CompareToFile(function(){
|
|
|
|
var synth = new NoiseSynth({
|
|
|
|
envelope : {
|
|
|
|
attack : 0.01,
|
|
|
|
decay : 0.4
|
|
|
|
}
|
|
|
|
}).toMaster();
|
|
|
|
synth.triggerAttack(0);
|
|
|
|
synth.triggerAttack(0.3);
|
2019-02-17 17:12:04 +00:00
|
|
|
}, "noiseSynth.wav", 4);
|
2019-01-27 18:05:20 +00:00
|
|
|
});
|
2018-04-25 14:29:07 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("matches another file", function(){
|
|
|
|
return CompareToFile(function(){
|
|
|
|
var synth = new NoiseSynth({
|
|
|
|
envelope : {
|
|
|
|
attack : 0.01,
|
|
|
|
decay : 0.4
|
|
|
|
}
|
|
|
|
}).toMaster();
|
|
|
|
synth.triggerAttackRelease(0.1, 0);
|
2019-02-17 17:12:04 +00:00
|
|
|
}, "noiseSynthRelease.wav", 4);
|
2019-01-27 18:05:20 +00:00
|
|
|
});
|
2018-02-05 18:55:37 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
context("API", function(){
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can get and set noise type", function(){
|
|
|
|
var noiseSynth = new NoiseSynth();
|
|
|
|
noiseSynth.noise.type = "pink";
|
|
|
|
expect(noiseSynth.noise.type).to.equal("pink");
|
|
|
|
noiseSynth.dispose();
|
|
|
|
});
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can get and set envelope attributes", function(){
|
|
|
|
var noiseSynth = new NoiseSynth();
|
|
|
|
noiseSynth.envelope.attack = 0.24;
|
|
|
|
expect(noiseSynth.envelope.attack).to.equal(0.24);
|
|
|
|
noiseSynth.dispose();
|
|
|
|
});
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can be constructed with an options object", function(){
|
|
|
|
var noiseSynth = new NoiseSynth({
|
|
|
|
"envelope" : {
|
|
|
|
"sustain" : 0.3
|
|
|
|
}
|
2015-08-31 15:37:10 +00:00
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
expect(noiseSynth.envelope.sustain).to.equal(0.3);
|
|
|
|
noiseSynth.dispose();
|
|
|
|
});
|
2015-08-31 15:37:10 +00:00
|
|
|
|
2019-01-27 18:05:20 +00:00
|
|
|
it("can get/set attributes", function(){
|
|
|
|
var noiseSynth = new NoiseSynth();
|
|
|
|
noiseSynth.set({
|
|
|
|
"envelope.decay" : 0.24
|
2015-08-31 15:37:10 +00:00
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
expect(noiseSynth.get().envelope.decay).to.equal(0.24);
|
|
|
|
noiseSynth.dispose();
|
2015-08-31 15:37:10 +00:00
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
|
2015-08-31 15:37:10 +00:00
|
|
|
});
|
2017-12-30 16:26:29 +00:00
|
|
|
});
|
2019-01-27 18:05:20 +00:00
|
|
|
|