2014-10-22 22:49:42 +00:00
|
|
|
<!DOCTYPE html>
|
2014-03-15 03:17:18 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
2014-10-22 22:49:42 +00:00
|
|
|
<meta charset="utf-8">
|
2014-03-15 05:02:33 +00:00
|
|
|
<title>Envelope</title>
|
2014-03-15 03:17:18 +00:00
|
|
|
|
2014-09-06 19:35:31 +00:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
2015-02-12 03:39:28 +00:00
|
|
|
|
2014-09-04 19:20:25 +00:00
|
|
|
<script type="text/javascript" src="../build/Tone.js"></script>
|
2015-02-12 03:39:28 +00:00
|
|
|
<script type="text/javascript" src="../build/Tone.Preset.js"></script>
|
|
|
|
<script type="text/javascript" src="./deps/jquery.min.js"></script>
|
|
|
|
<script type="text/javascript" src="./deps/nexusUI.js"></script>
|
|
|
|
<script type="text/javascript" src="./deps/prism.js"></script>
|
|
|
|
<script type="text/javascript" src="./scripts/Interface.js"></script>
|
2014-08-27 15:16:49 +00:00
|
|
|
|
2015-02-12 03:39:28 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="./style/examples.css">
|
|
|
|
<link rel="stylesheet" type="text/css" href="./style/prism.css">
|
2014-06-20 15:04:32 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
<script type="text/javascript">
|
2015-02-12 03:39:28 +00:00
|
|
|
// jshint ignore: start
|
|
|
|
</script>
|
2014-08-26 03:47:07 +00:00
|
|
|
|
2015-02-12 03:39:28 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<style type="text/css">
|
|
|
|
[nx="button"] {
|
2015-02-20 05:59:19 +00:00
|
|
|
height: 120px;
|
|
|
|
width: 50%;
|
2015-02-12 03:39:28 +00:00
|
|
|
}
|
2015-02-20 05:59:19 +00:00
|
|
|
#Envelope {
|
|
|
|
width: 50%!important;
|
2015-02-12 03:39:28 +00:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<div id="Explanation">
|
|
|
|
ADSR Envelope
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
Click the button to trigger the attack/decay portion of the envelope.
|
|
|
|
Let go of the button to trigger the release.
|
|
|
|
</div>
|
|
|
|
<div id="Content">
|
2015-02-20 05:59:19 +00:00
|
|
|
<div id="Rack">
|
|
|
|
</div>
|
2015-02-12 03:39:28 +00:00
|
|
|
<div id="CodeBlock"></div>
|
|
|
|
</div>
|
2014-08-26 03:47:07 +00:00
|
|
|
|
2015-02-12 03:39:28 +00:00
|
|
|
<script id="ToneCode" type="text/javascript">
|
|
|
|
var env = new Tone.AmplitudeEnvelope({
|
|
|
|
"attack" : 0.01,
|
|
|
|
"decay" : 0.02,
|
|
|
|
"sustain" : 0.09,
|
|
|
|
"release" : 1.2
|
|
|
|
}).toMaster();
|
2014-08-26 03:47:07 +00:00
|
|
|
|
2015-02-12 03:39:28 +00:00
|
|
|
var osc = new Tone.Oscillator(440, "square")
|
|
|
|
.connect(env)
|
|
|
|
.start();
|
2014-08-28 04:39:17 +00:00
|
|
|
|
2015-02-12 03:39:28 +00:00
|
|
|
//just so it's not soo loud.
|
|
|
|
osc.volume.value = -6;
|
|
|
|
</script>
|
|
|
|
<script id="GUI" type="text/javascript">
|
|
|
|
Interface.Rack("Rack", "Envelope");
|
|
|
|
Interface.Momentary("Rack", function(down){
|
|
|
|
if (down){
|
|
|
|
env.triggerAttack();
|
|
|
|
} else {
|
|
|
|
env.triggerRelease();
|
|
|
|
}
|
2014-08-28 04:39:17 +00:00
|
|
|
});
|
2015-02-20 05:59:19 +00:00
|
|
|
var envGroup = Interface.Group($("<div>").appendTo("#Rack"), "Envelope");
|
|
|
|
Interface.AmplitudeEnvelope(envGroup, env);
|
2015-02-12 03:39:28 +00:00
|
|
|
Interface.Code("CodeBlock", "ToneCode");
|
2014-03-15 03:17:18 +00:00
|
|
|
</script>
|
2014-08-26 03:47:07 +00:00
|
|
|
|
|
|
|
</style>
|
2014-03-15 03:17:18 +00:00
|
|
|
</body>
|
|
|
|
</html>
|