diff --git a/Tone/component/Filter.js b/Tone/component/Filter.js index d9b4981c..715f1a83 100644 --- a/Tone/component/Filter.js +++ b/Tone/component/Filter.js @@ -171,11 +171,13 @@ define(["Tone/core/Tone", "Tone/signal/Signal"], function(Tone){ } this.frequency.dispose(); this.Q.dispose(); + this.detune.dispose(); this.gain.dispose(); this._filters = null; this.frequency = null; this.Q = null; this.gain = null; + this.detune = null; }; return Tone.Filter; diff --git a/Tone/instrument/DuoSynth.js b/Tone/instrument/DuoSynth.js index 019b097d..f46d4aa5 100644 --- a/Tone/instrument/DuoSynth.js +++ b/Tone/instrument/DuoSynth.js @@ -220,7 +220,7 @@ function(Tone){ /** * clean up */ - Tone.DuoSynth.dispose = function(){ + Tone.DuoSynth.prototype.dispose = function(){ Tone.Monophonic.prototype.dispose.call(this); this.voice0.dispose(); this.voice1.dispose(); diff --git a/Tone/instrument/FMSynth.js b/Tone/instrument/FMSynth.js index 7ab4e5f7..fcfa54b6 100644 --- a/Tone/instrument/FMSynth.js +++ b/Tone/instrument/FMSynth.js @@ -177,7 +177,7 @@ function(Tone){ /** * clean up */ - Tone.FMSynth.dispose = function(){ + Tone.FMSynth.prototype.dispose = function(){ Tone.Monophonic.prototype.dispose.call(this); this.carrier.dispose(); this.modulator.dispose(); diff --git a/Tone/instrument/MonoSynth.js b/Tone/instrument/MonoSynth.js index e2721cec..14bca543 100644 --- a/Tone/instrument/MonoSynth.js +++ b/Tone/instrument/MonoSynth.js @@ -155,14 +155,15 @@ function(Tone){ this.envelope.dispose(); this.filterEnvelope.dispose(); this.filter.dispose(); - this.detune.dispose(); - this._unison.dispose(); + this._amplitude.disconnect(); this.oscillator = null; this.filterEnvelope = null; this.envelope = null; this.filter = null; this.detune = null; - this._unison = null; + this._amplitude = null; + this.frequency = null; + this.detune = null; }; return Tone.MonoSynth; diff --git a/Tone/instrument/MultiSampler.js b/Tone/instrument/MultiSampler.js index 14922223..d374f158 100644 --- a/Tone/instrument/MultiSampler.js +++ b/Tone/instrument/MultiSampler.js @@ -122,12 +122,13 @@ function(Tone){ /** * clean up */ - Tone.MultiSampler.dispose = function(){ + Tone.MultiSampler.prototype.dispose = function(){ Tone.prototype.dispose.call(this); for (var samp in this.samples){ this.samples[samp].dispose(); this.samples[samp] = null; } + this.samples = null; }; return Tone.MultiSampler; diff --git a/test/test.js b/test/test.js index dd4f7319..0809b31a 100644 --- a/test/test.js +++ b/test/test.js @@ -30,8 +30,8 @@ function wasDisposed(obj, expect){ } var allTests = ["tests/Core", "tests/Timing", "tests/Signal", "tests/SignalComparison", -"tests/SignalMath", "tests/Transport", "tests/Sources", "tests/Components", "tests/Effect"]; -// var allTests = ["tests/Core", "tests/SignalComparison"]; +"tests/SignalMath", "tests/Transport", "tests/Sources", "tests/Components", "tests/Effect", "tests/Instruments"]; +// var allTests = ["tests/Core", "tests/Instruments"]; require(allTests, function(){ mocha.run(); diff --git a/test/tests/Instruments.js b/test/tests/Instruments.js new file mode 100644 index 00000000..8128bcfb --- /dev/null +++ b/test/tests/Instruments.js @@ -0,0 +1,56 @@ +/* global it, describe, wasDisposed */ + +define(["tests/Core", "chai", "Tone/instrument/DuoSynth", "Tone/instrument/MonoSynth", "Tone/instrument/FMSynth", + "Tone/instrument/PolySynth", "Tone/instrument/Sampler", "Tone/instrument/MultiSampler"], +function(Tone, chai, DuoSynth, MonoSynth, FMSynth, PolySynth, Sampler, MultiSampler){ + + var expect = chai.expect; + + describe("Tone.MonoSynth", function(){ + it("can be created and disposed", function(){ + var ms = new MonoSynth(); + ms.dispose(); + wasDisposed(ms, expect); + }); + }); + + describe("Tone.DuoSynth", function(){ + it("can be created and disposed", function(){ + var ds = new DuoSynth(); + ds.dispose(); + wasDisposed(ds, expect); + }); + }); + + describe("Tone.FMSynth", function(){ + it("can be created and disposed", function(){ + var fms = new FMSynth(); + fms.dispose(); + wasDisposed(fms, expect); + }); + }); + + describe("Tone.PolySynth", function(){ + it("can be created and disposed", function(){ + var ps = new PolySynth(); + ps.dispose(); + wasDisposed(ps, expect); + }); + }); + + describe("Tone.Sampler", function(){ + it("can be created and disposed", function(){ + var samp = new Sampler(); + samp.dispose(); + wasDisposed(samp, expect); + }); + }); + + describe("Tone.MultiSampler", function(){ + it("can be created and disposed", function(){ + var samp = new MultiSampler(); + samp.dispose(); + wasDisposed(samp, expect); + }); + }); +}); \ No newline at end of file