diff --git a/Tone/instrument/MonoSynth.js b/Tone/instrument/MonoSynth.js index 10035684..62bd5226 100644 --- a/Tone/instrument/MonoSynth.js +++ b/Tone/instrument/MonoSynth.js @@ -1,4 +1,4 @@ -define(["Tone/core/Tone", "Tone/component/Envelope", "Tone/source/Oscillator", +define(["Tone/core/Tone", "Tone/component/Envelope", "Tone/source/OmniOscillator", "Tone/signal/Signal", "Tone/component/Filter", "Tone/signal/Add", "Tone/instrument/Monophonic"], function(Tone){ @@ -21,9 +21,9 @@ function(Tone){ /** * the first oscillator - * @type {Tone.Oscillator} + * @type {Tone.OmniOscillator} */ - this.oscillator = new Tone.Oscillator(0, options.oscType); + this.oscillator = new Tone.OmniOscillator(options.oscillator); /** * the frequency control signal @@ -81,7 +81,9 @@ function(Tone){ * @type {Object} */ Tone.MonoSynth.defaults = { - "oscType" : "square", + "oscillator" : { + "type" : "square" + }, "filter" : { "Q" : 6, "type" : "lowpass", @@ -139,7 +141,7 @@ function(Tone){ */ Tone.MonoSynth.prototype.set = function(params){ if (!this.isUndef(params.detune)) this.detune.setValue(params.detune); - if (!this.isUndef(params.oscType)) this.setOscType(params.oscType); + if (!this.isUndef(params.oscillator)) this.oscillator.set(params.oscillator); if (!this.isUndef(params.filterEnvelope)) this.filterEnvelope.set(params.filterEnvelope); if (!this.isUndef(params.envelope)) this.envelope.set(params.envelope); if (!this.isUndef(params.filter)) this.filter.set(params.filter); diff --git a/Tone/instrument/preset/MonoSynth.preset.js b/Tone/instrument/preset/MonoSynth.preset.js index af9a9040..b8182172 100644 --- a/Tone/instrument/preset/MonoSynth.preset.js +++ b/Tone/instrument/preset/MonoSynth.preset.js @@ -7,9 +7,37 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth"], function(Tone){ * @type {Object} */ Tone.MonoSynth.prototype.preset = { + "CoolGuy" : { + "portamento" : 0.0, + "oscillator" : { + "type" : "pwm", + "modulationFrequency" : 1 + }, + "filter" : { + "Q" : 6, + "type" : "lowpass", + "rolloff" : -24 + }, + "envelope" : { + "attack" : 0.025, + "decay" : 0.3, + "sustain" : 0.9, + "release" : 2 + }, + "filterEnvelope" : { + "attack" : 0.245, + "decay" : 0.131, + "sustain" : 0.5, + "release" : 2, + "min" : 20, + "max" : 3000 + } + }, "Pianoetta" : { "portamento" : 0.0, - "oscType" : "square", + "oscillator" : { + "type" : "square" + }, "filter" : { "Q" : 6, "type" : "lowpass", @@ -32,7 +60,9 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth"], function(Tone){ }, "Barky" : { "portamento" : 0.01, - "oscType" : "triangle", + "oscillator" : { + "type" : "triangle" + }, "filter" : { "Q" : 3, "type" : "highpass", @@ -55,7 +85,9 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth"], function(Tone){ }, "Bassy" : { "portamento" : 0.08, - "oscType" : "square", + "oscillator" : { + "type" : "square" + }, "filter" : { "Q" : 4, "type" : "lowpass", @@ -78,7 +110,9 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth"], function(Tone){ }, "BrassCircuit" : { "portamento" : 0.01, - "oscType" : "sawtooth", + "oscillator" : { + "type" : "sawtooth" + }, "filter" : { "Q" : 2, "type" : "lowpass", @@ -101,7 +135,9 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth"], function(Tone){ }, "Pizz" : { "portamento" : 0.00, - "oscType" : "square", + "oscillator" : { + "type" : "square" + }, "filter" : { "Q" : 2, "type" : "highpass", @@ -124,7 +160,9 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth"], function(Tone){ }, "Kick" : { "portamento" : 0.00, - "oscType" : "square", + "oscillator" : { + "type" : "square" + }, "filter" : { "Q" : 2, "type" : "bandpass", @@ -147,7 +185,9 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth"], function(Tone){ }, "LaserSteps" : { "portamento" : 0.00, - "oscType" : "sawtooth", + "oscillator" : { + "type" : "sawtooth" + }, "filter" : { "Q" : 2, "type" : "bandpass", diff --git a/examples/Widgets.js b/examples/Widgets.js index 02da86df..50ae10b2 100644 --- a/examples/Widgets.js +++ b/examples/Widgets.js @@ -414,6 +414,26 @@ GUI.Oscillator.prototype.render = function(){ this.type.select(type); }; +/** + * OMNIOSCILLATOR + */ +GUI.OmniOscillator = function(container, oscillator, label){ + this.element = $("
", {"class" : "Oscillator"}) + .appendTo(container); + this.oscillator = oscillator; + this.label = $("
", {"id" : "Label"}) + .appendTo(this.element) + .text(label); + this.type = new GUI.DropDown(this.element, ["sine", "square", "sawtooth", "triangle", "pwm", "pulse"], function(option){ + oscillator.setType(option); + }); +}; + +GUI.OmniOscillator.prototype.render = function(){ + var type = this.oscillator.getType(); + this.type.select(type); +}; + /** * SLIDER + VALUE */ diff --git a/examples/duoSynth.html b/examples/duoSynth.html index b3a4acbe..b14fe88f 100644 --- a/examples/duoSynth.html +++ b/examples/duoSynth.html @@ -73,7 +73,7 @@ //osc 0 var ampEnv0 = new GUI.Envelope(envelope0, synth.voice0.envelope, "amplitude"); - var osc0 = new GUI.Oscillator(envelope0, synth.voice0.oscillator, "oscillator"); + var osc0 = new GUI.OmniOscillator(envelope0, synth.voice0.oscillator, "oscillator"); var osc0Vol = new GUI.Slider(envelope0, function(val){ var vol = synth.gainToDb(val); synth.voice0.setVolume(vol); @@ -82,7 +82,7 @@ //osc 1 var ampEnv1 = new GUI.Envelope(envelope1, synth.voice1.envelope, "amplitude"); - var osc1 = new GUI.Oscillator(envelope1, synth.voice1.oscillator, "oscillator"); + var osc1 = new GUI.OmniOscillator(envelope1, synth.voice1.oscillator, "oscillator"); var osc1Vol = new GUI.Slider(envelope1, function(val){ var vol = synth.gainToDb(val); synth.voice1.setVolume(vol); diff --git a/examples/fmSynth.html b/examples/fmSynth.html index 60b04411..91eb96e1 100644 --- a/examples/fmSynth.html +++ b/examples/fmSynth.html @@ -74,7 +74,7 @@ //osc 0 var ampEnv0 = new GUI.Envelope(envelope0, synth.carrier.envelope, "amplitude"); - var osc0 = new GUI.Oscillator(envelope0, synth.carrier.oscillator, "oscillator"); + var osc0 = new GUI.OmniOscillator(envelope0, synth.carrier.oscillator, "oscillator"); var osc0Vol = new GUI.Slider(envelope0, function(val){ var vol = synth.gainToDb(val); synth.carrier.setVolume(vol); @@ -83,7 +83,7 @@ //osc 1 var ampEnv1 = new GUI.Envelope(envelope1, synth.modulator.envelope, "amplitude"); - var osc1 = new GUI.Oscillator(envelope1, synth.modulator.oscillator, "oscillator"); + var osc1 = new GUI.OmniOscillator(envelope1, synth.modulator.oscillator, "oscillator"); var osc1Vol = new GUI.Slider(envelope1, function(val){ var vol = synth.gainToDb(val); synth.modulator.setVolume(vol); diff --git a/examples/monoSynth.html b/examples/monoSynth.html index 0b40ea88..a87feb01 100644 --- a/examples/monoSynth.html +++ b/examples/monoSynth.html @@ -9,6 +9,7 @@ + @@ -69,7 +70,7 @@ //envelopes var ampEnv = new GUI.Envelope(envelope, synth.envelope, "amplitude"); - var osc = new GUI.Oscillator(envelope, synth.oscillator, "oscillator"); + var osc = new GUI.OmniOscillator(envelope, synth.oscillator, "oscillator"); //filter var filtEnv =new GUI.Envelope(filter, synth.filterEnvelope, "filter"); @@ -128,7 +129,7 @@ maxFilFreq.render(maxVal); } - setPreset("Pianoetta"); + setPreset("CoolGuy");