Tone.js/examples/envelope.html
2014-08-25 23:47:07 -04:00

78 lines
No EOL
1.9 KiB
HTML

<html>
<head>
<title>Envelope</title>
<script type="text/javascript" src="../deps/jquery.min.js"></script>
<script type="text/javascript" src="../deps/jquery-ui.js"></script>
<script type="text/javascript" src="../Tone.js"></script>
<script type="text/javascript" src="./Widgets.js"></script>
<link rel="stylesheet" type="text/css" href="./style/widgets.css">
<link rel="stylesheet" type="text/css" href="./style/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="./style/jquery-ui.theme.css">
<link rel="stylesheet" type="text/css" href="./style/jquery-ui.structure.css">
</head>
<body>
<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="Container"></div>
<script type="text/javascript">
/* global Tone, GUI*/
var env = new Tone.Envelope(0.05, 0.01, 0.4, 0.4);
var noise = new Tone.Noise();
//connect the evnelope to the output gain
env.connect(noise.output.gain);
//start the noise
noise.toMaster();
noise.start();
// GUI //
var container = $("#Container");
new GUI.StartButton(Tone.startMobile);
//sliders for the envelope controls
new GUI.Envelope(container, env, "envelope");
//listen for triggers
$("<button>").button({ label: "attack" })
.mousedown(function(){
env.triggerAttack();
$(this).button({ label: "release" });
})
.mouseup(function(){
env.triggerRelease();
$(this).button({ label: "attack" });
})
.appendTo(container);
</script>
<style type="text/css">
#Container {
text-align: center;
width: 200px;
height: 200px;
}
#Envelope {
margin: auto;
}
button {
margin-top: 10px;
}
</style>
</body>
</html>