Tone.js/examples/amSynth.html

65 lines
1.6 KiB
HTML
Raw Normal View History

2019-01-10 04:25:30 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>AMSynth</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" type="image/png" sizes="174x174" href="./favicon.png">
2020-07-18 00:58:09 +00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/webcomponents-bundle.js"></script>
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet"/>
2019-01-10 04:25:30 +00:00
<script src="../build/Tone.js"></script>
2020-07-18 00:58:09 +00:00
<script src="./js/tone-ui.js"></script>
<script src="./js/components.js"></script>
2019-01-10 04:25:30 +00:00
</head>
<body>
<tone-example label="AMSynth">
<div slot="explanation">
2019-01-10 04:25:30 +00:00
<a href="https://tonejs.github.io/docs/AMSynth">Tone.AMSynth</a>
is composed of two
<a href="https://tonejs.github.io/docs/Synth">Tone.Synths</a>
where one Tone.Synth modulates the amplitude of a second Tone.Synth.
</div>
2019-01-10 04:25:30 +00:00
<div id="content">
</div>
2019-01-10 04:25:30 +00:00
</tone-example>
<script type="text/javascript">
const synth = new Tone.AMSynth({
harmonicity: 2.5,
oscillator: {
type: "fatsawtooth"
2019-01-10 04:25:30 +00:00
},
envelope: {
attack: 0.1,
decay: 0.2,
sustain: 0.2,
release: 0.3
2019-01-10 04:25:30 +00:00
},
modulation: {
type: "square"
2019-01-10 04:25:30 +00:00
},
modulationEnvelope: {
attack: 0.5,
decay: 0.01
2019-01-10 04:25:30 +00:00
}
}).toDestination();
piano({
tone: synth,
parent: document.querySelector("#content"),
noteon: (note) => synth.triggerAttack(note.name),
noteoff: (note) => synth.triggerRelease()
2020-07-19 00:20:19 +00:00
});
2019-01-10 04:25:30 +00:00
ui({
tone: synth,
name: "AMSynth",
parent: document.querySelector("#content"),
2020-07-19 00:20:19 +00:00
});
2019-01-10 04:25:30 +00:00
</script>
</body>
</html>