renamed Tone.Presets to Tone.Preset

This commit is contained in:
Yotam Mann 2014-09-04 23:56:34 -04:00
parent 5f43d07020
commit bd5af6b2eb
12 changed files with 613 additions and 20 deletions

2
.gitignore vendored
View file

@ -16,5 +16,5 @@ TODO.txt
utils/npm/Tone
utils/npm/Tone.js
utils/npm/Tone.min.js
utils/npm/Tone.Presets.js
utils/npm/Tone.Preset.js
utils/npm/README.md

View file

@ -32,7 +32,7 @@ Tone.js can also be used like any other script or library by dropping the [Tone.
<script type="text/javascript" src="pathto/Tone.js"></script>
```
To use any of the presets on instruments or effects, be sure to grab the [Tone.Presets build](https://raw.githubusercontent.com/TONEnoTONE/Tone.js/master/build/Tone.Presets.js) which is not included in the default build.
To use any of the presets on instruments or effects, be sure to grab the [Tone.Presets build](https://raw.githubusercontent.com/TONEnoTONE/Tone.js/master/build/Tone.Preset.js) which is not included in the default build.
# AudioContext

View file

@ -7,7 +7,18 @@ define(["Tone/core/Tone", "Tone/effect/AutoWah"], function(Tone){
* @type {Object}
*/
Tone.AutoWah.prototype.preset = {
"springy" : {
"baseFrequency" : 10,
"octaves" : 8,
"sensitivity" : 0,
"Q" : 20,
"gain" : 10,
/** attributes for the envelope follower */
"follower" : {
"attack" : 1,
"release" : 2
}
}
};
return Tone.AutoWah.prototype.preset;

View file

@ -5696,7 +5696,7 @@ define('Tone/effect/AutoWah',["Tone/core/Tone", "Tone/component/Follower", "Tone
* @type {Tone}
* @private
*/
this._sweepRange = new Tone.ScaleExp(0, 1, 0, 1, 2);
this._sweepRange = new Tone.ScaleExp(0, 1, 0, 1, 0.5);
/**
* @type {number}
@ -5714,9 +5714,10 @@ define('Tone/effect/AutoWah',["Tone/core/Tone", "Tone/component/Follower", "Tone
* @type {BiquadFilterNode}
* @private
*/
this._bandpass = this.context.createBiquadFilter();
this._bandpass.type = "bandpass";
this._bandpass.Q.value = 2;
this._bandpass = new Tone.Filter("bandpass");
this._bandpass.setRolloff(-48);
// this._bandpass.type = "bandpass";
// this._bandpass.Q.value = options.Q;
/**
* @type {BiquadFilterNode}
@ -5724,7 +5725,7 @@ define('Tone/effect/AutoWah',["Tone/core/Tone", "Tone/component/Follower", "Tone
*/
this._peaking = this.context.createBiquadFilter();
this._peaking.type = "peaking";
this._peaking.gain.value = 20;
this._peaking.gain.value = options.gain;
//the control signal path
this.chain(this.effectSend, this._follower, this._sweepRange);
@ -5747,6 +5748,8 @@ define('Tone/effect/AutoWah',["Tone/core/Tone", "Tone/component/Follower", "Tone
"baseFrequency" : 100,
"octaves" : 6,
"sensitivity" : 0,
"Q" : 2,
"gain" : 2,
/** attributes for the envelope follower */
"follower" : {
"attack" : 0.3,
@ -5800,6 +5803,8 @@ define('Tone/effect/AutoWah',["Tone/core/Tone", "Tone/component/Follower", "Tone
if (!this.isUndef(params.sensitivity)) this.setSensitiviy(params.sensitivity);
if (!this.isUndef(params.octaves)) this.setOctaves(params.octaves);
if (!this.isUndef(params.follower)) this._follower.set(params.follower);
if (!this.isUndef(params.Q)) this._bandpass.Q.value = params.Q;
if (!this.isUndef(params.gain)) this._peaking.gain.value = params.gain;
Tone.Effect.prototype.set.call(this, params);
};

2
build/Tone.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -6,6 +6,9 @@
<script type="text/javascript" src="./deps/jquery-ui.js"></script>
<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/effect/AutoWah.js"></script>
<script type="text/javascript" src="../Tone/effect/preset/AutoWah.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">
@ -32,13 +35,15 @@
/* globals Tone, GUI */
var synth = new Tone.MonoSynth();
synth.setPreset("Barky");
var dry = Tone.context.createGain();
dry.gain.value = 0;
synth.connect(dry);
dry.toMaster();
synth.setVolume(-10);
var chorusSend = synth.send("chorus");
chorusSend.gain.value = 0;
chorusSend.gain.value = 1;
var phaserSend = synth.send("phaser");
phaserSend.gain.value = 0;
var autowahSend = synth.send("autowah");
@ -53,6 +58,7 @@
phaser.toMaster();
var autoWah = new Tone.AutoWah();
autoWah.receive("autowah");
autoWah.setPreset("preOne");
autoWah.toMaster();
// GUI //
@ -65,14 +71,14 @@
//sliders
var drySlider = new GUI.Slider(content, function(val){
dry.gain.value = val;
}, 1, "dry");
drySlider.render(1);
}, 0, "dry");
// drySlider.render(1);
new GUI.Slider(content, function(val){
chorusSend.gain.value = val;
}, 0, "chorus");
new GUI.Slider(content, function(val){
autowahSend.gain.value = val;
}, 0, "autowah");
}, 1, "autowah");
new GUI.Slider(content, function(val){
phaserSend.gain.value = val;
}, 0, "phaser");

View file

@ -8,7 +8,7 @@
<script type="text/javascript" src="./deps/jquery-ui.js"></script>
<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.Presets.js"></script>
<script type="text/javascript" src="../build/Tone.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">

View file

@ -8,7 +8,7 @@
<script type="text/javascript" src="./deps/jquery-ui.js"></script>
<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.Presets.js"></script>
<script type="text/javascript" src="../build/Tone.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">

View file

@ -8,7 +8,7 @@
<script type="text/javascript" src="./deps/jquery-ui.js"></script>
<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.Presets.js"></script>
<script type="text/javascript" src="../build/Tone.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">

View file

@ -8,7 +8,7 @@
<script type="text/javascript" src="./deps/jquery-ui.js"></script>
<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.Presets.js"></script>
<script type="text/javascript" src="../build/Tone.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">
@ -39,7 +39,7 @@
bass.setVolume(-10);
bass.toMaster();
var keys = new Tone.PolySynth(3, Tone.MonoSynth, Tone.MonoSynth.preset.Pianoetta);
var keys = new Tone.PolySynth(3, Tone.MonoSynth, Tone.MonoSynth.prototype.preset.Pianoetta);
keys.setVolume(-30);
keys.toMaster();

View file

@ -36,7 +36,7 @@ module.exports = function(grunt) {
npm : {
files : [{
expand : true,
src: ["../build/Tone.js", "../build/Tone.min.js", "../build/Tone.Presets.js", "../README.md"],
src: ["../build/Tone.js", "../build/Tone.min.js", "../build/Tone.Preset.js", "../README.md"],
dest: "./npm"
}, {
src : ["../Tone/**"],
@ -62,7 +62,7 @@ module.exports = function(grunt) {
},
presets : {
files: {
"../build/Tone.Presets.js" : ["../Tone/**/preset/*.js"],
"../build/Tone.Preset.js" : ["../Tone/**/preset/*.js"],
}
},
removeRequireString: {

571
utils/npm/Tone.Presets.js Normal file
View file

@ -0,0 +1,571 @@
define(["Tone/core/Tone", "Tone/effect/AutoWah"], function(Tone){
/**
* named presets for the AutoWah
* @const
* @static
* @type {Object}
*/
Tone.AutoWah.preset = {
};
return Tone.AutoWah.preset;
});
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,
"harmonicity" : 1.99,
"voice0" : {
"volume" : -8,
"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" : -1,
"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,
"harmonicity" : 1.005,
"voice0" : {
"volume" : -2,
"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" : -10,
"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;
});
define(["Tone/core/Tone", "Tone/instrument/FMSynth"], function(Tone){
/**
* named presets for the FMSynth
* @const
* @static
* @type {Object}
*/
Tone.FMSynth.preset = {
"Trumpet" : {
"portamento" : 0,
"harmonicity" : 1,
"modulationIndex" : 4,
"carrier" : {
"volume" : 0,
"portamento" : 0,
"oscType" : "square",
"filter" : {
"Q" : 2,
"type" : "lowpass",
"rolloff" : -12
},
"envelope" : {
"attack" : 0.01,
"decay" : 1,
"sustain" : 0.7,
"release" : 0.4
},
"filterEnvelope" : {
"attack" : 0.06,
"decay" : 0.07,
"sustain" : 0.35,
"release" : 0.8,
"min" : 3000,
"max" : 6500
}
},
"modulator" : {
"volume" : -6,
"portamento" : 0,
"oscType" : "triangle",
"filter" : {
"Q" : 0,
"type" : "lowpass",
"rolloff" : -12
},
"envelope" : {
"attack" : 0.15,
"decay" : 0.3,
"sustain" : 1,
"release" : 1.5
},
"filterEnvelope" : {
"attack" : 0.03,
"decay" : 0.25,
"sustain" : 0.7,
"release" : 1,
"min" : 20000,
"max" : 20000
}
}
},
"Koto" : {
"portamento" : 0,
"harmonicity" : 3.01,
"modulationIndex" : 12.7,
"carrier" : {
"volume" : 0,
"portamento" : 0,
"oscType" : "triangle",
"filter" : {
"Q" : 2,
"type" : "lowpass",
"rolloff" : -12
},
"envelope" : {
"attack" : 0.01,
"decay" : 2,
"sustain" : 0,
"release" : 0.8
},
"filterEnvelope" : {
"attack" : 0.06,
"decay" : 0.07,
"sustain" : 0.35,
"release" : 0.8,
"min" : 20000,
"max" : 20000
}
},
"modulator" : {
"volume" : -1,
"portamento" : 0,
"oscType" : "sine",
"filter" : {
"Q" : 0,
"type" : "lowpass",
"rolloff" : -12
},
"envelope" : {
"attack" : 0.02,
"decay" : 2,
"sustain" : 0,
"release" : 0.8
},
"filterEnvelope" : {
"attack" : 0.03,
"decay" : 0.25,
"sustain" : 0.7,
"release" : 1,
"min" : 20000,
"max" : 20000
}
}
},
"ScratchAttack" : {
"portamento" : 0,
"harmonicity" : 10,
"modulationIndex" : 50,
"carrier" : {
"volume" : 0,
"portamento" : 0,
"oscType" : "square",
"filter" : {
"Q" : 2,
"type" : "lowpass",
"rolloff" : -12
},
"envelope" : {
"attack" : 0.08,
"decay" : 0.3,
"sustain" : 0,
"release" : 1.2
},
"filterEnvelope" : {
"attack" : 0.01,
"decay" : 0.1,
"sustain" : 0,
"release" : 0.2,
"min" : 200,
"max" : 10000
}
},
"modulator" : {
"volume" : -6,
"portamento" : 0,
"oscType" : "sine",
"filter" : {
"Q" : 1,
"type" : "highpass",
"rolloff" : -48
},
"envelope" : {
"attack" : 0.1,
"decay" : 0.2,
"sustain" : 0.3,
"release" : 0.01
},
"filterEnvelope" : {
"attack" : 0.2,
"decay" : 0.2,
"sustain" : 0.8,
"release" : 0.01,
"min" : 20,
"max" : 2000
}
}
},
"DistGit" : {
"portamento" : 0,
"harmonicity" : 1,
"modulationIndex" : 10,
"carrier" : {
"volume" : 0,
"portamento" : 0,
"oscType" : "square",
"filter" : {
"Q" : 2,
"type" : "lowpass",
"rolloff" : -12
},
"envelope" : {
"attack" : 0.001,
"decay" : 3.3,
"sustain" : 0,
"release" : 1.2
},
"filterEnvelope" : {
"attack" : 0.05,
"decay" : 0.15,
"sustain" : 1,
"release" : 1.5,
"min" : 400,
"max" : 4000
}
},
"modulator" : {
"volume" : -3,
"portamento" : 0,
"oscType" : "sine",
"filter" : {
"Q" : 1,
"type" : "lowpass",
"rolloff" : -48
},
"envelope" : {
"attack" : 0.3,
"decay" : 0.4,
"sustain" : 1,
"release" : 1.7
},
"filterEnvelope" : {
"attack" : 0.02,
"decay" : 0.02,
"sustain" : 0.1,
"release" : 1.5,
"min" : 200,
"max" : 200
}
}
},
};
/**
* augment the prototype to include setPreset
*/
Tone.FMSynth.prototype.setPreset = function(presetName){
presetName = this.defaultArg(presetName, "CasioPiano");
//look up if it exists
//TODO
//set it
this.set(Tone.FMSynth.preset[presetName]);
};
return Tone.FMSynth.preset;
});
define(["Tone/core/Tone", "Tone/instrument/MonoSynth"], function(Tone){
/**
* named presets for the MonoSynth
* @const
* @static
* @type {Object}
*/
Tone.MonoSynth.preset = {
"Pianoetta" : {
"portamento" : 0.0,
"oscType" : "square",
"filter" : {
"Q" : 6,
"type" : "lowpass",
"rolloff" : -24
},
"envelope" : {
"attack" : 0.005,
"decay" : 3,
"sustain" : 0,
"release" : 0.45
},
"filterEnvelope" : {
"attack" : 0.001,
"decay" : 0.32,
"sustain" : 0.9,
"release" : 3,
"min" : 700,
"max" : 3500
}
},
"Barky" : {
"portamento" : 0.01,
"oscType" : "triangle",
"filter" : {
"Q" : 3,
"type" : "highpass",
"rolloff" : -12
},
"envelope" : {
"attack" : 0.05,
"decay" : 0.15,
"sustain" : 0.6,
"release" : 1
},
"filterEnvelope" : {
"attack" : 0.02,
"decay" : 0.2,
"sustain" : 0.8,
"release" : 1.5,
"min" : 3000,
"max" : 250
}
},
"Bassy" : {
"portamento" : 0.08,
"oscType" : "square",
"filter" : {
"Q" : 4,
"type" : "lowpass",
"rolloff" : -24
},
"envelope" : {
"attack" : 0.04,
"decay" : 0.06,
"sustain" : 0.4,
"release" : 1
},
"filterEnvelope" : {
"attack" : 0.01,
"decay" : 0.1,
"sustain" : 0.6,
"release" : 1.5,
"min" : 50,
"max" : 350
}
},
"BrassCircuit" : {
"portamento" : 0.01,
"oscType" : "sawtooth",
"filter" : {
"Q" : 2,
"type" : "lowpass",
"rolloff" : -12
},
"envelope" : {
"attack" : 0.1,
"decay" : 0.1,
"sustain" : 0.6,
"release" : 0.5
},
"filterEnvelope" : {
"attack" : 0.05,
"decay" : 0.8,
"sustain" : 0.4,
"release" : 1.5,
"min" : 2000,
"max" : 5000
}
},
"Pizz" : {
"portamento" : 0.00,
"oscType" : "square",
"filter" : {
"Q" : 2,
"type" : "highpass",
"rolloff" : -24
},
"envelope" : {
"attack" : 0.01,
"decay" : 0.2,
"sustain" : 0.0,
"release" : 0.2
},
"filterEnvelope" : {
"attack" : 0.01,
"decay" : 0.1,
"sustain" : 0.0,
"release" : 0.1,
"min" : 900,
"max" : 500
}
},
"Kick" : {
"portamento" : 0.00,
"oscType" : "square",
"filter" : {
"Q" : 2,
"type" : "bandpass",
"rolloff" : -12
},
"envelope" : {
"attack" : 0.01,
"decay" : 0.2,
"sustain" : 0.0,
"release" : 0.2
},
"filterEnvelope" : {
"attack" : 0.01,
"decay" : 0.2,
"sustain" : 1,
"release" : 0.4,
"min" : 3000,
"max" : 30
}
},
"LaserSteps" : {
"portamento" : 0.00,
"oscType" : "sawtooth",
"filter" : {
"Q" : 2,
"type" : "bandpass",
"rolloff" : -24
},
"envelope" : {
"attack" : 0.01,
"decay" : 0.1,
"sustain" : 0.2,
"release" : 0.6
},
"filterEnvelope" : {
"attack" : 0.02,
"decay" : 0.4,
"sustain" : 1,
"release" : 0.2,
"min" : 0,
"max" : 7500
}
}
};
/**
* augment the prototype to include setPreset
*/
Tone.MonoSynth.prototype.setPreset = function(presetName){
presetName = this.defaultArg(presetName, "CasioPiano");
//look up if it exists
//TODO
//set it
this.set(Tone.MonoSynth.preset[presetName]);
};
return Tone.MonoSynth.preset;
});