2014-09-14 19:32:30 +00:00
|
|
|
/* global it, describe */
|
2014-09-09 19:30:36 +00:00
|
|
|
|
|
|
|
define(["tests/Core", "chai", "Tone/instrument/DuoSynth", "Tone/instrument/MonoSynth", "Tone/instrument/FMSynth",
|
2014-09-20 23:24:25 +00:00
|
|
|
"Tone/instrument/PolySynth", "Tone/instrument/Sampler", "Tone/instrument/MultiSampler",
|
2014-11-03 16:43:42 +00:00
|
|
|
"tests/Common", "Tone/instrument/Instrument", "Tone/instrument/PluckSynth", "Tone/instrument/AMSynth"],
|
|
|
|
function(Tone, chai, DuoSynth, MonoSynth, FMSynth, PolySynth, Sampler, MultiSampler, Test, Instrument,
|
|
|
|
PluckSynth, AMSynth){
|
2014-09-09 19:30:36 +00:00
|
|
|
|
|
|
|
var expect = chai.expect;
|
|
|
|
|
2014-09-14 19:32:30 +00:00
|
|
|
Test.onlineContext();
|
|
|
|
|
2014-09-20 23:24:25 +00:00
|
|
|
function extendsInstrument(InstrumentFactory){
|
|
|
|
var inst = new InstrumentFactory();
|
|
|
|
expect(inst).to.be.instanceOf(Instrument);
|
|
|
|
inst.dispose();
|
|
|
|
}
|
|
|
|
|
2014-09-09 19:30:36 +00:00
|
|
|
describe("Tone.MonoSynth", function(){
|
|
|
|
it("can be created and disposed", function(){
|
|
|
|
var ms = new MonoSynth();
|
|
|
|
ms.dispose();
|
2014-09-20 23:24:25 +00:00
|
|
|
Test.wasDisposed(ms);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("extends Instrument", function(){
|
|
|
|
extendsInstrument(MonoSynth);
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
|
|
|
it("handles output connections", function(){
|
|
|
|
var ms = new MonoSynth();
|
|
|
|
Test.acceptsOutput(ms);
|
|
|
|
ms.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("outputs a sound", function(done){
|
|
|
|
var ms;
|
|
|
|
Test.outputsAudio(function(dest){
|
|
|
|
ms = new MonoSynth();
|
|
|
|
ms.connect(dest);
|
|
|
|
ms.triggerAttack("C4");
|
|
|
|
}, function(){
|
|
|
|
ms.dispose();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("Tone.DuoSynth", function(){
|
|
|
|
it("can be created and disposed", function(){
|
|
|
|
var ds = new DuoSynth();
|
|
|
|
ds.dispose();
|
2014-09-20 23:24:25 +00:00
|
|
|
Test.wasDisposed(ds);
|
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
2014-09-20 23:24:25 +00:00
|
|
|
it("extends Instrument", function(){
|
|
|
|
extendsInstrument(DuoSynth);
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
|
|
|
it("handles output connections", function(){
|
|
|
|
var ds = new DuoSynth();
|
|
|
|
Test.acceptsOutput(ds);
|
|
|
|
ds.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("outputs a sound", function(done){
|
|
|
|
var ds;
|
|
|
|
Test.outputsAudio(function(dest){
|
|
|
|
ds = new DuoSynth();
|
|
|
|
ds.connect(dest);
|
|
|
|
ds.triggerAttack("C4");
|
|
|
|
}, function(){
|
|
|
|
ds.dispose();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("Tone.FMSynth", function(){
|
|
|
|
it("can be created and disposed", function(){
|
|
|
|
var fms = new FMSynth();
|
|
|
|
fms.dispose();
|
2014-09-20 23:24:25 +00:00
|
|
|
Test.wasDisposed(fms);
|
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
2014-09-20 23:24:25 +00:00
|
|
|
it("extends Instrument", function(){
|
|
|
|
extendsInstrument(FMSynth);
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
|
|
|
it("handles output connections", function(){
|
|
|
|
var fms = new FMSynth();
|
|
|
|
Test.acceptsOutput(fms);
|
|
|
|
fms.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("outputs a sound", function(done){
|
|
|
|
var fms;
|
|
|
|
Test.outputsAudio(function(dest){
|
|
|
|
fms = new FMSynth();
|
|
|
|
fms.connect(dest);
|
|
|
|
fms.triggerAttack("C4");
|
|
|
|
}, function(){
|
|
|
|
fms.dispose();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("Tone.PolySynth", function(){
|
|
|
|
it("can be created and disposed", function(){
|
|
|
|
var ps = new PolySynth();
|
|
|
|
ps.dispose();
|
2014-09-20 23:24:25 +00:00
|
|
|
Test.wasDisposed(ps);
|
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
2014-09-20 23:24:25 +00:00
|
|
|
it("extends Instrument", function(){
|
|
|
|
extendsInstrument(PolySynth);
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
2014-09-20 23:24:25 +00:00
|
|
|
|
2014-10-13 21:15:58 +00:00
|
|
|
it("handles output connections", function(){
|
|
|
|
var psynth = new PolySynth();
|
|
|
|
Test.acceptsOutput(psynth);
|
|
|
|
psynth.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("outputs a sound", function(done){
|
|
|
|
var psynth;
|
|
|
|
Test.outputsAudio(function(dest){
|
|
|
|
psynth = new PolySynth();
|
|
|
|
psynth.connect(dest);
|
|
|
|
psynth.triggerAttack("C4");
|
|
|
|
}, function(){
|
|
|
|
psynth.dispose();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-10-19 20:17:40 +00:00
|
|
|
|
|
|
|
it("accepts a chord", function(done){
|
|
|
|
var psynth;
|
|
|
|
Test.outputsAudio(function(dest){
|
|
|
|
psynth = new PolySynth(4, DuoSynth);
|
|
|
|
psynth.connect(dest);
|
|
|
|
psynth.triggerAttackRelease(["C4", "E4", "G4"], "8n");
|
|
|
|
}, function(){
|
|
|
|
psynth.dispose();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("Tone.Sampler", function(){
|
|
|
|
it("can be created and disposed", function(){
|
|
|
|
var samp = new Sampler();
|
|
|
|
samp.dispose();
|
2014-09-20 23:24:25 +00:00
|
|
|
Test.wasDisposed(samp);
|
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
2014-09-20 23:24:25 +00:00
|
|
|
it("extends Instrument", function(){
|
|
|
|
extendsInstrument(Sampler);
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
|
|
|
it("handles output connections", function(){
|
|
|
|
var samp = new Sampler();
|
|
|
|
Test.acceptsOutput(samp);
|
|
|
|
samp.dispose();
|
|
|
|
});
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("Tone.MultiSampler", function(){
|
|
|
|
it("can be created and disposed", function(){
|
|
|
|
var samp = new MultiSampler();
|
|
|
|
samp.dispose();
|
2014-09-20 23:24:25 +00:00
|
|
|
Test.wasDisposed(samp);
|
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
|
|
|
it("handles output connections", function(){
|
|
|
|
var samp = new MultiSampler();
|
|
|
|
Test.acceptsOutput(samp);
|
|
|
|
samp.dispose();
|
|
|
|
});
|
|
|
|
|
2014-09-20 23:24:25 +00:00
|
|
|
it("extends Instrument", function(){
|
|
|
|
extendsInstrument(MultiSampler);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("Tone.PluckSynth", function(){
|
|
|
|
it("can be created and disposed", function(){
|
|
|
|
var pluck = new PluckSynth();
|
|
|
|
pluck.dispose();
|
|
|
|
Test.wasDisposed(pluck);
|
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
2014-09-20 23:24:25 +00:00
|
|
|
it("extends Instrument", function(){
|
|
|
|
extendsInstrument(PluckSynth);
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
2014-10-13 21:15:58 +00:00
|
|
|
|
|
|
|
it("handles output connections", function(){
|
|
|
|
var psynth = new PluckSynth();
|
|
|
|
Test.acceptsOutput(psynth);
|
|
|
|
psynth.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("outputs a sound", function(done){
|
|
|
|
var psynth;
|
|
|
|
Test.outputsAudio(function(dest){
|
|
|
|
psynth = new PluckSynth();
|
|
|
|
psynth.connect(dest);
|
|
|
|
psynth.triggerAttack("C4");
|
|
|
|
}, function(){
|
|
|
|
psynth.dispose();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|
2014-11-03 16:43:42 +00:00
|
|
|
|
|
|
|
describe("Tone.AMSynth", function(){
|
|
|
|
it("can be created and disposed", function(){
|
|
|
|
var ams = new AMSynth();
|
|
|
|
ams.dispose();
|
|
|
|
Test.wasDisposed(ams);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("extends Instrument", function(){
|
|
|
|
extendsInstrument(AMSynth);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("handles output connections", function(){
|
|
|
|
var ams = new AMSynth();
|
|
|
|
Test.acceptsOutput(ams);
|
|
|
|
ams.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("outputs a sound", function(done){
|
|
|
|
var ams;
|
|
|
|
Test.outputsAudio(function(dest){
|
|
|
|
ams = new AMSynth();
|
|
|
|
ams.connect(dest);
|
|
|
|
ams.triggerAttack("C4");
|
|
|
|
}, function(){
|
|
|
|
ams.dispose();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2014-09-09 19:30:36 +00:00
|
|
|
});
|