mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-26 03:23:11 +00:00
64 lines
1.6 KiB
HTML
64 lines
1.6 KiB
HTML
<!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">
|
|
<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"/>
|
|
<script src="../build/Tone.js"></script>
|
|
<script src="./js/tone-ui.js"></script>
|
|
<script src="./js/components.js"></script>
|
|
</head>
|
|
<body>
|
|
<tone-example label="AMSynth">
|
|
<div slot="explanation">
|
|
<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>
|
|
|
|
<div id="content">
|
|
</div>
|
|
</tone-example>
|
|
|
|
<script type="text/javascript">
|
|
const synth = new Tone.AMSynth({
|
|
harmonicity: 2.5,
|
|
oscillator: {
|
|
type: "fatsawtooth"
|
|
},
|
|
envelope: {
|
|
attack: 0.1,
|
|
decay: 0.2,
|
|
sustain: 0.2,
|
|
release: 0.3
|
|
},
|
|
modulation: {
|
|
type: "square"
|
|
},
|
|
modulationEnvelope: {
|
|
attack: 0.5,
|
|
decay: 0.01
|
|
}
|
|
}).toDestination();
|
|
|
|
piano({
|
|
tone: synth,
|
|
parent: document.querySelector("#content"),
|
|
noteon: (note) => synth.triggerAttack(note.name),
|
|
noteoff: (note) => synth.triggerRelease()
|
|
});
|
|
|
|
ui({
|
|
tone: synth,
|
|
name: "AMSynth",
|
|
parent: document.querySelector("#content"),
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|