Tone.js/examples/envelope.html

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