Tone.js/examples/envelope.html
Yotam Mann eea83d1728 updated examples style and copy
add Logo, updated qwerty hancock & nexusUI
2015-12-06 13:14:36 -05:00

132 lines
No EOL
2.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Envelope</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<script type="text/javascript" src="../build/Tone.js"></script>
<script type="text/javascript" src="./scripts/jquery.min.js"></script>
<script type="text/javascript" src="./scripts/draggabilly.js"></script>
<script type="text/javascript" src="./scripts/Interface.js"></script>
<script type="text/javascript" src="./scripts/Logo.js"></script>
<link rel="stylesheet" type="text/css" href="./style/examples.css">
<script type="text/javascript">
// jshint ignore: start
</script>
</head>
<body>
<style type="text/css">
img {
width: 300px!important;
}
.y {
float: left;
height: 290px!important;
}
#Sliders {
float: left;
position: relative;
width: calc(100% - 100px);
}
.Button {
clear: both;
}
</style>
<div id="Content">
<div id="Title">Envelope</div>
<div id="Explanation">
Envelopes ramp amplitude, frequency or any other parameter over time.
<a href="http://tonejs.org/docs/#Envelope">Tone.Envelope</a> and the classes that extend it
implement an <a href="https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope" target="_blank">ADSR</a> envelope type
which splits its ramp into four distinct phases: Attack, Decay, Sustain, Release.
<img src="https://upload.wikimedia.org/wikipedia/commons/e/ea/ADSR_parameter.svg">
</div>
<div id="Sliders"></div>
</div>
<script type="text/javascript">
var env = new Tone.AmplitudeEnvelope({
"attack" : 0.11,
"decay" : 0.21,
"sustain" : 0.09,
"release" : 1.2
}).toMaster();
//create an oscillator and connect it to the envelope
var osc = new Tone.Oscillator({
"partials" : [3, 2, 1],
"type" : "custom",
"frequency" : "C#4",
"volume" : -8,
}).connect(env).start();
</script>
<script id="GUI" type="text/javascript">
$(function(){
new Interface.Slider({
param : "attack",
name : "attack",
parent : $("#Sliders"),
tone : env,
min : 0.005,
max : 1,
exp : 2,
});
new Interface.Slider({
param : "decay",
name : "decay",
parent : $("#Sliders"),
tone : env,
min : 0.005,
max : 1,
exp : 2,
});
new Interface.Slider({
param : "release",
name : "release",
parent : $("#Sliders"),
tone : env,
min : 0.2,
max : 2,
exp : 2,
});
new Interface.Slider({
param : "sustain",
name : "sustain",
tone : env,
axis : "y",
min : 0.0,
max : 1,
exp : 2,
});
new Interface.Button({
text : "Trigger Attack",
activeText : "Trigger Release",
key : 32, //spacebar
start : function(){
env.triggerAttack();
},
end : function(){
env.triggerRelease();
},
});
});
</script>
</style>
</body>
</html>