Tone.js/examples/envelope.html

38 lines
No EOL
876 B
HTML

<html>
<head>
<title>Envelope</title>
<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">
</head>
<body>
<div>Press down to trigger the attack, release the mouse to trigger the release of the envelope.</div>
<br>
<button>attack</button>
<script type="text/javascript">
var env = new Tone.Envelope(.05, .01, .4, .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();
//listen for triggers
$("button").mousedown(function(){
env.triggerAttack();
$(this).text("release");
});
$("button").mouseup(function(){
env.triggerRelease();
$(this).text("attack");
});
</script>
</body>
</html>