Tone.js/examples/envelope.html
2014-04-04 20:24:19 -04:00

61 lines
No EOL
1.3 KiB
HTML

<html>
<head>
<title>Envelope</title>
<link rel="stylesheet" type="text/css" href="../style/GUI.css">
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="../src/core/Tone.js"></script>
<script type="text/javascript" src="../src/component/Envelope.js"></script>
<script type="text/javascript" src="../src/component/Noise.js"></script>
</head>
<body>
<style type="text/css">
#Trigger {
margin-left: -50px;
margin-top: -50px;
width: 100px;
height: 100px;
position: absolute;
top: 50%;
left: 50%;
background-color: blue;
}
#Trigger:after {
font-family: monospace;
position: absolute;
width: 100%;
content: "attack";
color: white;
text-align: center;
line-height: 100px;
}
#Trigger:active {
background-color: white;
color: black;
}
#Trigger:active:after {
content: "release";
color: black;
}
</style>
<div id='Trigger'></div>
<script type="text/javascript">
var env = new Tone.Envelope(.05, .01, .7, .4);
var noise = new Tone.Noise();
noise.connect(env);
env.toMaster();
$("#Trigger").bind("mousedown", function(e){
env.triggerAttack();
});
$("#Trigger").bind("mouseup", function(e){
env.triggerRelease();
});
</script>
</body>
</html>