mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
c109efe191
simplified oscillators
83 lines
No EOL
1.9 KiB
HTML
83 lines
No EOL
1.9 KiB
HTML
<html>
|
|
<head>
|
|
<title>Envelope</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=0.5">
|
|
|
|
<script type="text/javascript" src="../deps/jquery.min.js"></script>
|
|
<script type="text/javascript" src="../deps/jquery-ui.js"></script>
|
|
<script type="text/javascript" src="../deps/jquery.ui.touch-punch.js"></script>
|
|
<script type="text/javascript" src="../Tone.js"></script>
|
|
<script type="text/javascript" src="./Widgets.js"></script>
|
|
<script type="text/javascript" src="./ExampleList.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="./style/widgets.css">
|
|
<link rel="stylesheet" type="text/css" href="./style/jquery-ui.css">
|
|
|
|
</head>
|
|
<body>
|
|
<div id="Container">
|
|
<div id="Explanation">
|
|
Attack/Decay/Sustain/Release Envelope
|
|
<br>
|
|
<br>
|
|
Click the button to trigger the attack/decay portion of the envelope.
|
|
Let go of the button to trigger the release.
|
|
<br>
|
|
<br>
|
|
<a href="http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope">Read more about ADSR on Wikipedia</a>
|
|
</div>
|
|
<div id="Content"></div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
/* global Tone, GUI*/
|
|
|
|
var env = new Tone.Envelope(0.05, 0.01, 0.4, 0.4);
|
|
|
|
var osc = new Tone.Oscillator(440, "square");
|
|
|
|
//connect the envelope to the output gain
|
|
env.connect(osc.output.gain);
|
|
|
|
//start the oscillator
|
|
osc.toMaster();
|
|
osc.start();
|
|
|
|
// GUI //
|
|
|
|
$(function(){
|
|
var container = $("#Content");
|
|
|
|
new GUI.StartButton(Tone.startMobile);
|
|
new GUI.TopBar(Tone);
|
|
|
|
//sliders for the envelope controls
|
|
new GUI.Envelope(container, env, "envelope");
|
|
|
|
new GUI.Momentary(container, function(down){
|
|
if (down){
|
|
env.triggerAttack();
|
|
} else {
|
|
env.triggerRelease();
|
|
}
|
|
}, "attack", "release");
|
|
});
|
|
|
|
</script>
|
|
|
|
<style type="text/css">
|
|
#Content {
|
|
text-align: center;
|
|
width: 180px;
|
|
height: 200px;
|
|
}
|
|
.Envelope {
|
|
margin: auto;
|
|
}
|
|
.Momentary {
|
|
margin-top: 10px;
|
|
width: 100%;
|
|
}
|
|
</style>
|
|
</body>
|
|
</html> |