mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 00:27:58 +00:00
78 lines
No EOL
1.9 KiB
HTML
78 lines
No EOL
1.9 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Envelope</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
|
|
|
<script type="text/javascript" src="../build/Tone.js"></script>
|
|
<script type="text/javascript" src="../build/Tone.Preset.js"></script>
|
|
<script type="text/javascript" src="./deps/jquery.min.js"></script>
|
|
<script type="text/javascript" src="./deps/nexusUI.js"></script>
|
|
<script type="text/javascript" src="./deps/prism.js"></script>
|
|
<script type="text/javascript" src="./scripts/Interface.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="./style/examples.css">
|
|
<link rel="stylesheet" type="text/css" href="./style/prism.css">
|
|
|
|
<script type="text/javascript">
|
|
// jshint ignore: start
|
|
</script>
|
|
|
|
</head>
|
|
<body>
|
|
<style type="text/css">
|
|
[nx="button"] {
|
|
height: 120px;
|
|
width: 50%;
|
|
}
|
|
#Envelope {
|
|
width: 50%!important;
|
|
}
|
|
</style>
|
|
<div id="Explanation">
|
|
ADSR Envelope
|
|
<br>
|
|
<br>
|
|
Click the button to trigger the attack/decay portion of the envelope.
|
|
Let go of the button to trigger the release.
|
|
</div>
|
|
<div id="Content">
|
|
<div id="Rack">
|
|
</div>
|
|
<div id="CodeBlock"></div>
|
|
</div>
|
|
|
|
<script id="ToneCode" type="text/javascript">
|
|
var env = new Tone.AmplitudeEnvelope({
|
|
"attack" : 0.01,
|
|
"decay" : 0.02,
|
|
"sustain" : 0.09,
|
|
"release" : 1.2
|
|
}).toMaster();
|
|
|
|
var osc = new Tone.Oscillator(440, "square")
|
|
.connect(env)
|
|
.start();
|
|
|
|
//just so it's not soo loud.
|
|
osc.volume.value = -6;
|
|
</script>
|
|
<script id="GUI" type="text/javascript">
|
|
Interface.Rack("Rack", "Envelope");
|
|
Interface.Momentary("Rack", function(down){
|
|
if (down){
|
|
env.triggerAttack();
|
|
} else {
|
|
env.triggerRelease();
|
|
}
|
|
});
|
|
var envGroup = Interface.Group($("<div>").appendTo("#Rack"), "Envelope");
|
|
Interface.AmplitudeEnvelope(envGroup, env);
|
|
Interface.Code("CodeBlock", "ToneCode");
|
|
</script>
|
|
|
|
</style>
|
|
</body>
|
|
</html> |