Tone.js/examples/simpleSynth.html

66 lines
1.7 KiB
HTML
Raw Normal View History

2015-06-26 05:23:05 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<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>
<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>
<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>
<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>.
</div>
2015-06-26 05:23:05 +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">
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,
"sustain" : 0.2,
2018-03-06 05:03:04 +00:00
"release" : 1.5,
},
"portamento" : 0.05
}).toDestination();
2015-06-26 05:23:05 +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>