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-06-20 15:04:32 +00:00
|
|
|
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
|
|
|
|
<script type="text/javascript" src="../Tone.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="exampleStyle.css">
|
2014-03-15 03:17:18 +00:00
|
|
|
</head>
|
2014-04-16 00:05:11 +00:00
|
|
|
<body>
|
2014-06-20 15:04:32 +00:00
|
|
|
|
2014-06-23 17:29:22 +00:00
|
|
|
<div>Press down to trigger the attack, release the mouse to trigger the release of the envelope.</div>
|
|
|
|
<br>
|
|
|
|
<button>attack</button>
|
2014-06-20 15:04:32 +00:00
|
|
|
|
2014-04-06 00:47:59 +00:00
|
|
|
<script type="text/javascript">
|
2014-06-20 15:04:32 +00:00
|
|
|
var env = new Tone.Envelope(.05, .01, .4, .4);
|
2014-04-16 00:05:11 +00:00
|
|
|
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();
|
|
|
|
|
|
|
|
//listen for triggers
|
2014-06-23 17:29:22 +00:00
|
|
|
$("button").mousedown(function(){
|
2014-06-20 15:04:32 +00:00
|
|
|
env.triggerAttack();
|
2014-06-23 17:29:22 +00:00
|
|
|
$(this).text("release");
|
2014-06-20 15:04:32 +00:00
|
|
|
});
|
|
|
|
|
2014-06-23 17:29:22 +00:00
|
|
|
$("button").mouseup(function(){
|
2014-06-20 15:04:32 +00:00
|
|
|
env.triggerRelease();
|
2014-06-23 17:29:22 +00:00
|
|
|
$(this).text("attack");
|
2014-06-20 15:04:32 +00:00
|
|
|
});
|
2014-03-15 03:17:18 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|