diff --git a/Tone/instrument/DuoSynth.js b/Tone/instrument/DuoSynth.js index 52ceac8d..3a6d462d 100644 --- a/Tone/instrument/DuoSynth.js +++ b/Tone/instrument/DuoSynth.js @@ -26,12 +26,14 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth", "Tone/component/LFO", "To * @type {Tone.MonoSynth} */ this.voice0 = new Tone.MonoSynth(options.voice0); + this.voice0.setVolume(-10); /** * the second voice * @type {Tone.MonoSynth} */ this.voice1 = new Tone.MonoSynth(options.voice1); + this.voice1.setVolume(-10); /** * the vibrato lfo @@ -101,28 +103,37 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth", "Tone/component/LFO", "To "portamento" : 0.05, "voiceRatio" : 1.5, "voice0" : { + "volume" : -10, "portamento" : 0, - "osc0type" : "sine", - "osc1type" : "sawtooth", - "unison" : 20, + "oscType" : "sine", "filterEnvelope" : { "attack" : 0.01, "decay" : 0.0, "sustain" : 1, "release" : 0.5 + }, + "envelope" : { + "attack" : 0.01, + "decay" : 0.0, + "sustain" : 1, + "release" : 0.5 } }, "voice1" : { - "volume" : -6, + "volume" : -10, "portamento" : 0, - "osc0type" : "square", - "osc1type" : "square", - "unison" : 10, + "oscType" : "sine", "filterEnvelope" : { "attack" : 0.01, "decay" : 0.0, "sustain" : 1, "release" : 0.5 + }, + "envelope" : { + "attack" : 0.01, + "decay" : 0.0, + "sustain" : 1, + "release" : 0.5 } } }; @@ -172,7 +183,7 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth", "Tone/component/LFO", "To * set the ratio between the two oscillator * @param {number} ratio */ - Tone.DuoSynth.prototype.setOscRatio = function(ratio){ + Tone.DuoSynth.prototype.setVoiceRatio = function(ratio){ this._frequencyRatio.setValue(ratio); }; @@ -209,16 +220,23 @@ define(["Tone/core/Tone", "Tone/instrument/MonoSynth", "Tone/component/LFO", "To this._vibrato.setFrequency(rate); }; + /** + * set the volume of the instrument. + * borrowed from {@link Tone.Source} + * @function + */ + Tone.DuoSynth.prototype.setVolume = Tone.Source.prototype.setVolume; + /** * bulk setter * @param {Object} param */ Tone.DuoSynth.prototype.set = function(params){ - if (!this.isUndef(params.oscRatio)) this.setOscRatio(params.oscRatio); + if (!this.isUndef(params.voiceRatio)) this.setVoiceRatio(params.voiceRatio); if (!this.isUndef(params.vibratoRate)) this.setVibratoRate(params.vibratoRate); if (!this.isUndef(params.vibratoAmount)) this.setVibratoAmount(params.vibratoAmount); if (!this.isUndef(params.vibratoDelay)) this.setVibratoDelay(params.vibratoDelay); - if (!this.isUndef(params.portamento)) this.portament = this.toSeconds(params.portamento); + if (!this.isUndef(params.portamento)) this.setPortamento(params.portamento); if (!this.isUndef(params.voice0)) this.voice0.set(params.voice0); if (!this.isUndef(params.voice1)) this.voice1.set(params.voice1); }; diff --git a/Tone/instrument/preset/DuoSynth.preset.js b/Tone/instrument/preset/DuoSynth.preset.js new file mode 100644 index 00000000..1a3a36ca --- /dev/null +++ b/Tone/instrument/preset/DuoSynth.preset.js @@ -0,0 +1,135 @@ +define(["Tone/core/Tone", "Tone/instrument/DuoSynth"], function(Tone){ + + /** + * named presets for the DuoSynth + * @const + * @static + * @type {Object} + */ + Tone.DuoSynth.preset = { + "Steely" : { + "vibratoAmount" : 0.0, + "vibratoRate" : 5, + "vibratoDelay" : 1, + "portamento" : 0, + "voiceRatio" : 1.99, + "voice0" : { + "volume" : -20, + "portamento" : 0, + "oscType" : "square", + "filter" : { + "Q" : 2, + "type" : "lowpass", + "rolloff" : -12 + }, + "envelope" : { + "attack" : 0.01, + "decay" : 1, + "sustain" : 0, + "release" : 0.4 + }, + "filterEnvelope" : { + "attack" : 0.001, + "decay" : 0.01, + "sustain" : 0.35, + "release" : 1, + "min" : 20, + "max" : 8000 + } + }, + "voice1" : { + "volume" : -10, + "portamento" : 0, + "oscType" : "sine", + "filter" : { + "Q" : 2, + "type" : "lowpass", + "rolloff" : -12 + }, + "envelope" : { + "attack" : 0.25, + "decay" : 4, + "sustain" : 0, + "release" : 0.8 + }, + "filterEnvelope" : { + "attack" : 0.03, + "decay" : 0.25, + "sustain" : 0.7, + "release" : 1, + "min" : 1000, + "max" : 2500 + } + } + }, + "Rego" : { + "vibratoAmount" : 0.5, + "vibratoRate" : 5, + "vibratoDelay" : 1, + "portamento" : 0.1, + "voiceRatio" : 1.005, + "voice0" : { + "volume" : -10, + "portamento" : 0, + "oscType" : "sawtooth", + "filter" : { + "Q" : 1, + "type" : "lowpass", + "rolloff" : -24 + }, + "envelope" : { + "attack" : 0.01, + "decay" : 0.25, + "sustain" : 0.4, + "release" : 1.2 + }, + "filterEnvelope" : { + "attack" : 0.001, + "decay" : 0.05, + "sustain" : 0.3, + "release" : 2, + "min" : 100, + "max" : 10000 + } + }, + "voice1" : { + "volume" : -100, + "portamento" : 0, + "oscType" : "sawtooth", + "filter" : { + "Q" : 2, + "type" : "bandpass", + "rolloff" : -12 + }, + "envelope" : { + "attack" : 0.25, + "decay" : 4, + "sustain" : 0.1, + "release" : 0.8 + }, + "filterEnvelope" : { + "attack" : 0.05, + "decay" : 0.05, + "sustain" : 0.7, + "release" : 2, + "min" : 5000, + "max" : 2000 + } + } + } + }; + + /** + * augment the prototype to include setPreset + */ + Tone.DuoSynth.prototype.setPreset = function(presetName){ + presetName = this.defaultArg(presetName, "CasioPiano"); + //look up if it exists + //TODO + //set it + this.set(Tone.DuoSynth.preset[presetName]); + }; + + + return Tone.DuoSynth.preset; +}); \ No newline at end of file diff --git a/examples/duoSynth.html b/examples/duoSynth.html new file mode 100644 index 00000000..3696ba96 --- /dev/null +++ b/examples/duoSynth.html @@ -0,0 +1,224 @@ + +
+