Tone.js/examples/envelope.html

38 lines
876 B
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-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>
<body>
2014-06-20 15:04:32 +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);
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
$("button").mousedown(function(){
2014-06-20 15:04:32 +00:00
env.triggerAttack();
$(this).text("release");
2014-06-20 15:04:32 +00:00
});
$("button").mouseup(function(){
2014-06-20 15:04:32 +00:00
env.triggerRelease();
$(this).text("attack");
2014-06-20 15:04:32 +00:00
});
2014-03-15 03:17:18 +00:00
</script>
</body>
</html>