Tone.js/examples/envelope.html

78 lines
1.9 KiB
HTML
Raw Normal View History

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-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-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>
<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">
2014-03-15 03:17:18 +00:00
</head>
<body>
2014-06-20 15:04:32 +00:00
2014-08-26 03:47:07 +00:00
<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>
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);
var noise = new Tone.Noise();
//connect the evnelope to the output gain
env.connect(noise.output.gain);
2014-06-20 15:04:32 +00:00
//start the noise
noise.toMaster();
noise.start();
2014-08-26 03:47:07 +00:00
// GUI //
var container = $("#Container");
new GUI.StartButton(Tone.startMobile);
//sliders for the envelope controls
new GUI.Envelope(container, env, "envelope");
2014-06-20 15:04:32 +00:00
//listen for triggers
2014-08-26 03:47:07 +00:00
$("<button>").button({ label: "attack" })
.mousedown(function(){
env.triggerAttack();
$(this).button({ label: "release" });
})
.mouseup(function(){
env.triggerRelease();
$(this).button({ label: "attack" });
})
.appendTo(container);
2014-03-15 03:17:18 +00:00
</script>
2014-08-26 03:47:07 +00:00
<style type="text/css">
#Container {
text-align: center;
width: 200px;
height: 200px;
}
#Envelope {
margin: auto;
}
button {
margin-top: 10px;
}
</style>
2014-03-15 03:17:18 +00:00
</body>
</html>