mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
synths use OmniOscillator
This commit is contained in:
parent
f5ff008170
commit
ff57f046f3
6 changed files with 81 additions and 18 deletions
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -414,6 +414,26 @@ GUI.Oscillator.prototype.render = function(){
|
|||
this.type.select(type);
|
||||
};
|
||||
|
||||
/**
|
||||
* OMNIOSCILLATOR
|
||||
*/
|
||||
GUI.OmniOscillator = function(container, oscillator, label){
|
||||
this.element = $("<div>", {"class" : "Oscillator"})
|
||||
.appendTo(container);
|
||||
this.oscillator = oscillator;
|
||||
this.label = $("<div>", {"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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<script type="text/javascript" src="./deps/jquery.ui.touch-punch.js"></script>
|
||||
<script type="text/javascript" src="../build/Tone.js"></script>
|
||||
<script type="text/javascript" src="../build/Tone.Preset.js"></script>
|
||||
<script type="text/javascript" src="../Tone/instrument/preset/MonoSynth.Preset.js"></script>
|
||||
<script type="text/javascript" src="./Widgets.js"></script>
|
||||
<script type="text/javascript" src="./ExampleList.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="./style/widgets.css">
|
||||
|
@ -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");
|
||||
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in a new issue