2015-06-26 05:23:05 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
2016-05-23 23:52:56 +00:00
|
|
|
<title>Synth</title>
|
2015-06-26 05:23:05 +00:00
|
|
|
|
2019-01-09 01:21:29 +00:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
|
|
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
|
2015-06-26 05:23:05 +00:00
|
|
|
|
2019-01-09 01:21:29 +00:00
|
|
|
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@^2/webcomponents-bundle.js"></script>
|
2020-07-18 00:36:42 +00:00
|
|
|
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet"/>
|
2019-01-09 01:21:29 +00:00
|
|
|
<script src="../build/Tone.js"></script>
|
2020-07-18 00:36:42 +00:00
|
|
|
<script src="../../examples/dist/tone-gui.js"></script>
|
|
|
|
<script src="../../examples/dist/components.js"></script>
|
2015-06-26 05:23:05 +00:00
|
|
|
</head>
|
2019-01-09 01:21:29 +00:00
|
|
|
<body>
|
|
|
|
<style>
|
|
|
|
tone-piano {
|
|
|
|
margin-bottom: 10px;
|
2015-06-26 05:23:05 +00:00
|
|
|
}
|
|
|
|
</style>
|
2020-07-18 00:36:42 +00:00
|
|
|
<tone-example label="Synth">
|
|
|
|
<div slot="explanation">
|
2019-01-09 01:21:29 +00:00
|
|
|
<a href="https://tonejs.github.io/docs/Synth" target="_blank">Tone.Synth</a> is composed simply of a
|
|
|
|
<a href="https://tonejs.github.io/docs/OmniOscillator" target="_blank">Tone.OmniOscillator</a>
|
2015-06-26 05:23:05 +00:00
|
|
|
routed through a
|
2019-01-09 01:21:29 +00:00
|
|
|
<a href="https://tonejs.github.io/docs/AmplitudeEnvelope" target="_blank">Tone.AmplitudeEnvelope</a>.
|
2020-07-18 00:36:42 +00:00
|
|
|
</div>
|
2015-06-26 05:23:05 +00:00
|
|
|
|
2020-07-18 00:36:42 +00:00
|
|
|
<div id="content">
|
|
|
|
</div>
|
2019-01-09 01:21:29 +00:00
|
|
|
</tone-example>
|
2015-06-26 05:23:05 +00:00
|
|
|
|
2019-01-09 01:21:29 +00:00
|
|
|
<script type="text/javascript">
|
2020-07-18 00:36:42 +00:00
|
|
|
const synth = new Tone.Synth({
|
2015-06-26 05:23:05 +00:00
|
|
|
"oscillator" : {
|
2018-03-29 20:57:04 +00:00
|
|
|
"type" : "amtriangle",
|
|
|
|
"harmonicity" : 0.5,
|
2018-03-06 05:03:04 +00:00
|
|
|
"modulationType" : "sine"
|
2015-06-26 05:23:05 +00:00
|
|
|
},
|
|
|
|
"envelope" : {
|
2019-01-09 01:21:29 +00:00
|
|
|
"attackCurve" : "exponential",
|
2018-03-06 05:03:04 +00:00
|
|
|
"attack" : 0.05,
|
2015-06-26 05:23:05 +00:00
|
|
|
"decay" : 0.2,
|
2015-12-05 18:20:53 +00:00
|
|
|
"sustain" : 0.2,
|
2018-03-06 05:03:04 +00:00
|
|
|
"release" : 1.5,
|
|
|
|
},
|
|
|
|
"portamento" : 0.05
|
2020-07-18 00:36:42 +00:00
|
|
|
}).toDestination();
|
2015-06-26 05:23:05 +00:00
|
|
|
|
2020-07-18 00:36:42 +00:00
|
|
|
piano({
|
|
|
|
tone: synth,
|
|
|
|
parent: document.querySelector("#content"),
|
|
|
|
noteon: (note) => synth.triggerAttack(note.name),
|
|
|
|
noteoff: (note) => synth.triggerRelease()
|
|
|
|
})
|
|
|
|
|
|
|
|
ui({
|
|
|
|
tone: synth,
|
|
|
|
name: "Synth",
|
|
|
|
parent: document.querySelector("#content"),
|
|
|
|
})
|
2015-06-26 05:23:05 +00:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
2019-01-09 01:21:29 +00:00
|
|
|
</html>
|