2015-06-26 05:23:05 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>PolySynth</title>
|
|
|
|
|
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
|
|
|
|
2020-07-18 00:58:09 +00:00
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.4.3/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:58:09 +00:00
|
|
|
<script src="./js/tone-ui.js"></script>
|
|
|
|
<script src="./js/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;
|
|
|
|
}
|
|
|
|
</style>
|
2020-07-18 00:36:42 +00:00
|
|
|
<tone-example label="Polyphony">
|
|
|
|
<div slot="explanation">
|
2019-01-09 01:21:29 +00:00
|
|
|
<a href="https://tonejs.github.io/docs/PolySynth">Tone.PolySynth</a>
|
|
|
|
handles voice creation and allocation for any monophonic
|
2015-06-27 21:25:01 +00:00
|
|
|
instruments passed in as the second parameter. PolySynth is
|
2015-06-26 05:23:05 +00:00
|
|
|
not a synthesizer by itself, it merely manages voices of
|
|
|
|
one of the other types of synths, allowing any of the
|
|
|
|
monophonic synthesizers to be polyphonic.
|
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>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2020-07-19 00:20:19 +00:00
|
|
|
const synth = new Tone.PolySynth(Tone.Synth, {
|
|
|
|
oscillator: {
|
|
|
|
partials: [0, 2, 3, 4],
|
2015-12-05 18:20:53 +00:00
|
|
|
}
|
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({
|
2020-07-19 00:20:19 +00:00
|
|
|
parent: document.querySelector("#content"),
|
2020-07-18 00:36:42 +00:00
|
|
|
polyphonic: true,
|
|
|
|
noteon: note => synth.triggerAttack(note.name),
|
|
|
|
noteoff: note => synth.triggerRelease(note.name)
|
2020-07-19 00:20:19 +00:00
|
|
|
});
|
2020-07-18 00:36:42 +00:00
|
|
|
|
|
|
|
ui({
|
|
|
|
tone: synth,
|
2020-07-19 00:20:19 +00:00
|
|
|
parent: document.querySelector("#content"),
|
|
|
|
});
|
2015-06-26 05:23:05 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
2019-01-09 01:21:29 +00:00
|
|
|
</html>
|