Tone.js/examples/monoSynth.html
2017-03-26 16:39:19 -04:00

74 lines
1.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>MonoSynth</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" type="image/png" sizes="174x174" href="./style/favicon.png">
<script src="../build/Tone.js"></script>
<script src="./scripts/jquery.min.js"></script>
<script src="./scripts/draggabilly.js"></script>
<script src="./scripts/StartAudioContext.js"></script>
<script src="./scripts/Interface.js"></script>
<script src="https://tonejs.github.io/Logo/build/Logo.js"></script>
<script src="./scripts/Keyboard.js"></script>
<link rel="stylesheet" type="text/css" href="./style/examples.css">
<script>
// jshint ignore: start
</script>
</head>
<body>
<div id="Content">
<div id="Title">MonoSynth</div>
<div id="Explanation">
<a href="https://tonejs.github.io/docs/#MonoSynth">Tone.MonoSynth</a>
is composed of one oscillator, one filter, and two envelopes.
Both envelopes are triggered simultaneously when a note is triggered.
</div>
<div id="Keyboard"></div>
</div>
<script>
var synth = new Tone.MonoSynth({
"portamento" : 0.01,
"oscillator" : {
"type" : "square"
},
"envelope" : {
"attack" : 0.005,
"decay" : 0.2,
"sustain" : 0.4,
"release" : 1.4,
},
"filterEnvelope" : {
"attack" : 0.005,
"decay" : 0.1,
"sustain" : 0.05,
"release" : 0.8,
"baseFrequency" : 300,
"octaves" : 4
}
}).toMaster();
// GUI //
var keyboard = Interface.Keyboard();
keyboard.keyDown = function (note) {
synth.triggerAttack(note);
};
keyboard.keyUp = function () {
synth.triggerRelease();
};
</script>
</body>
</html>