2014-03-15 03:17:18 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
2014-03-15 05:02:33 +00:00
|
|
|
<title>Envelope</title>
|
2014-03-15 03:17:18 +00:00
|
|
|
|
2014-08-27 15:16:49 +00:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=0.5">
|
|
|
|
|
2014-08-26 03:47:07 +00:00
|
|
|
<script type="text/javascript" src="../deps/jquery.min.js"></script>
|
|
|
|
<script type="text/javascript" src="../deps/jquery-ui.js"></script>
|
2014-08-27 15:16:49 +00:00
|
|
|
<script type="text/javascript" src="../deps/jquery.ui.touch-punch.js"></script>
|
2014-06-20 15:04:32 +00:00
|
|
|
<script type="text/javascript" src="../Tone.js"></script>
|
2014-08-26 03:47:07 +00:00
|
|
|
<script type="text/javascript" src="./Widgets.js"></script>
|
2014-08-27 15:16:49 +00:00
|
|
|
<script type="text/javascript" src="./ExampleList.js"></script>
|
2014-08-26 03:47:07 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="./style/widgets.css">
|
|
|
|
<link rel="stylesheet" type="text/css" href="./style/jquery-ui.css">
|
2014-08-27 15:16:49 +00:00
|
|
|
|
2014-03-15 03:17:18 +00:00
|
|
|
</head>
|
2014-04-16 00:05:11 +00:00
|
|
|
<body>
|
2014-08-27 15:16:49 +00:00
|
|
|
<div id="Container">
|
|
|
|
<div id="Explanation">
|
|
|
|
Attack/Decay/Sustain/Release Envelope
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
Click the button to trigger the attack/decay portion of the envelope.
|
|
|
|
Let go of the button to trigger the release.
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
<a href="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope">Read more about ADSR on Wikipedia</a>
|
|
|
|
</div>
|
|
|
|
<div id="Content"></div>
|
2014-08-26 03:47:07 +00:00
|
|
|
</div>
|
2014-06-20 15:04:32 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
<script type="text/javascript">
|
2014-08-26 03:47:07 +00:00
|
|
|
/* global Tone, GUI*/
|
|
|
|
|
|
|
|
var env = new Tone.Envelope(0.05, 0.01, 0.4, 0.4);
|
|
|
|
|
2014-08-27 15:16:49 +00:00
|
|
|
var osc = new Tone.Oscillator(440, "square");
|
2014-04-16 00:05:11 +00:00
|
|
|
|
2014-08-27 15:16:49 +00:00
|
|
|
//connect the envelope to the output gain
|
|
|
|
env.connect(osc.output.gain);
|
2014-06-20 15:04:32 +00:00
|
|
|
|
2014-08-27 15:16:49 +00:00
|
|
|
//start the oscillator
|
|
|
|
osc.toMaster();
|
|
|
|
osc.start();
|
2014-06-20 15:04:32 +00:00
|
|
|
|
2014-08-26 03:47:07 +00:00
|
|
|
// GUI //
|
|
|
|
|
2014-08-28 04:39:17 +00:00
|
|
|
$(function(){
|
|
|
|
var container = $("#Content");
|
2014-08-26 03:47:07 +00:00
|
|
|
|
2014-08-28 04:39:17 +00:00
|
|
|
new GUI.StartButton(Tone.startMobile);
|
|
|
|
new GUI.TopBar(Tone);
|
2014-08-26 03:47:07 +00:00
|
|
|
|
2014-08-28 04:39:17 +00:00
|
|
|
//sliders for the envelope controls
|
|
|
|
new GUI.Envelope(container, env, "envelope");
|
|
|
|
|
|
|
|
new GUI.Momentary(container, function(down){
|
|
|
|
if (down){
|
|
|
|
env.triggerAttack();
|
|
|
|
} else {
|
|
|
|
env.triggerRelease();
|
|
|
|
}
|
|
|
|
}, "attack", "release");
|
|
|
|
});
|
2014-08-26 03:47:07 +00:00
|
|
|
|
2014-03-15 03:17:18 +00:00
|
|
|
</script>
|
2014-08-26 03:47:07 +00:00
|
|
|
|
|
|
|
<style type="text/css">
|
2014-08-27 15:16:49 +00:00
|
|
|
#Content {
|
2014-08-26 03:47:07 +00:00
|
|
|
text-align: center;
|
2014-08-28 04:45:59 +00:00
|
|
|
width: 180px;
|
2014-08-26 03:47:07 +00:00
|
|
|
height: 200px;
|
|
|
|
}
|
2014-08-27 15:16:49 +00:00
|
|
|
.Envelope {
|
2014-08-26 03:47:07 +00:00
|
|
|
margin: auto;
|
|
|
|
}
|
2014-08-28 04:39:17 +00:00
|
|
|
.Momentary {
|
2014-08-26 03:47:07 +00:00
|
|
|
margin-top: 10px;
|
2014-08-28 04:45:59 +00:00
|
|
|
width: 100%;
|
2014-08-26 03:47:07 +00:00
|
|
|
}
|
|
|
|
</style>
|
2014-03-15 03:17:18 +00:00
|
|
|
</body>
|
|
|
|
</html>
|