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

74 lines
1.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FMSynth</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">FMSynth</div>
<div id="Explanation">
<a href="https://tonejs.github.io/docs/#FMSynth">Tone.FMSynth</a>
is composed of two
<a href="https://tonejs.github.io/docs/#Synth">Tone.Synths</a>
where one Tone.Synth modulates the frequency of a second Tone.Synth.
</div>
</div>
<script>
var synth = new Tone.FMSynth({
"modulationIndex" : 12.22,
"envelope" : {
"attack" : 0.01,
"decay" : 0.2
},
"modulation" : {
"type" : "square"
},
"modulationEnvelope" : {
"attack" : 0.2,
"decay" : 0.01
}
}).toMaster();
// GUI //
Interface.Slider({
tone : synth,
param : "modulationIndex",
name : "mod index",
max : 100
});
var keyboard = Interface.Keyboard();
keyboard.keyDown = function (note) {
synth.triggerAttack(note);
};
keyboard.keyUp = function (note) {
synth.triggerRelease();
};
</script>
</body>
</html>